refine instruction

This commit is contained in:
Jicheng Lu 2025-08-25 23:42:21 -05:00
parent 222e4f7c74
commit f452aad4f5

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;