Open
Description
/// Calls the API to get a response, which is appended to the current chat's <see cref="Messages"/> as an <see cref="ChatMessageRole.Assistant"/>
_chat.AppendUserInput(prompt);
await foreach (string responseChunk in _chat.StreamResponseEnumerableFromChatbotAsync())
{
OutputText.Text += responseChunk;
}
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.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Tryanks commentedon Apr 19, 2023
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?
NorKaiser commentedon Apr 19, 2023
same problem,in openai api stream result,only the first jsonpack has the role information.
Tryanks commentedon Apr 19, 2023
It also looks like there are no errors in the content returned by the OpenAI API :
Then I don't know what the problem is.
Maybe the behavior of Conversation.cs#L193 can be hard-coded as
Assistant
?@OkGoDoIt Can you take a look at this?
Fix OkGoDoIt#119
sdcb commentedon Apr 20, 2023
I just found the causing reason, it will assign
responseRole
multiple times, first time it assignted toassistance
, by next token response, it will reassigned touser
although it's not response in API stream.Pull request to fix: #122
Workaround before official merge:
Specify following code after every call to
chat.StreamResponseEnumerableFromChatbotAsync()
:example:
Tryanks commentedon Apr 20, 2023
Does this mean that the default value of delta.Role is not
null
butuser
?Does it depend on the API or class
ChatMessage
initialization?sdcb commentedon Apr 20, 2023
Yes it seems

ChatMessage
's default role isuser
instead ofnull
: