refine summary prompt

This commit is contained in:
Jicheng Lu 2024-05-27 12:12:39 -05:00
parent b8becca945
commit a5dad4dee4
2 changed files with 29 additions and 8 deletions

View file

@ -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<string> Summarize(Agent agent, string prompt, List<RoleDialogModel> 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<ILlmProviderService>();
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<AgentSettings>();
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<AgentSettings>();
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,

View file

@ -1 +1,8 @@
Please summarize the conversation.
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'.