Interface IAIClient
- All Known Implementing Classes:
OpenAIClient
public interface IAIClient
Interface for AI client implementations.
Defines methods for interacting with AI models, managing chat messages,
and facilitating chat completion requests.
Implementations, such as
OpenAIClient
, handle communication with specific AI platforms
by utilizing authentication, message history, and model-specific configurations.-
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> messages) Updates the chat message history with the provided list of messages.
-
Method Details
-
chatCompletion
Sends a list of chat messages to the AI model and retrieves the AI-generated response.- 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
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.- 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
List<IChatMessage> getMessageHistory()Retrieves the chat message history. This method returns a list of previously exchanged messages that are stored in memory.- Returns:
- a list of
IChatMessage
objects representing the chat history.
-
setMessageHistory
Updates the chat message history with the provided list of messages.- Parameters:
messages
- the list ofIChatMessage
objects to save as the updated chat history.
-