Class OllamaChatFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse,OllamaRequest>
io.agentscope.extensions.model.ollama.formatter.OllamaChatFormatter
- All Implemented Interfaces:
io.agentscope.core.formatter.Formatter<OllamaMessage,OllamaResponse, OllamaRequest>
public class OllamaChatFormatter
extends io.agentscope.core.formatter.AbstractBaseFormatter<OllamaMessage,OllamaResponse,OllamaRequest>
Formatter for Ollama Chat API.
Converts between AgentScope Msg objects and Ollama DTO types.
-
Constructor Summary
Constructors -
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.protected List<OllamaMessage>io.agentscope.core.model.ChatResponseparseResponse(OllamaResponse result, Instant startTime) Methods inherited from class io.agentscope.core.formatter.AbstractBaseFormatter
convertToolResultToString, 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
-
OllamaChatFormatter
public OllamaChatFormatter() -
OllamaChatFormatter
public OllamaChatFormatter(boolean promoteToolResultImages)
-
-
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
-