Class OllamaMultiAgentFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse,OllamaRequest>
io.agentscope.extensions.model.ollama.formatter.OllamaMultiAgentFormatter
- All Implemented Interfaces:
io.agentscope.core.formatter.Formatter<OllamaMessage,OllamaResponse, OllamaRequest>
public class OllamaMultiAgentFormatter
extends io.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse,OllamaRequest>
Ollama formatter for multi-agent conversations.
Converts AgentScope Msg objects to Ollama DTO Message objects with multi-agent support.
Collapses multi-agent conversation into a single user message with history tags.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a OllamaMultiAgentFormatter with default conversation history prompt.OllamaMultiAgentFormatter(boolean promoteToolResultImages) OllamaMultiAgentFormatter(String conversationHistoryPrompt) Create a OllamaMultiAgentFormatter with custom conversation history prompt.OllamaMultiAgentFormatter(String conversationHistoryPrompt, boolean promoteToolResultImages) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyOptions(OllamaRequest request, io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) voidapplyOptions(OllamaRequest request, OllamaOptions options, OllamaOptions defaultOptions) Apply OllamaOptions to the request.voidapplyToolChoice(OllamaRequest request, io.agentscope.core.model.ToolChoice toolChoice) voidapplyTools(OllamaRequest request, List<io.agentscope.core.model.ToolSchema> tools) buildRequest(String model, List<OllamaMessage> messages, boolean stream, OllamaOptions options, OllamaOptions defaultOptions, List<io.agentscope.core.model.ToolSchema> tools, io.agentscope.core.model.ToolChoice toolChoice) Build a complete OllamaRequest for the API call.convertToolResultToString(List<io.agentscope.core.message.ContentBlock> blocks) Convert list of content blocks (usually from tool result) to string.protected List<OllamaMessage>io.agentscope.core.model.ChatResponseparseResponse(OllamaResponse result, Instant startTime) Methods inherited from class io.agentscope.core.formatter.AbstractBaseFormatter
doFormat, extractTextContent, extractTextContent, format, format, formatRoleLabel, getOptionOrDefault, hasMediaContent, saveBase64DataToTempFile, shouldBypassHistoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.formatter.Formatter
applyToolChoice, applyTools
-
Constructor Details
-
OllamaMultiAgentFormatter
public OllamaMultiAgentFormatter()Create a OllamaMultiAgentFormatter with default conversation history prompt. -
OllamaMultiAgentFormatter
Create a OllamaMultiAgentFormatter with custom conversation history prompt.- Parameters:
conversationHistoryPrompt- The prompt to prepend before conversation history
-
OllamaMultiAgentFormatter
public OllamaMultiAgentFormatter(boolean promoteToolResultImages) -
OllamaMultiAgentFormatter
-
-
Method Details
-
doFormat
- Specified by:
doFormatin classio.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse, OllamaRequest>
-
parseResponse
public io.agentscope.core.model.ChatResponse parseResponse(OllamaResponse result, Instant startTime) -
applyOptions
public void applyOptions(OllamaRequest request, io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) -
applyOptions
public void applyOptions(OllamaRequest request, OllamaOptions options, OllamaOptions defaultOptions) Apply OllamaOptions to the request.- Parameters:
request- The request to apply options tooptions- The runtime optionsdefaultOptions- The default options
-
applyTools
-
applyToolChoice
-
buildRequest
public OllamaRequest buildRequest(String model, List<OllamaMessage> messages, boolean stream, OllamaOptions options, OllamaOptions defaultOptions, List<io.agentscope.core.model.ToolSchema> tools, io.agentscope.core.model.ToolChoice toolChoice) Build a complete OllamaRequest for the API call.- Parameters:
model- Model namemessages- Formatted Ollama messagesstream- Whether to enable streamingoptions- Generation optionsdefaultOptions- Default generation optionstools- Tool schemastoolChoice- Tool choice configuration- Returns:
- Complete OllamaRequest ready for API call
-
convertToolResultToString
Convert list of content blocks (usually from tool result) to string.- Overrides:
convertToolResultToStringin classio.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse, OllamaRequest> - Parameters:
blocks- The list of content blocks to convert- Returns:
- The string representation of the content blocks
-