refine file selection prompt
This commit is contained in:
parent
a0a07bac2d
commit
980138edad
|
|
@ -1,9 +1,6 @@
|
|||
using Microsoft.AspNetCore.SignalR;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Unicode;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using JsonConvert = Newtonsoft.Json.JsonConvert;
|
||||
using JsonSerializerSettings = Newtonsoft.Json.JsonSerializerSettings;
|
||||
|
||||
namespace BotSharp.Plugin.ChatHub.Hooks;
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class HandleEmailRequestFn : IFunctionCallback
|
|||
{
|
||||
var promptFiles = files.Select((x, idx) =>
|
||||
{
|
||||
return $"id: {idx + 1}, file_name: {x.FileName}.{x.FileType}, author: {x.FileSource}, content_type: {x.ContentType}";
|
||||
return $"id: {idx + 1}, file_name: {x.FileName}.{x.FileType}, content_type: {x.ContentType}, author: {x.FileSource}";
|
||||
}).ToList();
|
||||
var prompt = db.GetAgentTemplate(BuiltInAgentId.UtilityAssistant, "select_attachment_prompt");
|
||||
prompt = render.Render(prompt, new Dictionary<string, object>
|
||||
|
|
@ -113,7 +113,8 @@ public class HandleEmailRequestFn : IFunctionCallback
|
|||
var provider = llmProviderService.GetProviders().FirstOrDefault(x => x == "openai");
|
||||
var model = llmProviderService.GetProviderModel(provider: provider, id: "gpt-4");
|
||||
var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model.Name);
|
||||
var response = await completion.GetChatCompletions(agent, dialogs);
|
||||
var latest = dialogs.LastOrDefault();
|
||||
var response = await completion.GetChatCompletions(agent, new List<RoleDialogModel> { latest });
|
||||
var content = response?.Content ?? string.Empty;
|
||||
var selecteds = JsonSerializer.Deserialize<LlmContextOut>(content);
|
||||
var fids = selecteds?.Selecteds ?? new List<int>();
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ Here is the JSON format to use:
|
|||
"selected_ids": a list of id selected from the [FILES] section
|
||||
}
|
||||
|
||||
Suppose there are 4 files:
|
||||
Suppose there are four files:
|
||||
|
||||
id: 1, file_name: example_file.jpg, author: user, content_type: image/jpeg
|
||||
id: 2, file_name: example_file.pdf, author: user, content_type: application/pdf
|
||||
id: 3, file_name: example_file.png, author: bot, content_type: image/png
|
||||
id: 4, file_name: example_file.png, author: bot, content_type: image/png
|
||||
id: 1, file_name: example_file.jpg, content_type: image/jpeg, author: user
|
||||
id: 2, file_name: example_file.pdf, content_type: application/pdf, author: user
|
||||
id: 3, file_name: example_file.png, content_type: image/png, author: bot
|
||||
id: 4, file_name: example_file.png, content_type: image/png, author: bot
|
||||
|
||||
=====
|
||||
Example 1:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
Please take a look at the images in the [IMAGES] section from the conversation and select ONLY one image based on the conversation with user.
|
||||
Your response must be an interger number.
|
||||
|
||||
** Ensure the output is only in JSON format without any additional text.
|
||||
** You may need to look at the image_name as a reference to find the correct image id.
|
||||
|
|
@ -10,7 +9,7 @@ Here is the JSON format to use:
|
|||
}
|
||||
|
||||
|
||||
Suppose there are three images:
|
||||
Suppose there are four images:
|
||||
|
||||
id: 1, image_name: example_image_a.png
|
||||
id: 2, image_name: example_image_b.png
|
||||
|
|
|
|||
Loading…
Reference in a new issue