From 9fcee1ad8a3815c68bfb533800a5a9e6bae9f230 Mon Sep 17 00:00:00 2001 From: Samuel Rince Date: Fri, 23 Aug 2024 20:45:13 +0200 Subject: [PATCH] fix: skip first token for azure openai async + stream --- ecologits/tracers/openai_tracer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ecologits/tracers/openai_tracer.py b/ecologits/tracers/openai_tracer.py index 1cf21a0..a880cda 100644 --- a/ecologits/tracers/openai_tracer.py +++ b/ecologits/tracers/openai_tracer.py @@ -139,6 +139,8 @@ async def openai_async_chat_wrapper_stream( i = 0 token_count = 0 async for chunk in stream: + if i == 0 and chunk.model == "": + continue if i > 0 and chunk.choices[0].finish_reason is None: token_count += 1 request_latency = time.perf_counter() - timer_start