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 Details

    • chatCompletion

      IChatMessage chatCompletion(List<IChatMessage> messages) throws IOException, InterruptedException
      Sends a list of chat messages to the AI model and retrieves the AI-generated response.
      Parameters:
      messages - the list of IChatMessage 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

      IChatMessage createMessage(Role role, String userPrompt)
      Creates a new chat message with the specified role and content. Roles, such as Role.USER or Role.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 a String.
      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

      void setMessageHistory(List<IChatMessage> messages)
      Updates the chat message history with the provided list of messages.
      Parameters:
      messages - the list of IChatMessage objects to save as the updated chat history.