from .base import BaseModel
from openai import OpenAI

class OpenAIModel(BaseModel):
    def __init__(self, model_name: str, api_key: str):
        super().__init__()
        self.model_name = model_name
        self.client = OpenAI(api_key=api_key)

    def get_response(self, input_data: str) -> str:
        """
        Gets a response from the OpenAI model.

        Args:
            input_data (str): The user's input message.

        Returns:
            str: The response generated by the model.
        """
        try:

            response = self.client.responses.create(
                model=self.model_name,
                messages=input_data
            )

            return response.output_text
        except Exception as e:
            return f"Error: {str(e)}"
