Skip to content

Commit b28924f

Browse files
authored
Merge pull request #1260 from MateuszKepczynski/mkepczynski/mistral-ai/fix/handle-usage-in-stream
fix: mistral-ai /chat/completitions missing "usage" in stream response
2 parents ccc7f62 + 6807fbf commit b28924f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/providers/mistral-ai/chatComplete.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ interface MistralAIStreamChunk {
143143
index: number;
144144
finish_reason: string | null;
145145
}[];
146+
usage: {
147+
prompt_tokens: number;
148+
completion_tokens: number;
149+
total_tokens: number;
150+
};
146151
}
147152

148153
export const MistralAIChatCompleteResponseTransform: (
@@ -212,6 +217,7 @@ export const MistralAIChatCompleteStreamChunkTransform: (
212217
finish_reason: parsedChunk.choices[0].finish_reason,
213218
},
214219
],
220+
...(parsedChunk.usage ? { usage: parsedChunk.usage } : {}),
215221
})}` + '\n\n'
216222
);
217223
};

0 commit comments

Comments
 (0)