Skip to content

Commit babb879

Browse files
author
Jicheng Lu
committed
add demo script
1 parent 5be85d3 commit babb879

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<None Remove="data\agents\01fcc3e5-0af7-49e6-ad7a-a760bd12dc4d\instructions\instruction.liquid" />
8181
<None Remove="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\agent.json" />
8282
<None Remove="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\instructions\instruction.liquid" />
83+
<None Remove="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\codes\src\demo.py" />
8384
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\agent.json" />
8485
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\instructions\instruction.liquid" />
8586
<None Remove="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\templates\.welcome.liquid" />
@@ -126,7 +127,7 @@
126127
<Content Include="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\instructions\instruction.liquid">
127128
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
128129
</Content>
129-
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\agent.json">
130+
<Content Include="data\agents\01e2fc5c-2c89-4ec7-8470-7688608b496c\codes\src\demo.py">
130131
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
131132
</Content>
132133
<Content Include="data\agents\01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a\functions\response_to_user.json">

src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ await hook.OnResponseGenerated(new InstructResponseModel
233233
response = new InstructResult
234234
{
235235
MessageId = message.MessageId,
236+
Template = scriptName,
236237
Text = result?.Result?.ToString()
237238
};
238239

src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.AgentCodeScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace BotSharp.Core.Repository;
44

55
public partial class FileRepository
66
{
7-
#region Code
7+
#region Code script
88
public List<AgentCodeScript> GetAgentCodeScripts(string agentId, AgentCodeScriptFilter? filter = null)
99
{
1010
if (string.IsNullOrWhiteSpace(agentId))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import argparse
2+
3+
def main():
4+
parser = argparse.ArgumentParser(description="Receive named arguments")
5+
parser.add_argument("--first_name", required=True, help="The first name")
6+
parser.add_argument("--last_name", required=True, help="The last name")
7+
8+
args = parser.parse_args()
9+
print(f"Hello, {args.first_name} {args.last_name}!")
10+
11+
if __name__ == "__main__":
12+
main()

src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentCodeScriptDocument.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public class AgentCodeScriptDocument : MongoBase
88
public string Name { get; set; } = default!;
99
public string Content { get; set; } = default!;
1010
public string ScriptType { get; set; } = default!;
11+
public DateTime CreatedTime { get; set; }
12+
public DateTime UpdatedTime { get; set; }
1113

1214
public static AgentCodeScriptDocument ToMongoModel(AgentCodeScript script)
1315
{

src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.AgentCodeScript.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace BotSharp.Plugin.MongoStorage.Repository;
55

66
public partial class MongoRepository
77
{
8-
#region Code
8+
#region Code script
99
public List<AgentCodeScript> GetAgentCodeScripts(string agentId, AgentCodeScriptFilter? filter = null)
1010
{
1111
if (string.IsNullOrWhiteSpace(agentId))
@@ -72,6 +72,7 @@ public bool UpdateAgentCodeScripts(string agentId, List<AgentCodeScript> scripts
7272
builder.Eq(y => y.ScriptType, x.ScriptType)
7373
}),
7474
Builders<AgentCodeScriptDocument>.Update.Set(y => y.Content, x.Content)
75+
.Set(x => x.UpdatedTime, DateTime.UtcNow)
7576
))
7677
.ToList();
7778

@@ -91,6 +92,8 @@ public bool BulkInsertAgentCodeScripts(string agentId, List<AgentCodeScript> scr
9192
var script = AgentCodeScriptDocument.ToMongoModel(x);
9293
script.AgentId = agentId;
9394
script.Id = x.Id.IfNullOrEmptyAs(Guid.NewGuid().ToString());
95+
script.CreatedTime = DateTime.UtcNow;
96+
script.UpdatedTime = DateTime.UtcNow;
9497
return script;
9598
}).ToList();
9699

0 commit comments

Comments
 (0)