enchancements
This commit is contained in:
parent
833fffe722
commit
9d6f5dc22d
|
|
@ -124,6 +124,10 @@ public partial class RoutingService
|
|||
var msg = RoleDialogModel.From(message,
|
||||
role: AgentRole.Function,
|
||||
content: message.Content);
|
||||
// Preserve images produced by the tool (e.g. `browser_act screenshot`) so the next
|
||||
// LLM round in this turn can attach them to the tool message for a multimodal model.
|
||||
// They are not persisted (ConversationStorage ignores dialog.Files).
|
||||
msg.Files = message.Files;
|
||||
|
||||
dialogs.Add(msg);
|
||||
Context.AddDialogs([msg]);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public partial class RoutingService
|
|||
message.RichContent = clonedMessage.RichContent;
|
||||
message.Data = clonedMessage.Data;
|
||||
message.MessageLabel = clonedMessage.MessageLabel;
|
||||
// Tools may return images (e.g. a browser screenshot). Carry them back from the clone so
|
||||
// the function dialog handed to the LLM can include the tool-produced image content.
|
||||
message.Files = clonedMessage.Files;
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -524,7 +524,21 @@ public class ChatCompletionProvider : IChatCompletion
|
|||
|
||||
messages.Add(assistantToolMsg);
|
||||
|
||||
messages.Add(new ToolChatMessage(message.ToolCallId.IfNullOrEmptyAs(message.FunctionName), message.LlmContent));
|
||||
// A tool may produce images (e.g. `browser_act screenshot`): attach them to the tool
|
||||
// message so a multimodal model can SEE the tool output instead of only reading the
|
||||
// file name. Text-only models keep the plain text result. The gateway accepts image
|
||||
// parts on a `tool` message; these files are transient (never persisted in history).
|
||||
var toolContentParts = new List<ChatMessageContentPart>
|
||||
{
|
||||
ChatMessageContentPart.CreateTextPart(message.LlmContent)
|
||||
};
|
||||
if (allowMultiModal && !message.Files.IsNullOrEmpty())
|
||||
{
|
||||
CollectMessageContentParts(toolContentParts, message.Files, imageDetailLevel);
|
||||
}
|
||||
|
||||
messages.Add(new ToolChatMessage(
|
||||
message.ToolCallId.IfNullOrEmptyAs(message.FunctionName), toolContentParts));
|
||||
}
|
||||
else if (message.Role == AgentRole.User)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue