Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pydantic will detect definitions #11

@zy2021314

Description

@zy2021314
Traceback (most recent call last):
File "D:\pythonProject\llm_agents\run_agent.py", line 1, in
from llm_agents import Agent, ChatLLM, PythonREPLTool, HackerNewsSearchTool, SerpAPITool
File "D:\pythonProject\llm_agents\llm_agents_init_.py", line 5, in
from llm_agents.tools.search import SerpAPITool
File "D:\pythonProject\llm_agents\llm_agents\tools\search.py", line 74, in
class SerpAPITool(ToolInterface):
File "D:\Anaconda\envs\agents\Lib\site-packages\pydantic_internal_model_construction.py", line 96, in new
private_attributes = inspect_namespace(
^^^^^^^^^^^^^^^^^^
File "D:\Anaconda\envs\agents\Lib\site-packages\pydantic_internal_model_construction.py", line 391, in inspect_namespace
raise PydanticUserError(
pydantic.errors.PydanticUserError: Field 'name' defined on a base class was overridden by a non-annotated attribute. All field definitions, including overrides, require a type annotation.

For further information visit https://errors.pydantic.dev/2.8/u/model-field-overridden

I don't know if it's a version update of the library, or if it's my configuration problem, I need to re-enforce the type definition in all utility classes, such as:

class GoogleSearchTool(ToolInterface):
"""Tool for Google search results."""

name:str = "Google Search"
description:str  = "Get specific information from a search query. Input should be a question like 'How to add number in Clojure?'. Result will be the answer to the question."

def use(self, input_text: str) -> str:
    return search(input_text)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions