We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1f57087 commit b820cbbCopy full SHA for b820cbb
libs/langchain-community/src/chat_models/zhipuai.ts
@@ -514,7 +514,7 @@ export class ChatZhipuAI extends BaseChatModel implements ChatZhipuAIParams {
514
for await (const chunk of stream) {
515
if (chunk !== "[DONE]") {
516
const deserializedChunk = this._deserialize(chunk);
517
- const { choices, id } = deserializedChunk;
+ const { choices, usage, id } = deserializedChunk;
518
const text = choices[0]?.delta?.content ?? "";
519
const finished = !!choices[0]?.finish_reason;
520
yield new ChatGenerationChunk({
@@ -524,7 +524,8 @@ export class ChatZhipuAI extends BaseChatModel implements ChatZhipuAIParams {
524
? {
525
finished,
526
request_id: id,
527
- usage: chunk.usage,
+ // The usage of tokens is counted at the end of the stream
528
+ usage,
529
}
530
: undefined,
531
});
0 commit comments