OpenAI-API-dotnet icon indicating copy to clipboard operation
OpenAI-API-dotnet copied to clipboard

streaming error: Could not load file or assembly "System.Threading.Tasks.Extensions, Version=4.2.0.0

Open ericliu0408 opened this issue 2 years ago • 3 comments

I met below error when calling StreamChatAsync, could you please advise the reason. many thanks:

System.IO.FileLoadException: 'Could not load file or assembly "System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.'

Below is the code I wrote to call StreamChatAsync (my project uses .net framework 4.7):

var api = new OpenAI_API.OpenAIAPI(apiKey);

                        await api.Chat.StreamChatAsync(new ChatRequest()
                        {
                            Model = Model.ChatGPTTurbo,
                            MaxTokens = max_Tokens,
                            Messages = new ChatMessage[]
                            {
        new ChatMessage(ChatMessageRole.User, prompt)
                            }
                        },
                        res =>
                        {
                            answer = res.Choices[0].Message.Content.Trim();

                            richTextBox1.SelectionStart = richTextBox1.TextLength;
                            richTextBox1.SelectionColor = Color.Blue;

                            richTextBox1.AppendText(answer);
                        });

ericliu0408 avatar Apr 24 '23 04:04 ericliu0408

Could anybody please take a look at this issue? this function is critical to my project. many thanks!!! @OkGoDoIt @esp0 @dex3r @gotmike

ericliu0408 avatar May 01 '23 05:05 ericliu0408

Try using System.Threading.Tasks.Extensions.dll I have downloaded raw dll and included to my project

ios1ph avatar May 15 '23 00:05 ios1ph

@ericliu0408 I struggled with this as well in my .net framework project. The only working solution I found is to copy the right dll in the bin(/debug) folder.

glienard avatar May 19 '23 09:05 glienard