Set default LlmConfig for Agent level.

This commit is contained in:
Haiping Chen 2023-12-13 17:16:34 -06:00
parent 1e89ea0c6a
commit 89af1d72a6
6 changed files with 52 additions and 4 deletions

View file

@ -4,4 +4,10 @@ public class AgentSettings
{
public string DataDir { get; set; } = string.Empty;
public string TemplateFormat { get; set; } = "liquid";
/// <summary>
/// This is the default LLM config for agent
/// </summary>
public AgentLlmConfig LlmConfig { get; set; }
= new AgentLlmConfig();
}

View file

@ -19,11 +19,12 @@ public partial class RoutingService
}
var agentService = _services.GetRequiredService<IAgentService>();
var agentSetting = _services.GetRequiredService<AgentSettings>();
var agent = await agentService.LoadAgent(agentId);
var chatCompletion = CompletionProvider.GetChatCompletion(_services,
provider: agent?.LlmConfig?.Provider,
model: agent.LlmConfig?.Model);
provider: agent?.LlmConfig?.Provider ?? agentSetting.LlmConfig.Provider,
model: agent.LlmConfig?.Model ?? agentSetting.LlmConfig.Model);
var message = dialogs.Last();
var response = chatCompletion.GetChatCompletions(agent, dialogs);

View file

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StrongGrid" Version="0.102.0" />
<PackageReference Include="Twilio.AspNet.Common" Version="8.0.2" />
<PackageReference Include="Twilio.AspNet.Core" Version="8.0.2" />
</ItemGroup>

View file

@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using StrongGrid;
namespace BotSharp.Plugin.Twilio.Controllers;
[AllowAnonymous]
public class TwilioEmailController : ControllerBase
{
private readonly TwilioSetting _settings;
private readonly IServiceProvider _services;
public TwilioEmailController(TwilioSetting settings, IServiceProvider services)
{
_settings = settings;
_services = services;
}
[HttpPost("/twilio/email")]
public async Task<IActionResult> IncomingEmail()
{
// https://docs.sendgrid.com/api-reference/settings-inbound-parse/create-a-parse-setting
var parser = new WebhookParser();
var inboundEmail = await parser.ParseInboundEmailWebhookAsync(Request.Body).ConfigureAwait(false);
// ... do something with the inbound email ...
return Ok();
}
}
public class SendGridWebhook
{
public string From { get; set; }
public string To { get; set; }
}

View file

@ -49,7 +49,11 @@
"Agent": {
"DataDir": "agents",
"TemplateFormat": "liquid",
"MaxRecursiveDepth": 3
"MaxRecursiveDepth": 3,
"LlmConfig": {
"Provider": "azure-openai",
"Model": "one"
}
},
"Conversation": {

View file

@ -7,6 +7,6 @@
"isPublic": true,
"llmConfig": {
"provider": "azure-openai",
"model": "gpt-35-turbo"
"model": "one"
}
}