torvalds-dev / llama_index

LlamaIndex (formerly GPT Index) is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
0 stars 0 forks source link

[Bug]: TypeError when importing aiostream while importing RetrieverQueryEngine #19

Open torvalds-dev opened 7 months ago

torvalds-dev commented 7 months ago

Bug Description

Python: 3.9.16

This is the lowest level failure of importing a class from llama_index that depends on import from aiostream somwhere down the call stack. The offending line is class OperatorType(Protocol[P, T]): where P and T are ParamSpecs

I tried installing the different versions of typing-extentions but that does not change anything.

Expected behavior: imports without TypeError

Version

0.9.8.post1

Steps to Reproduce

from llama_index.query_engine import RetrieverQueryEngine

Relevant Logs/Tracbacks

File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/__init__.py", line 18, in <module>
    from . import stream, pipe
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/stream/__init__.py", line 3, in <module>
    from .create import *
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/stream/create.py", line 21, in <module>
    from ..stream import time
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/stream/time.py", line 6, in <module>
    from ..core import streamcontext, pipable_operator
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/core.py", line 260, in <module>
    class OperatorType(Protocol[P, T]):
  File "/usr/lib/python3.9/typing.py", line 277, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3.9/typing.py", line 997, in __class_getitem__
    raise TypeError(
TypeError: Parameters to Protocol[...] must all be type variables
torvalds-dev commented 7 months ago

torvalds.dev is analyzing the ticket

torvalds-dev commented 7 months ago

The issue you're facing is related to the aiostream package, which is a dependency of the llama_index package you're trying to import from. The error message indicates that there's a TypeError when the aiostream package tries to define a class OperatorType with Protocol[P, T], where P and T are ParamSpecs.

The error message Parameters to Protocol[...] must all be type variables suggests that P and T are not being recognized as type variables, which is a requirement for the Protocol generic in Python's typing module.

This could be due to a few reasons:

  1. There might be a version mismatch between the aiostream package and the Python interpreter you're using. The aiostream package might not be fully compatible with Python 3.9.16, which you're using.

  2. There might be a bug in the aiostream package itself, which is causing this error.

  3. The typing-extensions package, which provides additional typing capabilities beyond those included in the standard typing module, might not be correctly installed or might be incompatible with your Python version or the aiostream package.

To resolve this issue, you could try the following steps:

  1. Check the version of aiostream you're using and see if there's a newer version available that might have fixed this issue.

  2. Check if there are known issues related to this error in the aiostream package's issue tracker or documentation.

  3. Try using a different Python version. If the aiostream package is not fully compatible with Python 3.9.16, using an older version might resolve the issue.

  4. If none of the above steps work, you might need to contact the maintainers of the aiostream package or the llama_index package for further assistance.