Package org.springframework.ai.ollama
Class OllamaChatModel
java.lang.Object
org.springframework.ai.chat.model.AbstractToolCallSupport
org.springframework.ai.ollama.OllamaChatModel
- All Implemented Interfaces:
ChatModel
,StreamingChatModel
,Model<Prompt,
,ChatResponse> StreamingModel<Prompt,
ChatResponse>
ChatModel
implementation for Ollama. Ollama allows developers to run
large language models and generate embeddings locally. It supports open-source models
available on [Ollama AI Library](...). - Llama
2 (7B parameters, 3.8GB size) - Mistral (7B parameters, 4.1GB size) Please refer to the
official Ollama website for the most up-to-date
information on available models.- Since:
- 1.0.0
- Author:
- Christian Tzolov, luocongqiu, Thomas Vitale
-
Field Summary
Fields inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
functionCallbackContext, functionCallbackRegister, IS_RUNTIME_CALL
-
Constructor Summary
ConstructorDescriptionOllamaChatModel
(OllamaApi ollamaApi) OllamaChatModel
(OllamaApi ollamaApi, OllamaOptions defaultOptions) OllamaChatModel
(OllamaApi ollamaApi, OllamaOptions defaultOptions, FunctionCallbackContext functionCallbackContext) OllamaChatModel
(OllamaApi ollamaApi, OllamaOptions defaultOptions, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks) OllamaChatModel
(OllamaApi chatApi, OllamaOptions defaultOptions, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks, io.micrometer.observation.ObservationRegistry observationRegistry) -
Method Summary
Modifier and TypeMethodDescriptionExecutes a method call to the AI model.static ChatResponseMetadata
from
(OllamaApi.ChatResponse response) void
setObservationConvention
(ChatModelObservationConvention observationConvention) Use the provided convention for reporting observation datareactor.core.publisher.Flux<ChatResponse>
Executes a method call to the AI model.Methods inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
buildToolCallConversation, executeFunctions, getFunctionCallbackRegister, handleToolCalls, isProxyToolCalls, isToolCall, isToolCall, resolveFunctionCallbacks, runtimeFunctionCallbackConfigurations
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.chat.model.StreamingChatModel
stream, stream
-
Constructor Details
-
OllamaChatModel
-
OllamaChatModel
-
OllamaChatModel
public OllamaChatModel(OllamaApi ollamaApi, OllamaOptions defaultOptions, FunctionCallbackContext functionCallbackContext) -
OllamaChatModel
public OllamaChatModel(OllamaApi ollamaApi, OllamaOptions defaultOptions, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks) -
OllamaChatModel
public OllamaChatModel(OllamaApi chatApi, OllamaOptions defaultOptions, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks, io.micrometer.observation.ObservationRegistry observationRegistry)
-
-
Method Details
-
call
Description copied from interface:Model
Executes a method call to the AI model. -
from
-
stream
Description copied from interface:StreamingModel
Executes a method call to the AI model.- Specified by:
stream
in interfaceChatModel
- Specified by:
stream
in interfaceStreamingChatModel
- Specified by:
stream
in interfaceStreamingModel<Prompt,
ChatResponse> - Parameters:
prompt
- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
getDefaultOptions
- Specified by:
getDefaultOptions
in interfaceChatModel
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention
- The provided convention
-