Builder
public static class Builder
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:266–424构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.model.ollama 包。核心成员包括 modelName、baseUrl、stream、defaultOptions、formatter、httpTransport。
A class in io.agentscope.extensions.model.ollama that talks to model services and returns generated or embedded output. Declared in io.agentscope.extensions.model.ollama.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Builder modelName(String modelName) | 设置模型名称。 Performs the model name operation. |
public Builder baseUrl(String baseUrl) | 设置基类 URL。 Performs the base url operation. |
public Builder stream(boolean stream) | 设置流。 Sets whether streaming should be enabled. |
public Builder defaultOptions(OllamaOptions defaultOptions) | 设置默认选项。 Performs the default options operation. |
public Builder formatter(Formatter<OllamaMessage, OllamaResponse, OllamaRequest> formatter) | 设置格式化器。 Performs the formatter operation. |
public Builder httpTransport(HttpTransport httpTransport) | 设置HTTP 传输层到使用。 Sets the HTTP transport to use. |
public Builder proxy(ProxyConfig proxyConfig) | 设置代理。 Sets the proxy configuration for HTTP traffic. |
public Builder contextWindowSize(int contextWindowSize) | 设置该配置项。 Performs the context window size operation. |
public OllamaChatModel build() | 构建并返回最终实例。 Creates and returns an instance. |
方法详情Method Detail
modelName
public Builder modelName(String modelName)
设置模型名称。
Performs the model name operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelName | String | 模型名称(类型 `String`)。The model name. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:276–279baseUrl
public Builder baseUrl(String baseUrl)
设置基类 URL。
Performs the base url operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:281–284stream
public Builder stream(boolean stream)
设置流。
Sets whether streaming should be enabled.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
stream | boolean | 流(类型 `boolean`)。The stream. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:290–293defaultOptions
public Builder defaultOptions(OllamaOptions defaultOptions)
设置默认选项。
Performs the default options operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
defaultOptions | OllamaOptions | 默认选项(类型 `OllamaOptions`)。The default options. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:295–298formatter
public Builder formatter(Formatter<OllamaMessage, OllamaResponse, OllamaRequest> formatter)
设置格式化器。
Performs the formatter operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
formatter | Formatter<OllamaMessage, OllamaResponse, OllamaRequest> | 格式化器(类型 `Formatter`)。The formatter. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:300–304httpTransport
public Builder httpTransport(HttpTransport httpTransport)
设置HTTP 传输层到使用。
Sets the HTTP transport to use.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
httpTransport | HttpTransport | HTTP 传输层(类型 `HttpTransport`)。the HTTP transport (null for default from factory) |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:327–330proxy
public Builder proxy(ProxyConfig proxyConfig)
设置代理。
Sets the proxy configuration for HTTP traffic.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
proxyConfig | ProxyConfig | 代理配置(类型 `ProxyConfig`)。the proxy configuration (see `ProxyConfig`) |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:357–360contextWindowSize
public Builder contextWindowSize(int contextWindowSize)
设置该配置项。
Performs the context window size operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
contextWindowSize | int | 上下文 Window 大小(类型 `int`)。The context window size. |
Builder返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:362–365build
public OllamaChatModel build()
构建并返回最终实例。
Creates and returns an instance.
OllamaChatModel返回OllamaChatModel。Returns Ollama chat model.
源码Source
io/agentscope/extensions/model/ollama/OllamaChatModel.java:367–388