Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
amait41 opened this issue Aug 27, 2024 · 3 comments · Fixed by #115

Comments

@amait41
Copy link

amait41 commented Aug 27, 2024

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 = var_name.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
Copy link
Author

amait41 commented Aug 27, 2024

Quelle version de pydantic utilisez-vous ?

@desaxce
Copy link
Collaborator

desaxce commented Aug 27, 2024

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
Copy link
Author

amait41 commented Aug 27, 2024

Merci :)

@desaxce desaxce linked a pull request Aug 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@desaxce @amait41 and others