Merge branch 'SciSharp:master' into master

This commit is contained in:
C. Oceania 2024-07-26 07:23:59 -05:00 committed by GitHub
commit 3aa151240c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 13 additions and 15 deletions

View file

@ -12,7 +12,7 @@ public partial class ConversationService : IConversationService
private readonly IConversationStorage _storage;
private readonly IConversationStateService _state;
private string _conversationId;
private const string AIAssistant = "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a";
private const string AIAssistant = BuiltInAgentId.AIAssistant;
public string ConversationId => _conversationId;

View file

@ -11,7 +11,7 @@ namespace BotSharp.Logger.Hooks
{
private readonly IServiceProvider _services;
private readonly IConversationStateService _states;
private const string AIAssistant = "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a";
private const string AIAssistant = BuiltInAgentId.AIAssistant;
public TranslationResponseHook(IServiceProvider services,
IConversationStateService states)

View file

@ -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;

View file

@ -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>();

View file

@ -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:

View file

@ -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

View file

@ -1,10 +1,11 @@
using BotSharp.Abstraction.Agents;
using BotSharp.Abstraction.Agents.Enums;
namespace BotSharp.Plugin.PizzaBot.Hooks;
public class PizzaBotAgentHook : AgentHookBase
{
public override string SelfId => "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a";
public override string SelfId => BuiltInAgentId.AIAssistant;
public PizzaBotAgentHook(IServiceProvider services, AgentSettings settings)
: base(services, settings)