Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Add response return to ChatStream #51

Closed

Conversation

ytimocin
Copy link

@ytimocin ytimocin commented Feb 26, 2024

Added response return to ChatStream.

Fixes: #50

Signed-off-by: ytimocin <ytimocin@microsoft.com>
@@ -325,6 +325,8 @@ class MistralClient {
}
}
}

return response;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both unit tests and chat_with_streaming example pass with and without this one.

@sublimator
Copy link
Contributor

This is not necessary. You are supposed to use as so:

import MistralClient from '@mistralai/mistralai';
const apiKey = process.env.MISTRAL_API_KEY;
const client = new MistralClient(apiKey);
const chatStreamResponse = await client.chatStream({
model: 'mistral-tiny',
messages: [{role: 'user', content: 'What is the best French cheese?'}],
});
console.log('Chat Stream:');
for await (const chunk of chatStreamResponse) {
if (chunk.choices[0].delta.content !== undefined) {
const streamText = chunk.choices[0].delta.content;
process.stdout.write(streamText);
}
}

@ytimocin ytimocin closed this May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client does not return a response
2 participants