java.lang.Object
de.seggebaeing.sqlanalyzer.logic.promptable.impl.llm.AbstractLLMHandler
de.seggebaeing.sqlanalyzer.logic.promptable.impl.llm.OpenAIPromptHandler
All Implemented Interfaces:
Promptable

public class OpenAIPromptHandler extends AbstractLLMHandler
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.

  • Constructor Details

    • OpenAIPromptHandler

      public OpenAIPromptHandler()
      Constructs a new OpenAIPromptHandler, 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 model
      model - the OpenAI model identifier (e.g., "gpt-4o-mini")
      apiKey - the API key used for authentication
      temperature - 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