Skip to content

Commit 418a713

Browse files
authored
Merge pull request #551 from iceljc/features/relocate-generate_image
move generate image to file handler
2 parents c698dba + 53821d1 commit 418a713

17 files changed

Lines changed: 22 additions & 93 deletions

File tree

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

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>$(TargetFramework)</TargetFramework>
@@ -47,9 +47,7 @@
4747

4848
<ItemGroup>
4949
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\agent.json" />
50-
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\generate_image.json" />
5150
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\instruction.liquid" />
52-
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\generate_image.fn.liquid" />
5351
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\agent.json" />
5452
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions.json" />
5553
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions\human_intervention_needed.json" />
@@ -157,12 +155,6 @@
157155
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\instruction.liquid">
158156
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
159157
</Content>
160-
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\generate_image.json">
161-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
162-
</Content>
163-
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\generate_image.fn.liquid">
164-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
165-
</Content>
166158
<Content Include="data\plugins\config.json">
167159
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
168160
</Content>

src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using BotSharp.Core.Files.Hooks;
21
using BotSharp.Core.Files.Services;
32
using Microsoft.Extensions.Configuration;
43

@@ -16,8 +15,5 @@ public class FilePlugin : IBotSharpPlugin
1615
public void RegisterDI(IServiceCollection services, IConfiguration config)
1716
{
1817
services.AddScoped<IBotSharpFileService, BotSharpFileService>();
19-
20-
services.AddScoped<IAgentHook, ImageGeneratorHook>();
21-
services.AddScoped<IAgentUtilityHook, ImageGeneratorUtilityHook>();
2218
}
2319
}

src/Infrastructure/BotSharp.Core/Files/Hooks/ImageGeneratorHook.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/Infrastructure/BotSharp.Core/Files/Hooks/ImageGeneratorUtilityHook.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Plugins/BotSharp.Plugin.EmailHandler/BotSharp.Plugin.EmailHandler.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>$(TargetFramework)</TargetFramework>
@@ -12,8 +12,8 @@
1212

1313
<ItemGroup>
1414
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_email_request.json" />
15-
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\email_attachment_prompt.liquid" />
1615
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_email_request.fn.liquid" />
16+
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\select_attachment_prompt.liquid" />
1717
</ItemGroup>
1818

1919
<ItemGroup>
@@ -23,7 +23,7 @@
2323
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_email_request.fn.liquid">
2424
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2525
</Content>
26-
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\email_attachment_prompt.liquid">
26+
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\select_attachment_prompt.liquid">
2727
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2828
</Content>
2929
</ItemGroup>

src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailRequestFn.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public async Task<bool> Execute(RoleDialogModel message)
5656
}
5757

5858
mailMessage.Body = bodyBuilder.ToMessageBody();
59-
var response = await HandleSendEmailBySMTP(mailMessage);
59+
var response = await SendEmailBySMTP(mailMessage);
6060
message.Content = response;
6161

6262
_logger.LogWarning($"Email successfully send over to {recipient}. Email Subject: {subject} [{response}]");
@@ -96,7 +96,7 @@ private async Task<IEnumerable<MessageFileModel>> SelectFiles(IEnumerable<Messag
9696
{
9797
return $"id: {idx + 1}, file_name: {x.FileName}.{x.FileType}, content_type: {x.ContentType}";
9898
}).ToList();
99-
var prompt = db.GetAgentTemplate(BuiltInAgentId.UtilityAssistant, "email_attachment_prompt");
99+
var prompt = db.GetAgentTemplate(BuiltInAgentId.UtilityAssistant, "select_attachment_prompt");
100100
prompt = render.Render(prompt, new Dictionary<string, object>
101101
{
102102
{ "file_list", promptFiles }
@@ -140,7 +140,7 @@ private void BuildEmailAttachments(BodyBuilder builder, IEnumerable<MessageFileM
140140
}
141141
}
142142

143-
private async Task<string> HandleSendEmailBySMTP(MimeMessage mailMessage)
143+
private async Task<string> SendEmailBySMTP(MimeMessage mailMessage)
144144
{
145145
using var smtpClient = new SmtpClient();
146146
await smtpClient.ConnectAsync(_emailSettings.SMTPServer, _emailSettings.SMTPPort, SecureSocketOptions.StartTls);

src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/handle_email_request.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "handle_email_request",
3-
"description": "If the user requests to send an email, you need to capture the email content and the recipient email address. If the user explicitly enter email subject use the same if not intelligently capture the email subject from the content. Then call this function to send out email.",
3+
"description": "If the user requests to send an email with or without attachments or files, you need to capture the email content and the recipient email address. If the user explicitly enter email subject use the same if not intelligently capture the email subject from the content. Then call this function to send out email.",
44
"parameters": {
55
"type": "object",
66
"properties": {
@@ -18,7 +18,7 @@
1818
},
1919
"is_need_attachments": {
2020
"type": "boolean",
21-
"description": "If the user request to send email with attachemnt(s), then this value should be true. Otherwise, this value should be false."
21+
"description": "If the user request to send email with attachemnt(s) or file(s), then this value should be True. Otherwise, this value should be False."
2222
}
2323
},
2424
"required": [ "to_address", "email_content", "subject", "is_need_attachments" ]
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Suppose user has uploaded some attachments.
21
Please call handle_email_request if user wants to send out an email.

src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/email_attachment_prompt.liquid renamed to src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_attachment_prompt.liquid

File renamed without changes.

0 commit comments

Comments
 (0)