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

Commit

Permalink
Split examples
Browse files Browse the repository at this point in the history
  • Loading branch information
theophilegervet committed Dec 8, 2023
1 parent 6b591bb commit eb058c5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/chat_no_streaming.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import MistralClient from '../client.js';

const apiKey = process.env.MISTRAL_API_KEY;

const client = new MistralClient(apiKey);

const chatResponse = await client.chat(
'mistral-tiny',

Check failure on line 8 in examples/chat_no_streaming.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
[{role: 'user', content: 'What is the best French cheese?'}],

Check failure on line 9 in examples/chat_no_streaming.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
);

console.log('Chat:', chatResponse);
14 changes: 14 additions & 0 deletions examples/chat_with_streaming.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import MistralClient from '../client.js';

const apiKey = process.env.MISTRAL_API_KEY;

const client = new MistralClient(apiKey);

const chatStreamResponse = await client.chatStream(
'mistral-tiny',

Check failure on line 8 in examples/chat_with_streaming.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
[{role: 'user', content: 'What is the best French cheese?'}],

Check failure on line 9 in examples/chat_with_streaming.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
);

for await (const chunk of chatStreamResponse) {
console.log('Chat Stream:', '' + chunk);

Check failure on line 13 in examples/chat_with_streaming.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
}
14 changes: 14 additions & 0 deletions examples/embeddings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import MistralClient from '../client.js';

const apiKey = process.env.MISTRAL_API_KEY;

const client = new MistralClient(apiKey);

const input = [];
for (let i = 0; i < 10; i++) {
input.push('What is the best French cheese?');

Check failure on line 9 in examples/embeddings.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
}

const embeddingsBatchResponse = await client.embeddings('mistral-embed', input);

console.log('Embeddings Batch:', embeddingsBatchResponse.data);
11 changes: 11 additions & 0 deletions examples/list_models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import MistralClient from '../client.js';

const apiKey = process.env.MISTRAL_API_KEY;

const client = new MistralClient(apiKey);

const listModelsResponse = await client.listModels();

listModelsResponse.data.forEach((model) => {
console.log('Model:', model);

Check failure on line 10 in examples/list_models.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
});

0 comments on commit eb058c5

Please sign in to comment.