Class OllamaClient
java.lang.Object
com.developer.nefarious.zjoule.plugin.chat.ollama.OllamaClient
- All Implemented Interfaces:
IAIClient
-
Constructor Summary
ConstructorDescriptionOllamaClient
(IMemoryMessageHistory memoryMessageHistory, IMemoryObject<String> memoryOllamaEndpoint, IOllamaClientHelper ollamaClientHelper) -
Method Summary
Modifier and TypeMethodDescriptionchatCompletion
(List<IChatMessage> messages) Sends a list of chat messages to the AI model and retrieves the AI-generated response.createMessage
(Role role, String userPrompt) Creates a new chat message with the specified role and content.Retrieves the chat message history.void
setMessageHistory
(List<IChatMessage> chatMessages) Updates the chat message history with the provided list of messages.
-
Constructor Details
-
OllamaClient
public OllamaClient(IMemoryMessageHistory memoryMessageHistory, IMemoryObject<String> memoryOllamaEndpoint, IOllamaClientHelper ollamaClientHelper)
-
-
Method Details
-
chatCompletion
public IChatMessage chatCompletion(List<IChatMessage> messages) throws IOException, InterruptedException Description copied from interface:IAIClient
Sends a list of chat messages to the AI model and retrieves the AI-generated response.- Specified by:
chatCompletion
in interfaceIAIClient
- Parameters:
messages
- the list ofIChatMessage
objects representing the chat history and the user's current prompt.- Returns:
- the AI-generated response as an
IChatMessage
. - Throws:
IOException
- if an I/O error occurs during the request.InterruptedException
- if the operation is interrupted.
-
createMessage
Description copied from interface:IAIClient
Creates a new chat message with the specified role and content. Roles, such asRole.USER
orRole.SYSTEM
, determine the context of the message within the chat.- Specified by:
createMessage
in interfaceIAIClient
- Parameters:
role
- the role of the message (e.g., user, system, assistant).userPrompt
- the content of the message as aString
.- Returns:
- a newly created
IChatMessage
.
-
getMessageHistory
Description copied from interface:IAIClient
Retrieves the chat message history. This method returns a list of previously exchanged messages that are stored in memory.- Specified by:
getMessageHistory
in interfaceIAIClient
- Returns:
- a list of
IChatMessage
objects representing the chat history.
-
setMessageHistory
Description copied from interface:IAIClient
Updates the chat message history with the provided list of messages.- Specified by:
setMessageHistory
in interfaceIAIClient
- Parameters:
chatMessages
- the list ofIChatMessage
objects to save as the updated chat history.
-