mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 04:01:02 +02:00
Fix mistral metrics
This commit is contained in:
parent
4fca97d555
commit
105ef95262
1 changed files with 11 additions and 3 deletions
|
|
@ -156,6 +156,9 @@ class Processor(LlmService):
|
||||||
response_format={"type": "text"}
|
response_format={"type": "text"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
total_input_tokens = 0
|
||||||
|
total_output_tokens = 0
|
||||||
|
|
||||||
for chunk in stream:
|
for chunk in stream:
|
||||||
if chunk.data.choices and chunk.data.choices[0].delta.content:
|
if chunk.data.choices and chunk.data.choices[0].delta.content:
|
||||||
yield LlmChunk(
|
yield LlmChunk(
|
||||||
|
|
@ -166,11 +169,16 @@ class Processor(LlmService):
|
||||||
is_final=False
|
is_final=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# Send final chunk
|
# Capture usage data when available (typically in final chunk)
|
||||||
|
if chunk.data.usage:
|
||||||
|
total_input_tokens = chunk.data.usage.prompt_tokens
|
||||||
|
total_output_tokens = chunk.data.usage.completion_tokens
|
||||||
|
|
||||||
|
# Send final chunk with token counts
|
||||||
yield LlmChunk(
|
yield LlmChunk(
|
||||||
text="",
|
text="",
|
||||||
in_token=None,
|
in_token=total_input_tokens,
|
||||||
out_token=None,
|
out_token=total_output_tokens,
|
||||||
model=model_name,
|
model=model_name,
|
||||||
is_final=True
|
is_final=True
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue