Skip to content

Commit 89af1d7

Browse files
committed
Set default LlmConfig for Agent level.
1 parent 1e89ea0 commit 89af1d7

6 files changed

Lines changed: 52 additions & 4 deletions

File tree

‎src/Infrastructure/BotSharp.Abstraction/Agents/Settings/AgentSettings.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ public class AgentSettings
44
{
55
public string DataDir { get; set; } = string.Empty;
66
public string TemplateFormat { get; set; } = "liquid";
7+
8+
/// <summary>
9+
/// This is the default LLM config for agent
10+
/// </summary>
11+
public AgentLlmConfig LlmConfig { get; set; }
12+
= new AgentLlmConfig();
713
}

‎src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ public async Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialog
1919
}
2020

2121
var agentService = _services.GetRequiredService<IAgentService>();
22+
var agentSetting = _services.GetRequiredService<AgentSettings>();
2223
var agent = await agentService.LoadAgent(agentId);
2324

2425
var chatCompletion = CompletionProvider.GetChatCompletion(_services,
25-
provider: agent?.LlmConfig?.Provider,
26-
model: agent.LlmConfig?.Model);
26+
provider: agent?.LlmConfig?.Provider ?? agentSetting.LlmConfig.Provider,
27+
model: agent.LlmConfig?.Model ?? agentSetting.LlmConfig.Model);
2728

2829
var message = dialogs.Last();
2930
var response = chatCompletion.GetChatCompletions(agent, dialogs);

‎src/Plugins/BotSharp.Plugin.Twilio/BotSharp.Plugin.Twilio.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<PackageReference Include="StrongGrid" Version="0.102.0" />
1112
<PackageReference Include="Twilio.AspNet.Common" Version="8.0.2" />
1213
<PackageReference Include="Twilio.AspNet.Core" Version="8.0.2" />
1314
</ItemGroup>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using StrongGrid;
4+
5+
namespace BotSharp.Plugin.Twilio.Controllers;
6+
7+
[AllowAnonymous]
8+
public class TwilioEmailController : ControllerBase
9+
{
10+
private readonly TwilioSetting _settings;
11+
private readonly IServiceProvider _services;
12+
13+
public TwilioEmailController(TwilioSetting settings, IServiceProvider services)
14+
{
15+
_settings = settings;
16+
_services = services;
17+
}
18+
19+
[HttpPost("/twilio/email")]
20+
public async Task<IActionResult> IncomingEmail()
21+
{
22+
// https://docs.sendgrid.com/api-reference/settings-inbound-parse/create-a-parse-setting
23+
var parser = new WebhookParser();
24+
var inboundEmail = await parser.ParseInboundEmailWebhookAsync(Request.Body).ConfigureAwait(false);
25+
26+
// ... do something with the inbound email ...
27+
28+
return Ok();
29+
}
30+
}
31+
32+
public class SendGridWebhook
33+
{
34+
public string From { get; set; }
35+
public string To { get; set; }
36+
}

‎src/WebStarter/appsettings.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@
4949
"Agent": {
5050
"DataDir": "agents",
5151
"TemplateFormat": "liquid",
52-
"MaxRecursiveDepth": 3
52+
"MaxRecursiveDepth": 3,
53+
"LlmConfig": {
54+
"Provider": "azure-openai",
55+
"Model": "one"
56+
}
5357
},
5458

5559
"Conversation": {

‎src/WebStarter/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/agent.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"isPublic": true,
88
"llmConfig": {
99
"provider": "azure-openai",
10-
"model": "gpt-35-turbo"
10+
"model": "one"
1111
}
1212
}

0 commit comments

Comments
 (0)