类 OllamaChatModel
java.lang.Object
io.agentscope.core.model.ChatModelBase
io.agentscope.core.model.OllamaChatModel
- 所有已实现的接口:
Model
AgentScope ChatModel implementation for Ollama.
Provides integration with local Ollama instances via HTTP API.
This class implements the AgentScope ChatModelBase interface for Ollama models,
supporting both synchronous and streaming chat operations, tool usage, and custom Ollama options.
Key features:
- Support for both
GenerateOptionsand Ollama-specificOllamaOptions - Integration with AgentScope's message formatting system
- Streaming response support via Project Reactor's Flux
- Tool usage and function calling capabilities
- Configurable message formatters (OllamaChatFormatter, OllamaMultiAgentFormatter)
- Automatic timeout and retry mechanisms
-
嵌套类概要
嵌套类 -
构造器概要
构造器构造器说明OllamaChatModel(String modelName, String baseUrl, OllamaOptions defaultOptions) Creates a new OllamaChatModel with default settings.OllamaChatModel(String modelName, String baseUrl, OllamaOptions defaultOptions, Formatter<OllamaMessage, OllamaResponse, OllamaRequest> formatter, HttpTransport httpTransport) Creates a new OllamaChatModel. -
方法概要
修饰符和类型方法说明static OllamaChatModel.Builderbuilder()Creates a new builder for OllamaChatModel.chat(List<Msg> messages, GenerateOptions options) Chat with the model using default options.chat(List<Msg> messages, OllamaOptions options) Chat with the model using Ollama-specific options.protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Internal implementation for streaming chat completion responses.Get model name for logging and identification.从类继承的方法 io.agentscope.core.model.ChatModelBase
stream
-
构造器详细资料
-
OllamaChatModel
public OllamaChatModel(String modelName, String baseUrl, OllamaOptions defaultOptions, Formatter<OllamaMessage, OllamaResponse, OllamaRequest> formatter, HttpTransport httpTransport) Creates a new OllamaChatModel.- 参数:
modelName- The name of the model to use (e.g., "llama2", "mistral").baseUrl- The base URL of the Ollama server (e.g., "http://localhost:11434").defaultOptions- Default configuration options.formatter- The message formatter to use.httpTransport- The HTTP transport to use.
-
OllamaChatModel
Creates a new OllamaChatModel with default settings.- 参数:
modelName- The name of the model to use.baseUrl- The base URL of the Ollama server.defaultOptions- Default configuration options.
-
-
方法详细资料
-
builder
Creates a new builder for OllamaChatModel.- 返回:
- A new Builder instance.
-
getModelName
从接口复制的说明:ModelGet model name for logging and identification.- 返回:
- model name
-
chat
Chat with the model using Ollama-specific options.This method uses Ollama-specific options directly without conversion.
- 参数:
messages- The messages to send.options- The Ollama-specific options.- 返回:
- The chat response.
-
chat
Chat with the model using default options.- 参数:
messages- The messages to send.options- The generation options.- 返回:
- The chat response.
-
doStream
protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) 从类复制的说明:ChatModelBaseInternal implementation for streaming chat completion responses. Subclasses must implement their specific logic here.- 指定者:
doStream在类中ChatModelBase- 参数:
messages- AgentScope messages to send to the modeltools- Optional list of tool schemas (null or empty if no tools)options- Optional generation options (null to use defaults)- 返回:
- Flux stream of chat responses
-