类 OllamaChatFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse,OllamaRequest>
io.agentscope.core.formatter.ollama.OllamaChatFormatter
- 所有已实现的接口:
Formatter<OllamaMessage,OllamaResponse, OllamaRequest>
public class OllamaChatFormatter
extends AbstractBaseFormatter<OllamaMessage,OllamaResponse,OllamaRequest>
Formatter for Ollama Chat API.
Converts between AgentScope Msg objects and Ollama DTO types.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明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.protected List<OllamaMessage> parseResponse(OllamaResponse result, Instant startTime) Parse provider-specific response to AgentScope ChatResponse.从类继承的方法 io.agentscope.core.formatter.AbstractBaseFormatter
convertToolResultToString, 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
-
构造器详细资料
-
OllamaChatFormatter
public OllamaChatFormatter() -
OllamaChatFormatter
public OllamaChatFormatter(boolean promoteToolResultImages)
-
-
方法详细资料
-
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
-