Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token Usage Always Zero in Accumulation Stream Example from OpenAI Go SDK #149

Open
GuoChengH opened this issue Dec 20, 2024 · 0 comments
Open

Comments

@GuoChengH
Copy link

Hello OpenAI team,

I've been using the OpenAI Go SDK and specifically running the stream example provided at https://github.com/openai/openai-go/blob/main/examples/chat-completion-accumulating/main.go. However, I've encountered an issue where the token usage is always reported as zero, despite the example running correctly and generating outputs.

Steps to Reproduce:

  1. Clone the OpenAI Go SDK from the main branch.
  2. Navigate to the examples/chat-completion-accumulating directory.
  3. Run the example using go run main.go.
  4. Observe the outputs, specifically the token usage statistics.

Expected Behavior:
The token usage should accurately reflect the number of tokens used during the chat completions.

Actual Behavior:
The token usage is consistently reported as zero.

Output Details:
`
> Begin a very brief introduction of Greece, then incorporate the local weather of a few towns

{"role":"assistant","content":null}
{"tool_calls":[{"index":0,"id":"call_TqDP3Izo7KIyfFgmEzkkWZdn","type":"function","function":{"name":"get_live_weather","arguments":""}}]}
{"tool_calls":[{"index":0,"function":{"arguments":"{\"lo"}}]}
{"tool_calls":[{"index":0,"function":{"arguments":"catio"}}]}
{"tool_calls":[{"index":0,"function":{"arguments":"n\": \"A"}}]}
{"tool_calls":[{"index":0,"function":{"arguments":"then"}}]}
{"tool_calls":[{"index":0,"function":{"arguments":"s\"}"}}]}
Tool call stream finished: 0 get_live_weather {"location": "Athens"}

{"tool_calls":[{"index":1,"id":"call_eRCQGBbzI0eqWrFkxyE6HJaj","type":"function","function":{"name":"get_live_weather","arguments":""}}]}
{"tool_calls":[{"index":1,"function":{"arguments":"{\"lo"}}]}
{"tool_calls":[{"index":1,"function":{"arguments":"catio"}}]}
{"tool_calls":[{"index":1,"function":{"arguments":"n\": \"T"}}]}
{"tool_calls":[{"index":1,"function":{"arguments":"hess"}}]}
{"tool_calls":[{"index":1,"function":{"arguments":"aloni"}}]}
{"tool_calls":[{"index":1,"function":{"arguments":"ki\"}"}}]}
Tool call stream finished: 1 get_live_weather {"location": "Thessaloniki"}

{"tool_calls":[{"index":2,"id":"call_5wx6hceKR9z5gr3w4s0b9iE8","type":"function","function":{"name":"get_live_weather","arguments":""}}]}
{"tool_calls":[{"index":2,"function":{"arguments":"{\"lo"}}]}
{"tool_calls":[{"index":2,"function":{"arguments":"catio"}}]}
{"tool_calls":[{"index":2,"function":{"arguments":"n\": \"H"}}]}
{"tool_calls":[{"index":2,"function":{"arguments":"erak"}}]}
{"tool_calls":[{"index":2,"function":{"arguments":"lion\""}}]}
{"tool_calls":[{"index":2,"function":{"arguments":"}"}}]}
Tool call stream finished: 2 get_live_weather {"location": "Heraklion"}

{}
Total Tokens: 0
Finish Reason: tool_calls

`

Could you please look into this? It seems like either the token usage data is not being captured accurately, or there might be an issue with how it's being reported in the example.

Thank you for your assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant