Module de.seggebaeing.sqlanalyzer
Class OpenAIPromptHandler
java.lang.Object
de.seggebaeing.sqlanalyzer.logic.promptable.impl.llm.AbstractLLMHandler
de.seggebaeing.sqlanalyzer.logic.promptable.impl.llm.OpenAIPromptHandler
- All Implemented Interfaces:
Promptable
Handler for interacting with the OpenAI Chat Completions API.
This class builds and sends requests to the OpenAI endpoint using the provided API key, model, and prompt data. It parses responses to extract the generated message text and handles rate-limiting or error responses.
-
Field Summary
Fields inherited from class de.seggebaeing.sqlanalyzer.logic.promptable.impl.llm.AbstractLLMHandler
client, gson
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newOpenAIPromptHandler
, initializing the underlying HTTP client and JSON parser via the superclass. -
Method Summary
-
Constructor Details
-
OpenAIPromptHandler
public OpenAIPromptHandler()Constructs a newOpenAIPromptHandler
, initializing the underlying HTTP client and JSON parser via the superclass.
-
-
Method Details
-
prompt
public String prompt(String input, String model, String apiKey, double temperature) throws LLMException Sends the given input prompt to the OpenAI Chat Completions API and returns the generated response content.- Parameters:
input
- the user input text to be sent to the modelmodel
- the OpenAI model identifier (e.g., "gpt-4o-mini")apiKey
- the API key used for authenticationtemperature
- the sampling temperature controlling randomness- Returns:
- the generated response text from the model
- Throws:
LLMException
- if the API call fails, returns an error, or the response cannot be parsed
-