-
Notifications
You must be signed in to change notification settings - Fork 430
StreamResponseEnumerableFromChatbotAsync wrong role? #119
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I have checked the source code Conversation.cs#L193 and there seems to be no problem. Is it possible that the OpenAI APIf return value is wrong? |
same problem,in openai api stream result,only the first jsonpack has the role information. |
It also looks like there are no errors in the content returned by the OpenAI API : "choices": [
{
"delta": {
"role": "assistant"
},
"finish_reason": null,
"index": 0
}
] Then I don't know what the problem is. Maybe the behavior of Conversation.cs#L193 can be hard-coded as @OkGoDoIt Can you take a look at this? |
This is caused if upstream delta Role was not provided, then "user" will returned.
I just found the causing reason, it will assign Workaround before official merge: chat.Messages[^1].Role = ChatMessageRole.Assistant; example: OpenAIAPI api = OpenAIAPI.ForAzure("*****", "*****", "******");
api.ApiVersion = "2023-03-15-preview";
Conversation chat = api.Chat.CreateConversation();
while (true)
{
string? input = Console.ReadLine();
if (input == "exit" || input == "q") break;
chat.AppendUserInput(input);
Console.WriteLine($"> {input}");
await foreach (string res in chat.StreamResponseEnumerableFromChatbotAsync())
{
Console.Write(res);
}
Console.WriteLine();
chat.Messages[^1].Role = ChatMessageRole.Assistant; // important
} |
Does this mean that the default value of delta.Role is not |
Trying to use the following but when looking at the messages in chat I can see that the role for the responses is marked as User instead of Assistant.
The text was updated successfully, but these errors were encountered: