Skip to content

Commit 6807fbf

Browse files
fix(mistral-ai): add usage object in stream response chunk
1 parent 8051db4 commit 6807fbf

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)