Find answers from the community

Updated 5 months ago

Upgrading llama-index to 0.11.15 causes issues with mypy

At a glance

A community member upgraded llama-index to version 0.11.15 and encountered issues with mypy, including errors related to missing attributes in various llama_index modules. The community member provided the specific error messages and their imports.

In the comments, other community members suggested updating the openai package and creating a fresh environment, but these suggestions did not resolve the issue. One community member was unable to replicate the problem and suggested using the --ignore-missing-imports flag with mypy to address the missing library stubs or py.typed markers.

There is no explicitly marked answer in the provided information.

Useful resources
After upgrading llama-index to 0.11.15 (from 0.10.* I believe) together with other llama-index packages using poetry I get issues with mypy. Any idea?
Plain Text
error: Module "llama_index.core" has no attribute "Settings"  [attr-defined]
error: Module "llama_index.embeddings.openai" has no attribute "OpenAIEmbedding"  [attr-defined]
error: Module "llama_index.llms.openai" has no attribute "OpenAI"  [attr-defined]

My imports:
Plain Text
from llama_index.core import Settings
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.llms.openai import OpenAI

versions:
Plain Text
poetry show | grep llama
llama-index                               0.11.15          
llama-index-core                          0.11.15          
llama-index-embeddings-openai             0.2.5            
..
W
a
L
4 comments
Have you updated openai package as well?
pip install -U llama-index-llms-openai?
If this doesnt work, I would suggest creating a fresh env and then try again
Yes, it is the latest version ie 0.2.10. The errors above is just a few lines, it looks like all imports using llama-index* throw an error. A new poetry environment does not fix the issue
I'm not able to replicate this. Are you running mypy with any particular arguments/settings?

I know the packages still need py.typed files sadly, so you might have to set --ignore-missing-imports

For example

Plain Text
(venv) loganmarkewich@Logans-MBP test_install % mypy .     
app.py:2: error: Skipping analyzing "llama_index.embeddings.openai": module is installed, but missing library stubs or py.typed marker  [import-untyped]
app.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
app.py:3: error: Skipping analyzing "llama_index.llms.openai": module is installed, but missing library stubs or py.typed marker  [import-untyped]
Found 2 errors in 1 file (checked 1 source file)

(venv) loganmarkewich@Logans-MBP test_install % mypy --ignore-missing-imports .
Success: no issues found in 1 source file
Add a reply
Sign up and join the conversation on Discord