Skip to content

Commit 1c36f74

Browse files
cnewellSam Skjonsberg
andauthored
[WIP] Fix for TTFT bug (#264)
Fixes https://github.com/allenai/reviz-modal/issues/52 Co-authored-by: Sam Skjonsberg <sams@allenai.org>
1 parent c83965c commit 1c36f74

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/message/create_message_service.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -569,17 +569,18 @@ def map_chunk(chunk: InferenceEngineChunk):
569569
final_message = finalSystemMessage
570570

571571
end_all = time_ns()
572-
logger.info({
573-
"event": "inference.timing",
574-
"ttft_ms": (first_ns - start_all) // 1e6,
575-
"total_ms": (end_all - start_all) // 1e6,
576-
"safety_ms": safety_check_elapsed_time,
577-
"input_tokens": input_token_count,
578-
"output_tokens": output_token_count,
579-
"sha": sha,
580-
"model": model.id,
581-
"safety_check_id": checker_type,
582-
})
572+
if first_ns > start_all:
573+
logger.info({
574+
"event": "inference.timing",
575+
"ttft_ms": (first_ns - start_all) // 1e6,
576+
"total_ms": (end_all - start_all) // 1e6,
577+
"safety_ms": safety_check_elapsed_time,
578+
"input_tokens": input_token_count,
579+
"output_tokens": output_token_count,
580+
"sha": sha,
581+
"model": model.id,
582+
"safety_check_id": checker_type,
583+
})
583584

584585
yield format_message(final_message)
585586

0 commit comments

Comments
 (0)