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

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bam4d committed Jan 15, 2024
1 parent d608764 commit 7e0e9eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MistralClient {
method: method,
headers: {
'User-Agent': `mistral-client-js/${VERSION}`,
'Accept': request.stream ? 'text/event-stream' : 'application/json',
'Accept': request?.stream ? 'text/event-stream' : 'application/json',
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.apiKey}`,
},
Expand Down
11 changes: 6 additions & 5 deletions tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ export function mockChatResponsePayload() {
* @return {Object}
*/
export function mockChatResponseStreamingPayload() {
const encoder = new TextEncoder();
const firstMessage =
['data: ' +
[encoder.encode('data: ' +
JSON.stringify({
id: 'cmpl-8cd9019d21ba490aa6b9740f5d0a883e',
model: 'mistral-small',
Expand All @@ -195,12 +196,12 @@ export function mockChatResponseStreamingPayload() {
},
],
}) +
'\n\n'];
const lastMessage = ['data: [DONE]\n\n'];
'\n\n')];
const lastMessage = [encoder.encode('data: [DONE]\n\n')];

const dataMessages = [];
for (let i = 0; i < 10; i++) {
dataMessages.push(
dataMessages.push(encoder.encode(
'data: ' +
JSON.stringify({
id: 'cmpl-8cd9019d21ba490aa6b9740f5d0a883e',
Expand All @@ -215,7 +216,7 @@ export function mockChatResponseStreamingPayload() {
},
],
}) +
'\n\n',
'\n\n'),
);
}

Expand Down

0 comments on commit 7e0e9eb

Please sign in to comment.