mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-28 19:05:31 +02:00
Merge pull request #138 from rowboatlabs/tokens_used
fixed token_used error for other providers
This commit is contained in:
commit
df3e06a08d
1 changed files with 11 additions and 8 deletions
|
|
@ -196,12 +196,15 @@ async def run_turn_streamed(
|
||||||
if event.type == "raw_response_event":
|
if event.type == "raw_response_event":
|
||||||
# Handle token usage counting
|
# Handle token usage counting
|
||||||
if hasattr(event.data, 'type') and event.data.type == "response.completed" and hasattr(event.data.response, 'usage'):
|
if hasattr(event.data, 'type') and event.data.type == "response.completed" and hasattr(event.data.response, 'usage'):
|
||||||
tokens_used["total"] += event.data.response.usage.total_tokens
|
try:
|
||||||
tokens_used["prompt"] += event.data.response.usage.input_tokens
|
tokens_used["total"] += event.data.response.usage.total_tokens
|
||||||
tokens_used["completion"] += event.data.response.usage.output_tokens
|
tokens_used["prompt"] += event.data.response.usage.input_tokens
|
||||||
print('-'*50)
|
tokens_used["completion"] += event.data.response.usage.output_tokens
|
||||||
print(f"Found usage information. Updated cumulative tokens: {tokens_used}")
|
print('-'*50)
|
||||||
print('-'*50)
|
print(f"Found usage information. Updated cumulative tokens: {tokens_used}")
|
||||||
|
print('-'*50)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Warning: Tokens used is likely not available for your chosen model: {e}")
|
||||||
|
|
||||||
web_search_messages = handle_web_search_event(event, current_agent)
|
web_search_messages = handle_web_search_event(event, current_agent)
|
||||||
for message in web_search_messages:
|
for message in web_search_messages:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue