Package eu.hobbydev.bracheus.manager
Klasse OpenAIManager
java.lang.Object
eu.hobbydev.bracheus.manager.OpenAIManager
The `OpenAIManager` class is responsible for interacting with the OpenAI API to generate responses
for messages or comments. It uses an OpenAI client to send input to the GPT model and get generated responses.
This class is designed to automatically generate answers to a list of messages, with specific rules for the response.
The class is initialized with an API key to authenticate with the OpenAI API. It contains methods for constructing
prompts from provided messages and receiving responses generated by the OpenAI language model.
The main functionality of this class is to take a list of messages (such as Instagram messages or comments)
and return a generated answer. The answer is formulated based on the context of the given messages, following specific instructions.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungOpenAIManager(String apiKey) Constructs an `OpenAIManager` instance with the specified API key. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibunganswerMessages(List<String> nachrichten) Generates a response for a list of given messages.com.openai.client.OpenAIClientGets the OpenAI client instance used for making requests to the OpenAI API.
-
Konstruktordetails
-
OpenAIManager
Constructs an `OpenAIManager` instance with the specified API key.- Parameter:
apiKey- the API key used to authenticate with the OpenAI API.- Löst aus:
IllegalArgumentException- if the API key is null or invalid.
-
-
Methodendetails
-
answerMessages
Generates a response for a list of given messages. This method formats the input messages into a string, following a specific structure that instructs the OpenAI model to generate a response without adding any extra text. The model will also follow the instruction that if asked for a name, the response should include the username".- Parameter:
nachrichten- a list of messages (e.g., comments or text) that need responses.- Gibt zurück:
- a string containing the response generated by the OpenAI model based on the input messages.
-
getOpenAIClient
public com.openai.client.OpenAIClient getOpenAIClient()Gets the OpenAI client instance used for making requests to the OpenAI API.- Gibt zurück:
- the `OpenAIClient` instance used for interacting with the OpenAI API.
-