From f452aad4f5d03a3b5b81b4746beee8ccb4880088 Mon Sep 17 00:00:00 2001 From: Jicheng Lu Date: Mon, 25 Aug 2025 23:42:21 -0500 Subject: [PATCH] refine instruction --- .../Instructs/Services/InstructService.Execute.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs index c1b16ee51..9ebbd8074 100644 --- a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs +++ b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs @@ -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 async Task Execute(string agentId, RoleDialogModel messag var agentService = _services.GetRequiredService(); 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 async Task Execute(string agentId, RoleDialogModel messag { MessageId = message.MessageId }; + if (completer is ITextCompletion textCompleter) { instruction = null; @@ -86,7 +95,7 @@ public async Task Execute(string agentId, RoleDialogModel messag { 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;