diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs index 4a547204..25d754d6 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs @@ -1,3 +1,4 @@ +using BotSharp.Abstraction.MLTasks; using BotSharp.Abstraction.Templating; namespace BotSharp.Core.Conversations.Services; @@ -30,17 +31,30 @@ public partial class ConversationService private async Task Summarize(Agent agent, string prompt, List dialogs) { - var provider = agent?.LlmConfig?.Provider; - var model = agent?.LlmConfig?.Model; + var provider = "openai"; + string? model; - if (provider == null || model == null) + var providerService = _services.GetRequiredService(); + var modelSettings = providerService.GetProviderModels(provider); + var modelSetting = modelSettings.FirstOrDefault(x => x.Name.IsEqualTo("gpt4-turbo") || x.Name.IsEqualTo("gpt-4o")); + + if (modelSetting != null) { - var agentSettings = _services.GetRequiredService(); - provider = agentSettings.LlmConfig.Provider; - model = agentSettings.LlmConfig.Model; + model = modelSetting.Name; + } + else + { + provider = agent?.LlmConfig?.Provider; + model = agent?.LlmConfig?.Model; + if (provider == null || model == null) + { + var agentSettings = _services.GetRequiredService(); + provider = agentSettings.LlmConfig.Provider; + model = agentSettings.LlmConfig.Model; + } } - var chatCompletion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model); + var chatCompletion = CompletionProvider.GetChatCompletion(_services, provider, model); var response = await chatCompletion.GetChatCompletions(new Agent { Id = agent.Id, diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/conversation.summary.liquid b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/conversation.summary.liquid index a935e497..08792af3 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/conversation.summary.liquid +++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/conversation.summary.liquid @@ -1 +1,8 @@ -Please summarize the conversation. \ No newline at end of file +Please summarize the conversation. + +*** Super Important! Please consider the entire conversation. Do not only consider the recent sentences. *** +** Please do not respond to the latest conversation. +** If there are different topics in the conversation, please summarize each topic in different sentences and list them in bullets. +* Please use concise sentences to summarize each topic. +* Please do not include excessive details in the summaries. +* Please use 'user' instead of 'you', 'he' or 'she'. \ No newline at end of file