Merge pull request #1138 from iceljc/master

refine instruction
This commit is contained in:
iceljc 2025-08-25 23:51:13 -05:00 committed by GitHub
commit 5d875d075e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,3 @@
using BotSharp.Abstraction.Hooks;
using BotSharp.Abstraction.Instructs;
using BotSharp.Abstraction.Instructs.Models;
using BotSharp.Abstraction.MLTasks;
@ -13,6 +12,15 @@ public partial class InstructService
var agentService = _services.GetRequiredService<IAgentService>();
Agent agent = await agentService.LoadAgent(agentId);
if (agent == null)
{
return new InstructResult
{
MessageId = message.MessageId,
Text = $"Agent (id: {agentId}) does not exist!"
};
}
if (agent.Disabled)
{
var content = $"This agent ({agent.Name}) is disabled, please install the corresponding plugin ({agent.Plugin.Name}) to activate this agent.";
@ -55,6 +63,7 @@ public partial class InstructService
{
MessageId = message.MessageId
};
if (completer is ITextCompletion textCompleter)
{
instruction = null;
@ -86,7 +95,7 @@ public partial class InstructService
{
CurrentAgentId = agentId,
MessageId = message.MessageId,
Files = files?.Select(x => new BotSharpFile { FileUrl = x.FileUrl, FileData = x.FileData }).ToList() ?? []
Files = files?.Select(x => new BotSharpFile { FileUrl = x.FileUrl, FileData = x.FileData, ContentType = x.ContentType }).ToList() ?? []
}
});
response.Text = result.Content;