walterbm / cohere-rust

Rust crate for accessing the Cohere API
MIT License
2 stars 1 forks source link

No functionality for handling ratelimiting #1

Closed Brendon-Hablutzel closed 2 weeks ago

Brendon-Hablutzel commented 3 months ago

While using a trial key for the /chat endpoint, I would occasionally encounter the following error:

Err(RequestError(Error("missing field `event_type`", line: 1, column: 328)))

After cloning this crate directly and adding some print statements, it turns out that this occurs when the JSON response from the API was as follows:

{"message":"You are using a Trial key, which is limited to 10 API calls / minute. You can continue to use the Trial key for free or upgrade to a Production key with higher rate limits at 'https://dashboard.cohere.com/api-keys'. Contact us on 'https://discord.gg/XW44jPfYJu' or email us at support@cohere.com with any questions"}

However, there is no indication to the library user that the error is related to ratelimiting and seems initially to be some sort of internal JSON parsing error.

If this is not intentional, I would be willing to add and implement a ratelimiting error myself.

walterbm commented 2 weeks ago

hello @Brendon-Hablutzel, sorry for the late response. thank you for catching and reporting this error.

this should be fixed with this commit https://github.com/walterbm/cohere-rust/commit/8c75ccd486aca331b7deff47583f7006679ac44c that is included in the latest (v0.6.0) release

please let me know if you run into ant more issues