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

Fix the error when using create_sql_agent #145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

reatang
Copy link
Contributor

@reatang reatang commented Jan 21, 2025

fix error: "pydantic.errors.PydanticUndefinedAnnotation: name 'BaseCache' is not defined"

error stack

    |     ret = await asyncio.create_task(coro, context=context)
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/Users/reatang/www/demo-agent-service/src/my_agents/graph.py", line 78, in score_query
    |     sql_agent = create_sql_agent(llm=llm, db=db, prompt=prompt)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/Users/reatang/www/demo-agent-service/.venv/lib/python3.12/site-packages/langchain_community/agent_toolkits/sql/base.py", line 141, in create_sql_agent
    |     toolkit = toolkit or SQLDatabaseToolkit(llm=llm, db=db)  # type: ignore[arg-type]
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/Users/reatang/www/demo-agent-service/.venv/lib/python3.12/site-packages/pydantic/main.py", line 214, in __init__
    |     validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/Users/reatang/www/demo-agent-service/.venv/lib/python3.12/site-packages/pydantic/_internal/_mock_val_ser.py", line 100, in __getattr__
    |     raise PydanticUserError(self._error_message, code=self._code)
    | pydantic.errors.PydanticUserError: `SQLDatabaseToolkit` is not fully defined; you should define `BaseCache`, then call `SQLDatabaseToolkit.model_rebuild()`.
    | 
    | For further information visit https://errors.pydantic.dev/2.10/u/class-not-fully-defined

…ndefinedAnnotation: name 'BaseCache' is not defined"
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 this pull request may close these issues.

1 participant