Interface AIChatBuilder
- All Known Implementing Classes:
OpenAIChatBuilderImpl
public interface AIChatBuilder
Defines the interface for building AI chat interactions, allowing customization of the model, token limits, and messages.
-
Method Summary
Modifier and TypeMethodDescriptionassistantMsg(String text) Adds an assistant message to the chat.execute()Executes the chat completion request and returns the response.Sets the API key for the chat completion request.maxTokens(int maxTokens) Sets the maximum number of tokens the completion can use.Sets the AI model to be used for the chat completion.Adds a system message to the chat.toJson()Converts the chat completion request to a JSON string.Sets the URL for the chat completion request.Adds a user message to the chat.
-
Method Details
-
url
Sets the URL for the chat completion request.- Parameters:
url- The URL.- Returns:
- The builder instance for chaining.
-
key
Sets the API key for the chat completion request.- Parameters:
key- The API key.- Returns:
- The builder instance for chaining.
-
maxTokens
Sets the maximum number of tokens the completion can use.- Parameters:
maxTokens- The maximum number of tokens.- Returns:
- The builder instance for chaining.
-
model
Sets the AI model to be used for the chat completion.- Parameters:
model- The model name.- Returns:
- The builder instance for chaining.
-
systemMsg
Adds a system message to the chat.- Parameters:
text- The text of the message.- Returns:
- The builder instance for chaining.
-
userMsg
Adds a user message to the chat.- Parameters:
text- The text of the message.- Returns:
- The builder instance for chaining.
-
assistantMsg
Adds an assistant message to the chat.- Parameters:
text- The text of the message.- Returns:
- The builder instance for chaining.
-
toJson
String toJson()Converts the chat completion request to a JSON string.- Returns:
- The JSON string.
-
execute
String execute()Executes the chat completion request and returns the response.- Returns:
- The chat completion response.
-