|
@@ -46,6 +46,9 @@ class LLMCallbackHandler:
|
|
|
logging.debug(chunk)
|
|
|
|
|
|
if not chunk.choices:
|
|
|
+ if chunk.usage:
|
|
|
+ self.event_handler.pub_message_usage(chunk)
|
|
|
+ continue
|
|
|
continue
|
|
|
|
|
|
choice = chunk.choices[0]
|
|
@@ -53,6 +56,9 @@ class LLMCallbackHandler:
|
|
|
delta = choice.delta
|
|
|
logging.debug(delta)
|
|
|
if not delta:
|
|
|
+ if chunk.usage:
|
|
|
+ self.event_handler.pub_message_usage(chunk)
|
|
|
+ continue
|
|
|
continue
|
|
|
logging.debug(
|
|
|
"delta.tool_callstool_callstool_callstool_callstool_callstool_callstool_callstool_callstool_callstool_calls"
|
|
@@ -89,9 +95,6 @@ class LLMCallbackHandler:
|
|
|
self.event_handler.pub_message_delta(
|
|
|
self.message.id, index, delta.content, delta.role
|
|
|
)
|
|
|
- if chunk.usage:
|
|
|
- self.event_handler.pub_message_usage(chunk)
|
|
|
- continue
|
|
|
except Exception as e:
|
|
|
logging.error("handle_llm_response error: %s", e)
|
|
|
raise e
|