import openai

class Nika:
    def __init__(self, api_key: str, model: str = "gpt-4-o"):
        self.api_key = api_key
        self.model = model
        openai.api_key = self.api_key

    def generate_response(self, prompt: str) -> str:
        try:
            response = openai.ChatCompletion.create(
                model=self.model,
                messages=[
                    {"role": "system", "content": "You are a helpful assistant."},
                    {"role": "user", "content": prompt}
                ]
            )
            return response['choices'][0]['message']['content'].strip()
        except Exception as e:
            return f"An error occurred: {str(e)}"


