This is the only(before) .Net Framework ChatGPT API You Can use. 你(以前)唯一能在.Net Framework中的ChatGPT API 中文版本文档
ChatGPTClient cgc = new ChatGPTClient("YOU-API-KEY");
cgc.Ask("Store-History-ID", "Hi ChatGPT").GetMessageContent();
cgc.CreateCompletions("Store-History-ID", "System Message");
cgc.Ask("Store-History-ID", "Hi ChatGPT");
cgc.Ask_stream("Store-History-ID", "Hi ChatGPT", (x) =>
{
if (!string.IsNullOrEmpty(x.GetDeltaContent()))
{
Console.Write(x.choices[0].delta.content);
}
else if (x.GetDelta()?.finish_reason != null)
{
Console.WriteLine("\n---" + x.choices[0].delta.finish_reason + "---\n");
}
});
Also Can see Demo at ChatGPT.API.Test
ChatGPTClient cgc = new ChatGPTClient("YOU-API-KEY");
string json = cgc.Save();
cgc = ChatGPTClient.Load(Json);
See Completions.cs
and ChatGPTClient.cs
cgc.Completions["Store-History-ID"].max_tokens = 20;
ChatGPTClient cgc = new ChatGPTClient("你的ChatGPT的APIKEY");
//若库中无对话历史记录,会自动创建对话
cgc.Ask("储存历史用的id", "你好 ChatGPT").GetMessageContent();
cgc.CreateCompletions("储存历史用的id", "你是个可爱的桌宠,请用可爱的语气和我说话");
cgc.Ask("储存历史用的id", "你好,桌宠");
cgc.Ask_stream("储存历史用的id", "你好,桌宠", (x) =>
{
if (!string.IsNullOrEmpty(x.GetDeltaContent()))
{
Console.Write(x.GetDeltaContent());
}
else if (x.GetDelta()?.finish_reason != null)
{
Console.WriteLine("\n---" + x.GetDelta().delta.finish_reason + "---\n");
}
});
具体案例可以参见 ChatGPT.API.Test
ChatGPTClient cgc = new ChatGPTClient("YOU-API-KEY");
string json = cgc.Save();
cgc = ChatGPTClient.Load(Json);
具体见 Completions.cs
和ChatGPTClient.cs
cgc.Completions["Store-History-ID"].max_tokens = 20;