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 #34

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[bot] commented 7 months ago

torvalds.dev is analyzing the ticket

torvalds-dev commented 7 months ago

The issue you're facing is a TypeError when trying to import the RetrieverQueryEngine from llama_index.query_engine. The error occurs when the aiostream package is being imported somewhere in the call stack. The specific line causing the error is class OperatorType(Protocol[P, T]): where P and T are ParamSpecs.

The error message TypeError: Parameters to Protocol[...] must all be type variables suggests that the parameters provided to the Protocol are not all type variables, which is a requirement.

The traceback shows that the error originates from the aiostream package, specifically from the core.py file. This suggests that the issue might be with the aiostream package itself, or how it's being used within the llama_index package.

The user has tried installing different versions of typing-extensions but it didn't resolve the issue. This suggests that the problem might not be related to the typing-extensions package.

The relevant files to this issue are:

  1. llama_index/query_engine/__init__.py: This file imports the RetrieverQueryEngine which is causing the error when imported.

  2. llama_index/retrievers/__init__.py: This file might be relevant as it could be importing or using the aiostream package that's causing the error.

To address this issue, the following actions could be taken:

  1. Check the version of aiostream package installed and try updating or downgrading it.

  2. Check if aiostream package has any known issues with Python 3.9.16.

  3. Review the usage of aiostream within the llama_index package to ensure it's being used correctly.

  4. If the issue persists, consider reaching out to the maintainers of aiostream or llama_index with a detailed bug report.