mistralai / client-js

JS Client library for Mistral AI platform
Apache License 2.0
185 stars 46 forks source link

Client does not return a response #50

Closed chanmathew closed 1 month ago

chanmathew commented 8 months ago

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 {}
ytimocin commented 8 months ago

I can give this one a try.

ptesny commented 7 months ago

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 commented 6 months ago

This is not necessary. You are supposed to use as so: https://github.com/mistralai/client-js/blob/649923634ff7302f2e7c58c505cbe5cb3a431c68/examples/chat_with_streaming.js#L1-L18

GaspardBT commented 1 month ago

Thanks for reporting this issue. We have deprecated this package in favor of mistralai/client-ts, which is the new official Mistral client, compatible with both TypeScript and JavaScript.

You can find all installation information here.

This change is effective starting with version 1.0.0 of the npm package.

Let us know if your issue persists with the new package by opening an issue there.