类 OllamaMultiAgentFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse,OllamaRequest>
io.agentscope.core.formatter.ollama.OllamaMultiAgentFormatter
- 所有已实现的接口:
Formatter<OllamaMessage,OllamaResponse, OllamaRequest>
public class OllamaMultiAgentFormatter
extends 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.
-
构造器概要
构造器构造器说明Create 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) -
方法概要
修饰符和类型方法说明voidapplyOptions(OllamaRequest request, GenerateOptions options, GenerateOptions defaultOptions) Apply generation options to provider-specific request parameters.voidapplyOptions(OllamaRequest request, OllamaOptions options, OllamaOptions defaultOptions) Apply OllamaOptions to the request.voidapplyToolChoice(OllamaRequest request, ToolChoice toolChoice) Apply tool choice configuration to provider-specific request parameters.voidapplyTools(OllamaRequest request, List<ToolSchema> tools) Apply tool schemas to provider-specific request parameters.buildRequest(String model, List<OllamaMessage> messages, boolean stream, OllamaOptions options, OllamaOptions defaultOptions, List<ToolSchema> tools, ToolChoice toolChoice) Build a complete OllamaRequest for the API call.convertToolResultToString(List<ContentBlock> blocks) Convert list of content blocks (usually from tool result) to string.protected List<OllamaMessage> parseResponse(OllamaResponse result, Instant startTime) Parse provider-specific response to AgentScope ChatResponse.从类继承的方法 io.agentscope.core.formatter.AbstractBaseFormatter
extractTextContent, extractTextContent, format, formatRoleLabel, getOptionOrDefault, hasMediaContent, saveBase64DataToTempFile, shouldBypassHistory从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.formatter.Formatter
applyToolChoice, applyTools
-
构造器详细资料
-
OllamaMultiAgentFormatter
public OllamaMultiAgentFormatter()Create a OllamaMultiAgentFormatter with default conversation history prompt. -
OllamaMultiAgentFormatter
Create a OllamaMultiAgentFormatter with custom conversation history prompt.- 参数:
conversationHistoryPrompt- The prompt to prepend before conversation history
-
OllamaMultiAgentFormatter
public OllamaMultiAgentFormatter(boolean promoteToolResultImages) -
OllamaMultiAgentFormatter
-
-
方法详细资料
-
doFormat
-
parseResponse
从接口复制的说明:FormatterParse provider-specific response to AgentScope ChatResponse.- 参数:
result- Provider-specific response objectstartTime- Request start time for calculating duration- 返回:
- AgentScope ChatResponse
-
applyOptions
public void applyOptions(OllamaRequest request, GenerateOptions options, GenerateOptions defaultOptions) 从接口复制的说明:FormatterApply generation options to provider-specific request parameters.- 参数:
request- Provider-specific request parameters builderoptions- Generation options to applydefaultOptions- Default options to use if options parameter is null
-
applyOptions
public void applyOptions(OllamaRequest request, OllamaOptions options, OllamaOptions defaultOptions) Apply OllamaOptions to the request.- 参数:
request- The request to apply options tooptions- The runtime optionsdefaultOptions- The default options
-
applyTools
从接口复制的说明:FormatterApply tool schemas to provider-specific request parameters.- 参数:
request- Provider-specific request parameters buildertools- List of tool schemas to apply (may be null or empty)
-
applyToolChoice
从接口复制的说明:FormatterApply tool choice configuration to provider-specific request parameters.This method controls how the model uses tools. The default implementation does nothing, allowing formatters to override for providers that support tool choice configuration.
- 参数:
request- Provider-specific request parameters buildertoolChoice- Tool choice configuration (null means provider default)
-
buildRequest
public OllamaRequest buildRequest(String model, List<OllamaMessage> messages, boolean stream, OllamaOptions options, OllamaOptions defaultOptions, List<ToolSchema> tools, ToolChoice toolChoice) Build a complete OllamaRequest for the API call.- 参数:
model- Model namemessages- Formatted Ollama messagesstream- Whether to enable streamingoptions- Generation optionsdefaultOptions- Default generation optionstools- Tool schemastoolChoice- Tool choice configuration- 返回:
- Complete OllamaRequest ready for API call
-
convertToolResultToString
Convert list of content blocks (usually from tool result) to string.- 覆盖:
convertToolResultToString在类中AbstractBaseFormatter<OllamaMessage,OllamaResponse, OllamaRequest> - 参数:
blocks- The list of content blocks to convert- 返回:
- The string representation of the content blocks
-