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 数? #231

Closed
tangwenru opened this issue Apr 6, 2023 · 6 comments
Closed

如何获取 花费的 token 数? #231

tangwenru opened this issue Apr 6, 2023 · 6 comments
Labels
duplicate This issue or pull request already exists question Further information is requested stale

Comments

@tangwenru
Copy link

stream, errCreate := gptClient.CreateChatCompletionStream(ctx, reqData)

response, err := stream.Recv() 

问题:

为什么 1.6.1 取消了 response.Usage 对象?
也就是说,现在 无法得知 返回内容 花费的 token 了。。

有什么办法 得知么?

@fsmytsai
Copy link

fsmytsai commented Apr 7, 2023

我有一樣的問題,有人能回覆嗎?

@smile-magic
Copy link

#223

@yyyyzwd
Copy link

yyyyzwd commented Apr 19, 2023

俺也一样

@nasa1024
Copy link
Contributor

当stream = true时,接口不会返回tokenNum,需要用户自己去计算
@tangwenru @yyyyzwd @smile-magic @fsmytsai
可以参考 #223的方式
或者直接使用 tiktoken-go

@vvatanabe vvatanabe added question Further information is requested stale labels Jul 1, 2023
@vvatanabe
Copy link
Collaborator

Closing this due to lack of comments for an extended period. Hopefully, the proposed solution has resolved your issue.

@vvatanabe vvatanabe added the duplicate This issue or pull request already exists label Jul 3, 2023
@vvatanabe
Copy link
Collaborator

Related: #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

6 participants