Skip to content

[Bug] Dependency Issue #57

Description

@yuxuandexter

When I run through examples,
I am always getting error about ChatOpenAI

from langchain_core.callbacks import Callbacks
from langchain_core.caches import BaseCache
from langchain_core.language_models.chat_models import BaseChatModel
ChatOpenAI.model_rebuild()

After adding these, I can run through this math example, which is common for other examples.
It looks like pydantic 2.11.5 isn’t compatible with the dependency versions bundled in the current wheel.

python examples/math/workflow.py 
Traceback (most recent call last):
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/site-packages/pydantic/main.py", line 645, in model_rebuild
    cls.__pydantic_fields__ = _fields.rebuild_model_fields(
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/site-packages/pydantic/_internal/_fields.py", line 326, in rebuild_model_fields
    ann = _typing_extra.eval_type(
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py", line 397, in eval_type
    return eval_type_backport(value, globalns, localns)
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py", line 429, in eval_type_backport
    return _eval_type_backport(value, globalns, localns, type_params)
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py", line 466, in _eval_type_backport
    return _eval_type(value, globalns, localns, type_params)
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py", line 500, in _eval_type
    return typing._eval_type(  # type: ignore
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/typing.py", line 324, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/typing.py", line 688, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
NameError: name 'BaseCache' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/vanitas/open_source_projects/cognify/examples/math/workflow.py", line 11, in <module>
    ChatOpenAI.model_rebuild()
  File "/home/vanitas/miniconda3/envs/cognify_env/lib/python3.10/site-packages/pydantic/main.py", line 654, in model_rebuild
    raise exc from e
pydantic.errors.PydanticUndefinedAnnotation: name 'BaseCache' is not defined

For further information visit https://errors.pydantic.dev/2.11/u/undefined-annotation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions