Открытый AI-вызов C# Azure в CreateChatCompletionAsync выдает ошибку 404: Ресурс не найден

Я вызываю конечную точку Azure OpenAI с помощью пакета openAI nuget и могу подключиться к нему, когда использую метод CreateCompletionAsync, но когда я использую метод CreateChatCompletionAsync для того же URL-адреса, я получаю сообщение об ошибке 404: Ресурс не найден.

В приведенном ниже методе кода 1 и метод 2 используют CreateCompletionAsync, который работает нормально, но не методы 3 и 4, которые используют CreatChatCompeletionAsync.

      using System;
using System.Threading.Tasks;
using OpenAI_API;
using OpenAI_API.Chat;
using OpenAI_API.Completions;
using OpenAI_API.Models;
using OpenAI_API.Moderation;

class Program
{
    static async Task Main(string[] args)
    {

        APIAuthentication aPIAuthentication = new APIAuthentication("my_key");

        //Initialize the OpenAI client for Azure
        var api = OpenAIAPI.ForAzure("chatgpt", "ddic", aPIAuthentication);

        //Method 1: this first call works to the same API end point
        var prompt = "If I could fly";
        var model = "ddic";
        var result = await api.Completions.CreateCompletionAsync(prompt,model);
         // Print the generated text to the console
        Console.WriteLine(result);


    //MEthod 2: this second call also works for the same epi endpoint
        var completionRequest = new CompletionRequest();       
        string[] multiPrompt = { "Hello World", "Once upon a time" };
        completionRequest.MultiplePrompts = multiPrompt;
        completionRequest.Model = model;
        completionRequest.user = ChatMessageRole.User;
        var result1 = await api.Completions.CreateCompletionAsync(completionRequest);    

        //Method 3: for the next two call I get the folowing error
        // (end_point) with HTTP status code: NotFound. Content: {"error":{"code":"404","message": "Resource not found"}}
        var response = await api.Chat.CreateChatCompletionAsync (new ChatRequest()
         {
             Model = "ddic",
             Temperature = 0.1,
             MaxTokens = 50,
              Messages = new ChatMessage[] {
                   new ChatMessage(ChatMessageRole.System, "you are an assistant that gives me information about products, including their cost."),
                   new ChatMessage(ChatMessageRole.User, "Tesla")
             }
        });

        IList<ChatMessage> messages = new List<ChatMessage>
        {
            new ChatMessage(ChatMessageRole.System, "you are an assistant that gives me information about products, including their cost."),
            new ChatMessage(ChatMessageRole.User, "Tesla")
        };

    //Method 4
        var response1 = await api.Chat.CreateChatCompletionAsync(messages, "ddic");
        var reply = response1.Choices[0].Message;
        Console.WriteLine($"{reply.Role}: {reply.Content.Trim()}");

        
    }
}

1 ответ

Создавайте дополнения для сообщений чата с помощью моделей ChatGPT (предварительная версия) и GPT-4 (предварительная версия). Завершения чата в настоящее время доступны только с помощью api-version=2023-03-15-preview.

Другие вопросы по тегам