cohere-ai / cohere-python

Python Library for Accessing the Cohere API
https://docs.cohere.ai
MIT License
278 stars 60 forks source link

fix(base_client): max_retries null point exception #488

Closed aniaan closed 3 months ago

aniaan commented 3 months ago

Reproduce code(Due to various reasons, the api request failed, such as rate limiting.):

resp = co.tokenize(text=text, model="embed-multilingual-light-v3.0", offline=False)

Exception stack trace:

response = self.httpx_client.request(*args, **kwargs)
     95 if _should_retry(response=response):
---> 96     if max_retries > retries:
     97         time.sleep(_retry_timeout(response=response, retries=retries))
     98         return self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs)

TypeError: '>' not supported between instances of 'NoneType' and 'int'

The reason is because of None value for max_retries.

Other similar codes should also have corresponding issues, so I made some modifications together.

CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.