Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client does not return a response #50

Open
chanmathew opened this issue Feb 26, 2024 · 3 comments
Open

Client does not return a response #50

chanmathew opened this issue Feb 26, 2024 · 3 comments

Comments

@chanmathew
Copy link

chanmathew commented Feb 26, 2024

Hi there,

Running the latest version of the SDK 0.1.3, but when I try to init and call the client, it does not return anything.

Here is my code:

const mistral = new MistralClient(env.PUBLIC_MISTRAL_API_KEY)
const response = await mistral.chatStream({
	model: 'mistral-large-latest',
	messages: [{ role: 'system', content: 'Say hello world.' }],
	temperature: 0
})

// response is an empty object {}
@chanmathew chanmathew changed the title Client throws 500 response Client does not return a response Feb 26, 2024
@ytimocin
Copy link

I can give this one a try.

@ptesny
Copy link

ptesny commented Mar 17, 2024

chatStream is a generator function

client: MistralClient {
_request: [AsyncFunction: _request],
_makeChatCompletionRequest: [Function: _makeChatCompletionRequest],
listModels: [AsyncFunction: listModels],
chat: [AsyncFunction: chat],
chatStream: [AsyncGeneratorFunction: chatStream],
embeddings: [AsyncFunction: embeddings],
endpoint: 'https://api.mistral.ai',
apiKey: '********',
maxRetries: 5,
timeout: 120,
modelDefault: 'mistral'
}

@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);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants