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

chat(hash) to also return raw response + header object #9

Open
drnic opened this issue Apr 26, 2024 · 1 comment
Open

chat(hash) to also return raw response + header object #9

drnic opened this issue Apr 26, 2024 · 1 comment

Comments

@drnic
Copy link
Owner

drnic commented Apr 26, 2024

Currently chat(messages) returns a hash {role: "assistant", content: "Welcome"} and there is no way to access the raw response object which contains usage data:

"usage":{"prompt_tokens":163,"prompt_time":0.059,"completion_tokens":481,"completion_time":1.591,"total_tokens":644,"total_time":1.65}

Nor does it return the HTTP header information that contains rate limit stats:

x-ratelimit-limit-requests: "14400"
x-ratelimit-limit-tokens: "7000"
x-ratelimit-remaining-requests: "14399"
x-ratelimit-remaining-tokens: "6818"
x-ratelimit-reset-requests: "6s"
x-ratelimit-reset-tokens: "1.559999999s"
x-request-id: "req_01hwe17kc9efg93xtwk30d5tx4"

Can we change chat() to return multiple response objects?

message, response, headers = @client.chat("Hello?")
# if you just want one
message, _ = @client.chat("Hello?)

Perhaps this mode is enabled via config @client.chat("Hello?", metadata: true)

@inspire22
Copy link

I'd love this too! Currently struggling to stay inside their rate limits & it's hard without better ability to show their headers. I think it should be enabled by default, or just auto-log with metadata: true., but better to return it as the other result imo.

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

2 participants