from openai import AzureOpenAI, OpenAI

def outputGPT(api_endpoint, api_key, model, messages):
    try:
        client = AzureOpenAI(
            azure_endpoint = api_endpoint, 
            api_key=api_key,  
            api_version="2023-03-15-preview"
        )
        response = client.chat.completions.create(
        model=model, # model = "deployment_name".
        messages=messages
        )

        return response.choices[0].message.content
    except Exception as e:
        return str(e)

def outputMistrael(api_endpoint, api_key, messages):
    try:
        client = OpenAI(api_key=api_key,
                        base_url=api_endpoint)
        response = client.chat.completions.create(
        model='mistralai/Mixtral-8x7B-Instruct-v0.1',
        messages=messages
        )
        return response.choices[0].message.content
    except Exception as e:
        return str(e)

def outputGemini(model, messages):
    # try:
    response = model.generate(messages)
    predicted_answer = response[0].strip()
    # predicted_answer = predicted_answer.replace("'","")
    # predicted_answer = predicted_answer.replace(' ','')
    return predicted_answer
    # except Exception as e:
        # return str(e)
        
def outputClaude(model, messages):
    # try:
    response = model.generate(messages)
    predicted_answer = response[0].strip()
    # predicted_answer = predicted_answer.replace("'","")
    # predicted_answer = predicted_answer.replace(' ','')
    return predicted_answer
    # except Exception as e:
        # return str(e)

    