类 OllamaHttpClient
java.lang.Object
io.agentscope.core.model.OllamaHttpClient
HTTP client for Ollama API.
This client handles communication with Ollama's chat and embedding APIs. It provides both synchronous and asynchronous (streaming) request capabilities with proper JSON serialization/deserialization and error handling.
Features:
- Synchronous and streaming request support
- NDJSON stream parsing for streaming responses
- Automatic JSON serialization/deserialization with snake_case naming
- Proper error handling with detailed exception information
- Configurable base URL and HTTP transport
Default base URL is http://localhost:11434, which is the standard Ollama server address.
-
嵌套类概要
嵌套类修饰符和类型类说明static classBuilder for OllamaHttpClient.static classException thrown when Ollama HTTP operations fail. -
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static OllamaHttpClient.Builderbuilder()Create a new builder for OllamaHttpClient.Make a synchronous API call to specific endpoint.<T> TMake a synchronous API call to specific endpoint with custom response type.chat(OllamaRequest request) Make a synchronous Chat API call.voidclose()Close the transport.embed(OllamaEmbeddingRequest request) Make a synchronous Embed API call.Get the base URL.reactor.core.publisher.Flux<OllamaResponse> stream(OllamaRequest request) Make a streaming Chat API call.
-
字段详细资料
-
DEFAULT_BASE_URL
Default base URL for Ollama API.- 另请参阅:
-
CHAT_ENDPOINT
Chat API endpoint.- 另请参阅:
-
EMBED_ENDPOINT
Embed API endpoint.- 另请参阅:
-
-
构造器详细资料
-
OllamaHttpClient
Create a new OllamaHttpClient.- 参数:
transport- the HTTP transport to usebaseUrl- the base URL (null for default)
-
-
方法详细资料
-
chat
Make a synchronous Chat API call.- 参数:
request- the Ollama request- 返回:
- the Ollama response
-
embed
Make a synchronous Embed API call.- 参数:
request- the Embed request- 返回:
- the Embed response
-
call
Make a synchronous API call to specific endpoint.- 参数:
endpoint- the API endpointrequest- the request object- 返回:
- the Ollama response
-
call
Make a synchronous API call to specific endpoint with custom response type.- 类型参数:
T- the response type- 参数:
endpoint- the API endpointrequest- the request objectresponseType- the response class- 返回:
- the response object
-
stream
Make a streaming Chat API call.- 参数:
request- the Ollama request- 返回:
- a Flux of Ollama responses
-
getBaseUrl
Get the base URL.- 返回:
- the base URL
-
close
public void close()Close the transport. -
builder
Create a new builder for OllamaHttpClient.- 返回:
- a new Builder instance
-