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

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjeev-kadam committed Jan 1, 2024
1 parent f7049e5 commit 1b3d954
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
mockListModels,
mockFetch,
mockChatResponseStreamingPayload,
mockEmbeddingRequest,
mockEmbeddingResponsePayload,
mockChatResponsePayload,
mockFetchStream,
Expand Down Expand Up @@ -65,7 +66,7 @@ describe('Mistral Client', () => {
const mockResponse = mockEmbeddingResponsePayload();
globalThis.fetch = mockFetch(200, mockResponse);

const response = await client.listModels();
const response = await client.embeddings(mockEmbeddingRequest);
expect(response).toEqual(mockResponse);
});
});
Expand All @@ -76,7 +77,7 @@ describe('Mistral Client', () => {
const mockResponse = mockEmbeddingResponsePayload(10);
globalThis.fetch = mockFetch(200, mockResponse);

const response = await client.listModels();
const response = await client.embeddings(mockEmbeddingRequest);
expect(response).toEqual(mockResponse);
});
});
Expand Down
11 changes: 11 additions & 0 deletions tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,14 @@ export function mockEmbeddingResponsePayload(batchSize = 1) {
usage: {prompt_tokens: 90, total_tokens: 90, completion_tokens: 0},
};
}

/**
* Mock embeddings request payload
* @return {Object}
*/
export function mockEmbeddingRequest() {
return {
model: 'mistral-embed',
input: 'embed'
};
}

0 comments on commit 1b3d954

Please sign in to comment.