CreateChatCompletion error
var chat = await api.Chat.CreateChatCompletionAsync(new ChatRequest() { Model = Model.AdaText, Temperature = 0.1, MaxTokens = 1100, Messages = new ChatMessage[] { new ChatMessage(ChatMessageRole.System, _configuration.GetSection("OpenAi")["rules"]), new ChatMessage(ChatMessageRole.User, "Generate Character"), new ChatMessage(ChatMessageRole.Assistant, expectedResponse1), new ChatMessage(ChatMessageRole.User, "Generate Character"), new ChatMessage(ChatMessageRole.Assistant, expectedResponse2) } });
The error suggest me to use Completion instead of Chat, but I didn't know how to use Completion with this expected behavior messages like I am trying here.
Ada model is by default a completion model, and not a chat model, as implemented by the OpenAI. Not really an useful feature, but it is what it is. You can solve it by using Model.ChatGPTTurbo. To not raise the price, and keep the ada model, you will have to do automatic prompt engineering - i usually keep an array of dicts with (role, content) pairs, role being "user" and "assistant" and content the text that was passed / was generated as some sort of a history and then add a "history" section to my prompt (this is what is happening in the background when using these roles in chat/completions, anyways)