Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Chat Completions #54

Closed
rsthn opened this issue Mar 1, 2023 · 10 comments · Fixed by #56
Closed

Support for Chat Completions #54

rsthn opened this issue Mar 1, 2023 · 10 comments · Fixed by #56

Comments

@rsthn
Copy link

rsthn commented Mar 1, 2023

Today chat completions are now available:
https://platform.openai.com/docs/api-reference/chat/create

Uses a new end-point (https://api.openai.com/v1/chat/completions), and the latest model "gpt-3.5-turbo".

@megalon
Copy link
Contributor

megalon commented Mar 1, 2023

I am taking a stab at this, but I've hit a wall.
The API is throwing an error that the endpoint is incorrect, but it looks right to me.

System.Net.Http.HttpRequestException: Error at chat/completions (https://api.openai.com/v1/chat/completions) with HTTP status code: NotFound. Content: {
  "error": {
    "message": "Invalid URL (POST /v1/chat/completions)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

Anybody have any suggestions for why this might be happening?
I am not very familiar with how APIs work to be honest.

Here are my changes so far
master...megalon:OpenAI-API-dotnet:feature/chat

Edit;
I was able to get this to work. The error was in the data in the request.

@davidyack
Copy link

@megalon confirming your changes worked for me

@rsthn
Copy link
Author

rsthn commented Mar 2, 2023

This is awesome! Thank you @megalon

@dexinhuang
Copy link

Can someone provide an example of calling the new ChatGPT completion?
I used to use this code, var c = new CompletionRequest(memory.ToString(), GetModel(model), MaxTokens, Temperature, null, Top_p, NumOutputs, PresencePenalty, FrequencyPenalty, LogProbs,null, StopSequences); var results = await OAIEngine.Instance.Api.Completions.CreateCompletionsAsync(c); And I'm not sure how to achieve the same results in the new format

@rsthn
Copy link
Author

rsthn commented Mar 4, 2023

For testing I'm currently using:

var req = new OpenAI_API.Chat.ChatRequest();
req.Model = OpenAI_API.Models.Model.ChatGPTTurbo;
req.Messages = new System.Collections.Generic.List<OpenAI_API.Chat.ChatMessage>();
req.Messages.Add(new OpenAI_API.Chat.ChatMessage("user", "Give me a list of 10 colors"));
req.Temperature = 0;
req.MaxTokens = 100;

var result = await client.Chat.CreateChatAsync(req);
foreach (var i in result.Choices)
{
    Console.WriteLine("["+i.FinishReason+"] " + i.Message.Role + " => " + i.Message.Content);
}

@dexinhuang
Copy link

Amazing, thanks!

@dexinhuang
Copy link

Quick question, I'm being charged for gpt-3.5-turbo-0301, but I've even removed the model from the model list. Is anyone else running into the same issue?

@megalon
Copy link
Contributor

megalon commented Mar 4, 2023 via email

@dexinhuang
Copy link

Great! I appreciate the information! Thanks!

@ericliu0408
Copy link

Could you advise that when it could come out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants