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

Improve code quality #31

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
};
}