Skip to content

Commit 7387208

Browse files
author
Jicheng Lu
committed
Merge branch 'master' of https://github.com/SciSharp/BotSharp into feature/refine-cronttab
2 parents 0de06a9 + b99ef1f commit 7387208

File tree

36 files changed

+221
-146
lines changed

36 files changed

+221
-146
lines changed

src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class AgentType
1010
/// <summary>
1111
/// Planning agent
1212
/// </summary>
13-
public const string Planning = "plan";
13+
public const string Planning = "planning";
1414

1515
public const string Evaluating = "evaluation";
1616

src/Infrastructure/BotSharp.Abstraction/Agents/Enums/BuiltInAgentId.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ public class BuiltInAgentId
3232
/// </summary>
3333
public const string Learner = "01acc3e5-0af7-49e6-ad7a-a760bd12dc40";
3434

35-
/// <summary>
36-
/// Plan feasible implementation steps for complex problems
37-
/// </summary>
38-
public const string Planner = "282a7128-69a1-44b0-878c-a9159b88f3b9";
39-
4035
/// <summary>
4136
/// SQL statement generation
4237
/// </summary>

src/Infrastructure/BotSharp.Abstraction/Crontab/Models/CrontabItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public class CrontabItem : ScheduleTaskArgs
1919

2020
public override string ToString()
2121
{
22-
return $"{Topic}: {Description} [AgentId: {AgentId}, UserId: {UserId}]";
22+
return $"{Title}: {Description} [AgentId: {AgentId}, UserId: {UserId}]";
2323
}
2424
}

src/Infrastructure/BotSharp.Abstraction/Crontab/Models/CrontabItemFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class CrontabItemFilter : Pagination
1111
[JsonPropertyName("conversation_ids")]
1212
public IEnumerable<string>? ConversationIds { get; set; }
1313

14-
[JsonPropertyName("topics")]
15-
public IEnumerable<string>? Topics { get; set; }
14+
[JsonPropertyName("titles")]
15+
public IEnumerable<string>? Titles { get; set; }
1616

1717
public CrontabItemFilter()
1818
{

src/Infrastructure/BotSharp.Abstraction/Crontab/Models/ScheduleTaskArgs.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ public class ScheduleTaskArgs
55
[JsonPropertyName("cron_expression")]
66
public string Cron { get; set; } = null!;
77

8-
[JsonPropertyName("topic")]
9-
public string Topic { get; set; } = null!;
8+
[JsonPropertyName("title")]
9+
public string Title { get; set; } = null!;
1010

1111
[JsonPropertyName("description")]
1212
public string Description { get; set; } = null!;
1313

14+
[JsonPropertyName("to_do_list")]
15+
public ScheduleTaskItemArgs[] Tasks { get; set; } = null!;
16+
}
17+
18+
public class ScheduleTaskItemArgs
19+
{
20+
[JsonPropertyName("topic")]
21+
public string Topic { get; set; } = null!;
22+
1423
[JsonPropertyName("script")]
1524
public string Script { get; set; } = null!;
1625

src/Infrastructure/BotSharp.Abstraction/Planning/ITaskPlanner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace BotSharp.Abstraction.Planning;
88
/// </summary>
99
public interface ITaskPlanner
1010
{
11+
string Name => "Unamed Task Planner";
1112
Task<FunctionCallFromLlm> GetNextInstruction(Agent router, string messageId, List<RoleDialogModel> dialogs);
1213
Task<bool> AgentExecuting(Agent router, FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs);
1314
Task<bool> AgentExecuted(Agent router, FunctionCallFromLlm inst, RoleDialogModel message, List<RoleDialogModel> dialogs);

src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutableAgent.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public class RoutableAgent
1313
[JsonPropertyName("description")]
1414
public string Description { get; set; } = string.Empty;
1515

16+
[JsonPropertyName("type")]
17+
public string Type { get; set; } = AgentType.Task;
18+
1619
[JsonPropertyName("profiles")]
1720
public List<string> Profiles { get; set; }
1821
= new List<string>();

src/Infrastructure/BotSharp.Core.Crontab/Functions/ScheduleTaskFn.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using BotSharp.Abstraction.Repositories;
12
using BotSharp.Abstraction.Routing;
23
using BotSharp.Abstraction.Users;
34
using BotSharp.Core.Crontab.Hooks;
@@ -22,16 +23,18 @@ public async Task<bool> Execute(RoleDialogModel message)
2223
var user = _services.GetRequiredService<IUserIdentity>();
2324
var crontabItem = new CrontabItem
2425
{
25-
Topic = args.Topic,
26+
Title = args.Title,
2627
Description = args.Description,
2728
Cron = args.Cron,
28-
Script = args.Script,
29-
Language = args.Language,
3029
UserId = user.Id,
3130
AgentId = routing.EntryAgentId,
32-
ConversationId = routing.ConversationId
31+
ConversationId = routing.ConversationId,
32+
Tasks = args.Tasks,
3333
};
3434

35+
var db = _services.GetRequiredService<IBotSharpRepository>();
36+
// var ret = db.InsertCrontabItem(crontabItem);
37+
3538
return true;
3639
}
3740
}

src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabService.cs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,7 @@ You may obtain a copy of the License at
1414
limitations under the License.
1515
******************************************************************************/
1616

17-
using BotSharp.Abstraction.Agents.Enums;
18-
using BotSharp.Abstraction.Conversations;
19-
using BotSharp.Abstraction.Routing;
20-
using BotSharp.Core.Infrastructures;
21-
22-
23-
/*****************************************************************************
24-
Copyright 2024 Written by Haiping Chen. All Rights Reserved.
25-
26-
Licensed under the Apache License, Version 2.0 (the "License");
27-
you may not use this file except in compliance with the License.
28-
You may obtain a copy of the License at
29-
30-
http://www.apache.org/licenses/LICENSE-2.0
31-
32-
Unless required by applicable law or agreed to in writing, software
33-
distributed under the License is distributed on an "AS IS" BASIS,
34-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35-
See the License for the specific language governing permissions and
36-
limitations under the License.
37-
******************************************************************************/
38-
17+
using BotSharp.Abstraction.Repositories;
3918
using Microsoft.Extensions.Logging;
4019

4120
namespace BotSharp.Core.Crontab.Services;
@@ -57,24 +36,9 @@ public CrontabService(IServiceProvider services, ILogger<CrontabService> logger)
5736

5837
public async Task<List<CrontabItem>> GetCrontable()
5938
{
60-
var convService = _services.GetRequiredService<IConversationService>();
61-
var conv = await convService.GetConversation("73a9ee27-d597-4739-958f-3bd79760ac8e");
62-
if (conv == null || !conv.States.ContainsKey("cron_expression"))
63-
{
64-
return [];
65-
}
66-
67-
return
68-
[
69-
new CrontabItem
70-
{
71-
Topic = conv.States["topic"],
72-
Cron = conv.States["cron_expression"],
73-
Description = conv.States["description"],
74-
Script = conv.States["script"],
75-
Language = conv.States["language"]
76-
}
77-
];
39+
var repo = _services.GetRequiredService<IBotSharpRepository>();
40+
var crontable = repo.GetCrontabItems(CrontabItemFilter.Empty());
41+
return crontable.Items.ToList();
7842
}
7943

8044
public async Task ScheduledTimeArrived(CrontabItem item)

src/Infrastructure/BotSharp.Core.Crontab/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-crontab-schedule_task.json

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,37 @@
88
"type": "string",
99
"description": "cron expression include seconds"
1010
},
11-
"topic": {
11+
"title": {
1212
"type": "string",
13-
"description": "task topic in 1-3 keywords related to business entities"
13+
"description": "task short title"
1414
},
1515
"description": {
1616
"type": "string",
17-
"description": "task description without cron infromation, should include all key business entities"
17+
"description": "the task summary"
1818
},
19-
"script": {
20-
"type": "string",
21-
"description": "task related script, commands or provided function with parameters"
22-
},
23-
"language": {
24-
"type": "string",
25-
"enum": ["sql", "function"],
26-
"description": "script programming language"
19+
"to_do_list": {
20+
"type": "array",
21+
"description": "task to do list, should include all key business entities",
22+
"items": {
23+
"type": "object",
24+
"properties": {
25+
"topic": {
26+
"type": "string",
27+
"description": "task topic in 1-3 keywords related to the step"
28+
},
29+
"script": {
30+
"type": "string",
31+
"description": "task related script, function with parameters or plain text"
32+
},
33+
"language": {
34+
"type": "string",
35+
"enum": [ "function", "sql", "python", "text" ],
36+
"description": "programming language script, function or plain text"
37+
}
38+
}
39+
}
2740
}
2841
},
29-
"required": [ "cron_expression", "topic", "description", "script", "language" ]
42+
"required": [ "cron_expression", "title", "description", "to_do_list" ]
3043
}
3144
}

0 commit comments

Comments
 (0)