# Please install OpenAI SDK first: `pip3 install openai`

from openai import OpenAI


def getAiResponse(question):
    global response
    client = OpenAI(api_key="sk-8255b8195cb542c0acec623afffd40a5", base_url="https://api.deepseek.com")
    try:
        response = client.chat.completions.create(
            model="deepseek-chat",
            messages=[
                {"role": "system", "content": question},
                {"role": "user", "content": "Hello"},
            ],
            stream=False
        )
        print(response)
        if 'choices' in response and len(response.choices) > 0:
            print(response.choices[0].message.content)
            return response.choices[0].message.content
        else:
            return ''
    except Exception as e:
        print(f"Error: {e}")
        return ''
    finally:
        if client:
            client.close()
