Chainlit / literalai-python

https://docs.getliteral.ai/
Apache License 2.0
8 stars 0 forks source link

NameError: Fields must not use names with leading underscores; e.g., use 'client' instead of '_client'. #114

Closed amait41 closed 3 weeks ago

amait41 commented 3 weeks ago

CODE

from literalai import LiteralClient

lc = LiteralClient() lc.instrument_llamaindex()

CONDA ENV

chainlit==0.7.700 fastapi==0.100.1 httpx==0.24.1 literalai==0.0.612 llama-index==0.11.1 llama-index-embeddings-azure-openai==0.2.4 llama-index-llms-azure-openai==0.2.0 llama-index-vector-stores-qdrant==0.3.0 pytest==8.3.2 pytest-asyncio==0.24.0 uvicorn==0.23.2

ERROR


NameError Traceback (most recent call last) Cell In[9], line 4 1 from literalai import LiteralClient 3 lc = LiteralClient() ----> 4 lc.instrument_llamaindex()

File /anaconda/envs/eliott/lib/python3.11/site-packages/literalai/client.py:103, in BaseLiteralClient.instrument_llamaindex(self) 99 if not check_all_requirements(LLAMA_INDEX_REQUIREMENT): 100 raise Exception( 101 f"LlamaIndex instrumentation requirements not satisfied: {LLAMA_INDEX_REQUIREMENT}" 102 ) --> 103 from literalai.instrumentation.llamaindex import instrument_llamaindex 105 instrument_llamaindex(self.to_sync())

File /anaconda/envs/eliott/lib/python3.11/site-packages/literalai/instrumentation/llamaindex.py:111 92 model_dict = event.model_dict 94 return ChatGeneration( 95 provider=model_dict.get("class_name"), 96 model=model_dict.get("model"), (...) 107 ], 108 ) --> 111 class LiteralEventHandler(BaseEventHandler): 112 """This class handles events coming from LlamaIndex.""" 114 _client: "LiteralClient" = Field(...)

File /anaconda/envs/eliott/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py:96, in ModelMetaclass.new(mcs, cls_name, bases, namespace, pydantic_generic_metadata, __pydantic_reset_parent_namespace__, _create_model_module, **kwargs) 94 config_wrapper = ConfigWrapper.for_model(bases, namespace, kwargs) 95 namespace['model_config'] = config_wrapper.config_dict ---> 96 private_attributes = inspect_namespace( 97 namespace, config_wrapper.ignored_types, class_vars, base_field_names 98 ) 99 if private_attributes or base_private_attributes: 100 original_model_post_init = get_model_post_init(namespace, bases)

File /anaconda/envs/eliott/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py:376, in inspect_namespace(namespace, ignored_types, base_class_vars, base_class_fields) 374 elif isinstance(value, FieldInfo) and not is_valid_field_name(var_name): 375 suggested_name = varname.lstrip('') or 'my_field' # don't suggest '' for all-underscore name --> 376 raise NameError( 377 f'Fields must not use names with leading underscores;' 378 f' e.g., use {suggested_name!r} instead of {var_name!r}.' 379 ) 381 elif var_name.startswith('__'): 382 continue

NameError: Fields must not use names with leading underscores; e.g., use 'client' instead of '_client'.

amait41 commented 3 weeks ago

Quelle version de pydantic utilisez-vous ?

desaxce commented 3 weeks ago

Quelle version de pydantic utilisez-vous ?

Bien vu ! llama-index a changé sa dépendance sur pydantic à partir de llama-index version 0.11.0 et literalai en hérite. Je vais adapter le package aujourd'hui.

En attendant vous pouvez installer une version antérieure avec:

pip install --force-reinstall llama-index==0.10.68
amait41 commented 3 weeks ago

Merci :)