run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
33.74k stars 4.74k forks source link

[Bug]: metadata_filter.py:20: SyntaxWarning: invalid escape sequence '\*' #14187

Open awilhelm-projects opened 1 month ago

awilhelm-projects commented 1 month ago

Bug Description

I got this warning - and it is simple to solve:

xxxxx-2ETXSZzR-py3.12/lib/python3.12/site-packages/llama_index_client/types/metadata_filter.py:20: SyntaxWarning: invalid escape sequence '\*'
  """

Version

0.10.45

Steps to Reproduce

Just use Llama Index.

Relevant Logs/Tracbacks

Fix:
From:
llama_index_client/types/metadata_filter.py

class MetadataFilter(pydantic.BaseModel):
    """
    Comprehensive metadata filter for vector stores to support more operators.

To:
llama_index_client/types/metadata_filter.py

class MetadataFilter(pydantic.BaseModel):
    r"""
    Comprehensive metadata filter for vector stores to support more operators.
dosubot[bot] commented 1 month ago

To resolve the SyntaxWarning: invalid escape sequence '\*' in the metadata_filter.py file, you can change the docstring to a raw string by prefixing it with r. This prevents Python from interpreting backslashes as escape characters.

Here's the fix:

From:

class MetadataFilter(pydantic.BaseModel):
    """
    Comprehensive metadata filter for vector stores to support more operators.
    """

To:

class MetadataFilter(pydantic.BaseModel):
    r"""
    Comprehensive metadata filter for vector stores to support more operators.
    """

This change will prevent the invalid escape sequence warning.

To continue talking to Dosu, mention @dosu.

kwesinavilot commented 1 week ago

Hello, has this issue been solved?

I'm getting the same warning, and this is affecting a part of my app. I'm not able to visit some endpoints of my API. The feedback I'm getting is:

TypeError at /api/docs/
startswith first arg must be str or a tuple of str, not NoneType

...but this, I believe, is because of this warning I get when my app is running in production:

/python/lib/python3.12/site-packages/llama_cloud/types/metadata_filter.py:20: SyntaxWarning: invalid escape sequence '\*'

I already tried removing the llama_cloud package since my app didn't really use it (or so I thought) but I noticed that llamaindex wasn't running without the llama_cloud package so had to reinstall it

Surprisingly, everything works in my local environment and I'm able to access all endpoints. The error doesn't even show locally but once I deploy to production, I get the SyntaxWarning and the endpoints begin showing the TypeError

Any help?