assembly version mismatch when using OpenAIClient

21 Views Asked by At

Im trying to get response from openAI by sending prompt in class library, I have downloaded azure.AI.OpenAI package then Im unable to create client but same code is working fine when Im using winforms project template without any error

here is the code:

private async void button1_Click(object sender, EventArgs e)
{

    OpenAIClient client = new OpenAIClient(new Uri("my uri"), new AzureKeyCredential("my key"));

    var chatCompletionsOptions = new ChatCompletionsOptions()
    {
        DeploymentName = "my deployment name", //This must match the custom deployment name you chose for your model
        Messages =
        {
            new ChatRequestSystemMessage("You are a helpful assistant."),
            new ChatRequestUserMessage("please translate 'BUILDING FINAL DETAILS TO BE CONFIRMED BY A SUPPLIER IN THE NEXT PROJECT PHASE.' to spanish."),
            new ChatRequestAssistantMessage(""),
        },
        MaxTokens = 100
    };

    Response<ChatCompletions> response = client.GetChatCompletions(chatCompletionsOptions);

    Console.WriteLine(response.Value.Choices[0].Message.Content.Split('"')[1]);

    Console.WriteLine();

}

tried all versions of azure.ai,.openai

0

There are 0 best solutions below