Skip to content

Commit ad26a85

Browse files
author
Jicheng Lu
committed
rename
1 parent 78ce65b commit ad26a85

File tree

6 files changed

+44
-23
lines changed

6 files changed

+44
-23
lines changed

src/Infrastructure/BotSharp.Abstraction/Rules/RuleGraph.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void AddNode(RuleNode node)
8787
}
8888
}
8989

90-
public void AddEdge(RuleNode from, RuleNode to, GraphItemPayload payload)
90+
public void AddEdge(RuleNode from, RuleNode to, EdgeItemPayload payload)
9191
{
9292
var sourceFound = _nodes.Exists(x => x.Id.IsEqualTo(from.Id));
9393
var targetFound = _nodes.Exists(x => x.Id.IsEqualTo(to.Id));
@@ -112,6 +112,7 @@ public void AddEdge(RuleNode from, RuleNode to, GraphItemPayload payload)
112112
Type = payload.Type,
113113
Labels = [.. payload.Labels ?? []],
114114
Weight = payload.Weight,
115+
Purpose = payload.Purpose,
115116
Description = payload.Description,
116117
Config = new(payload.Config ?? [])
117118
});
@@ -213,12 +214,29 @@ public class GraphItem
213214
public virtual string Type { get; set; } = null!;
214215
public virtual IEnumerable<string> Labels { get; set; } = [];
215216
public virtual double Weight { get; set; } = 1.0;
217+
public virtual string? Purpose { get; set; }
216218
public virtual string? Description { get; set; }
217219
public virtual Dictionary<string, string?> Config { get; set; } = [];
218220
}
219221

220-
public class GraphItemPayload : GraphItem
222+
public class NodeItem : GraphItem
221223
{
224+
225+
}
226+
227+
public class EdgeItem : GraphItem
228+
{
229+
230+
}
231+
232+
public class NodeItemPayload : GraphItem
233+
{
234+
235+
}
236+
237+
public class EdgeItemPayload : GraphItem
238+
{
239+
222240
}
223241

224242
public class RuleGraphInfo

src/Infrastructure/BotSharp.Core.Rules/Actions/ChatRuleAction.cs renamed to src/Infrastructure/BotSharp.Core.Rules/Actions/ChatAction.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
namespace BotSharp.Core.Rules.Actions;
22

3-
public sealed class ChatRuleAction : IRuleAction
3+
public sealed class ChatAction : IRuleAction
44
{
55
private readonly IServiceProvider _services;
6-
private readonly ILogger<ChatRuleAction> _logger;
6+
private readonly ILogger<ChatAction> _logger;
77

8-
public ChatRuleAction(
8+
public ChatAction(
99
IServiceProvider services,
10-
ILogger<ChatRuleAction> logger)
10+
ILogger<ChatAction> logger)
1111
{
1212
_services = services;
1313
_logger = logger;

src/Infrastructure/BotSharp.Core.Rules/Actions/HttpRuleAction.cs renamed to src/Infrastructure/BotSharp.Core.Rules/Actions/HttpRequestAction.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
namespace BotSharp.Core.Rules.Actions;
66

7-
public sealed class HttpRuleAction : IRuleAction
7+
public sealed class HttpRequestAction : IRuleAction
88
{
99
private readonly IServiceProvider _services;
10-
private readonly ILogger<HttpRuleAction> _logger;
10+
private readonly ILogger<HttpRequestAction> _logger;
1111
private readonly IHttpClientFactory _httpClientFactory;
1212

13-
public HttpRuleAction(
13+
public HttpRequestAction(
1414
IServiceProvider services,
15-
ILogger<HttpRuleAction> logger,
15+
ILogger<HttpRequestAction> logger,
1616
IHttpClientFactory httpClientFactory)
1717
{
1818
_services = services;

src/Infrastructure/BotSharp.Core.Rules/Actions/FunctionCallRuleAction.cs renamed to src/Infrastructure/BotSharp.Core.Rules/Actions/ToolCallAction.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
namespace BotSharp.Core.Rules.Actions;
44

5-
public sealed class FunctionCallRuleAction : IRuleAction
5+
public sealed class ToolCallAction : IRuleAction
66
{
77
private readonly IServiceProvider _services;
8-
private readonly ILogger<FunctionCallRuleAction> _logger;
8+
private readonly ILogger<ToolCallAction> _logger;
99

10-
public FunctionCallRuleAction(
10+
public ToolCallAction(
1111
IServiceProvider services,
12-
ILogger<FunctionCallRuleAction> logger)
12+
ILogger<ToolCallAction> logger)
1313
{
1414
_services = services;
1515
_logger = logger;
1616
}
1717

18-
public string Name => "function_call";
18+
public string Name => "tool_call";
1919

2020
public async Task<RuleNodeResult> ExecuteAsync(
2121
Agent agent,
@@ -45,7 +45,7 @@ public async Task<RuleNodeResult> ExecuteAsync(
4545
Response = funcArg?.RichContent?.Message?.Text ?? funcArg?.Content,
4646
Data = new()
4747
{
48-
["function_name"] = funcName!,
48+
["function_name"] = func.Name!,
4949
["function_argument"] = funcArg?.ConvertToString() ?? "{}",
5050
["function_call_result"] = funcArg?.RichContent?.Message?.Text ?? funcArg?.Content ?? string.Empty
5151
}

src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
2222
services.AddScoped<IRuleEngine, RuleEngine>();
2323

2424
// Register rule actions
25-
services.AddScoped<IRuleAction, ChatRuleAction>();
26-
services.AddScoped<IRuleAction, HttpRuleAction>();
27-
services.AddScoped<IRuleAction, FunctionCallRuleAction>();
25+
services.AddScoped<IRuleAction, ChatAction>();
26+
services.AddScoped<IRuleAction, HttpRequestAction>();
27+
services.AddScoped<IRuleAction, ToolCallAction>();
2828

2929
// Register rule conditions
3030
services.AddScoped<IRuleCondition, LoopingCondition>();

src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ private RuleGraph BuildGraph(GraphQueryResult result)
172172
Weight = sourceNodeWeight,
173173
Name = GetGraphItemAttribute(sourceNodeProps, key: "name", defaultValue: "node"),
174174
Type = GetGraphItemAttribute(sourceNodeProps, key: "type", defaultValue: "action"),
175-
Description = GetGraphItemAttribute(sourceNodeProps, key: "description", defaultValue: "unknown"),
175+
Purpose = GetGraphItemAttribute(sourceNodeProps, key: "purpose", defaultValue: ""),
176+
Description = GetGraphItemAttribute(sourceNodeProps, key: "description", defaultValue: ""),
176177
Config = GetConfig(sourceNodeProps)
177178
};
178179

@@ -184,17 +185,19 @@ private RuleGraph BuildGraph(GraphQueryResult result)
184185
Weight = targetNodeWeight,
185186
Name = GetGraphItemAttribute(targetNodeProps, key: "name", defaultValue: "node"),
186187
Type = GetGraphItemAttribute(targetNodeProps, key: "type", defaultValue: "action"),
187-
Description = GetGraphItemAttribute(targetNodeProps, key: "description", defaultValue: "unknown"),
188+
Purpose = GetGraphItemAttribute(targetNodeProps, key: "purpose", defaultValue: ""),
189+
Description = GetGraphItemAttribute(targetNodeProps, key: "description", defaultValue: ""),
188190
Config = GetConfig(targetNodeProps)
189191
};
190192

191193
// Create edge payload
192-
var edgePayload = new GraphItemPayload()
194+
var edgePayload = new EdgeItemPayload()
193195
{
194196
Id = edgeId ?? Guid.NewGuid().ToString(),
195197
Name = GetGraphItemAttribute(edgeProps, key: "name", defaultValue: "edge"),
196198
Type = GetGraphItemAttribute(edgeProps, key: "type", defaultValue: "next"),
197-
Description = GetGraphItemAttribute(edgeProps, key: "description", defaultValue: "unknown"),
199+
Purpose = GetGraphItemAttribute(edgeProps, key: "purpose", defaultValue: ""),
200+
Description = GetGraphItemAttribute(edgeProps, key: "description", defaultValue: ""),
198201
Weight = edgeWeight,
199202
Config = GetConfig(edgeProps)
200203
};

0 commit comments

Comments
 (0)