shobrook / openlimit

Maximize your usage of OpenAI models without hitting rate limits
GNU General Public License v3.0
138 stars 22 forks source link

TypeError: duplicate base class TimeoutError (Python >=3.11) #13

Open espdev opened 9 months ago

espdev commented 9 months ago

Hello,

The package does not work on Python >=3.11

>>> from openlimit import EmbeddingRateLimiter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lib/python3.11/site-packages/openlimit/__init__.py", line 1, in <module>
    from openlimit.rate_limiters import ChatRateLimiter, CompletionRateLimiter, EmbeddingRateLimiter
  File "lib/python3.11/site-packages/openlimit/rate_limiters.py", line 6, in <module>
    from openlimit.buckets import Bucket
  File "lib/python3.11/site-packages/openlimit/buckets/__init__.py", line 1, in <module>
    from openlimit.buckets.redis_bucket import RedisBucket
  File "lib/python3.11/site-packages/openlimit/buckets/redis_bucket.py", line 6, in <module>
    import aioredis
  File "lib/python3.11/site-packages/aioredis/__init__.py", line 1, in <module>
    from aioredis.client import Redis, StrictRedis
  File "lib/python3.11/site-packages/aioredis/client.py", line 32, in <module>
    from aioredis.connection import (
  File "lib/python3.11/site-packages/aioredis/connection.py", line 33, in <module>
    from .exceptions import (
  File "lib/python3.11/site-packages/aioredis/exceptions.py", line 14, in <module>
    class TimeoutError(asyncio.TimeoutError, builtins.TimeoutError, RedisError):
TypeError: duplicate base class TimeoutError

Please use redis.asyncio instead of the abandoned aioredis dependency.

Aioredis is now in redis-py 4.2.0rc1+

Also, it would be nice to have redis dependency be optional in extras:

pip install openlimit[redis]
honzajavorek commented 8 months ago

Seems to me that https://github.com/shobrook/openlimit/pull/14 would fix this.

fengchang commented 2 months ago

Hi @shobrook ,

Could you please publish the change in https://github.com/shobrook/openlimit/pull/14 to pip source? Otherwise we are still facing this error.

Thanks, Chang

npip99 commented 1 month ago

If anyone else is running into this error, you can pip install git+https://github.com/shobrook/openlimit.git@ae77eb7d41f537ce1e68f78031f4b7197ddf29f4#egg=openlimit , which also works in requirements.in and requirements.txt