AS AgentScopeAPI 手册 / API Reference

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
modelNameString模型名称(类型 `String`)。The model name.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:276–279

baseUrl

public Builder baseUrl(String baseUrl)

设置基类 URL。

Performs the base url operation.

参数Parameters
名称Name类型Type说明Description
baseUrlString基类 URL(类型 `String`)。The base url.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:281–284

stream

public Builder stream(boolean stream)

设置流。

Sets whether streaming should be enabled.

参数Parameters
名称Name类型Type说明Description
streamboolean流(类型 `boolean`)。The stream.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:290–293

defaultOptions

public Builder defaultOptions(OllamaOptions defaultOptions)

设置默认选项。

Performs the default options operation.

参数Parameters
名称Name类型Type说明Description
defaultOptionsOllamaOptions默认选项(类型 `OllamaOptions`)。The default options.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:295–298

formatter

public Builder formatter(Formatter<OllamaMessage, OllamaResponse, OllamaRequest> formatter)

设置格式化器。

Performs the formatter operation.

参数Parameters
名称Name类型Type说明Description
formatterFormatter<OllamaMessage, OllamaResponse, OllamaRequest>格式化器(类型 `Formatter`)。The formatter.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:300–304

httpTransport

public Builder httpTransport(HttpTransport httpTransport)

设置HTTP 传输层到使用。

Sets the HTTP transport to use.

参数Parameters
名称Name类型Type说明Description
httpTransportHttpTransportHTTP 传输层(类型 `HttpTransport`)。the HTTP transport (null for default from factory)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:327–330

proxy

public Builder proxy(ProxyConfig proxyConfig)

设置代理。

Sets the proxy configuration for HTTP traffic.

参数Parameters
名称Name类型Type说明Description
proxyConfigProxyConfig代理配置(类型 `ProxyConfig`)。the proxy configuration (see `ProxyConfig`)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:357–360

contextWindowSize

public Builder contextWindowSize(int contextWindowSize)

设置该配置项。

Performs the context window size operation.

参数Parameters
名称Name类型Type说明Description
contextWindowSizeint上下文 Window 大小(类型 `int`)。The context window size.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:362–365

build

public OllamaChatModel build()

构建并返回最终实例。

Creates and returns an instance.

返回Returns OllamaChatModel
返回OllamaChatModel。Returns Ollama chat model.
源码Source io/agentscope/extensions/model/ollama/OllamaChatModel.java:367–388
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.