PawanOsman / ChatGPT.Net

C# library for ChatGPT using official OpenAI API

Home Page:https://www.nuget.org/packages/ChatGPT.Net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

program stopped without any prompt

willhuo opened this issue · comments

111

` private static async Task ChatgptNetTestAsync()
{
var chatGpt = new ChatGpt(new ChatGptConfig
{
UseCache = true
});
await chatGpt.WaitForReady();
var chatGptClient = await chatGpt.CreateClient(new ChatGptClientConfig
{
SessionToken = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..",
AccountType = AccountType.Free
});

    //init unique conversation id
    //var conversationId = Guid.NewGuid().ToString("N");
    var conversationId = "a-unique-string-id";

    while (true)
    {
        Serilog.Log.Information("pls ask a question");
        var question = Console.ReadLine();
        var response = await chatGptClient.Ask(question, conversationId);
        Serilog.Log.Information("answer:{0}", response);            
    }
}

`

I find the bug finally.
The async method caused the problem.