Merge pull request #503 from iceljc/bugfix/add-system-prompt

append image analysis prompt
This commit is contained in:
C. Oceania 2024-06-18 13:48:49 -05:00 committed by GitHub
commit 1b89a267ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,3 +1,4 @@
namespace BotSharp.Core.Files.Hooks;
public class AttachmentProcessingHook : AgentHookBase
@ -14,6 +15,20 @@ public class AttachmentProcessingHook : AgentHookBase
_agentSettings = settings;
}
public override void OnAgentLoaded(Agent agent)
{
var fileService = _services.GetRequiredService<IBotSharpFileService>();
var conv = _services.GetRequiredService<IConversationService>();
var hasConvFiles = fileService.HasConversationUserFiles(conv.ConversationId);
if (hasConvFiles)
{
agent.Instruction += "\r\n\r\nIf user wants to describe images or pdf files, please call load_attachment.";
}
base.OnAgentLoaded(agent);
}
public override bool OnFunctionsLoaded(List<FunctionDef> functions)
{
var fileService = _services.GetRequiredService<IBotSharpFileService>();