Gentopia-AI / Gentopia

Build Hierarchical Autonomous Agents through Config. Collaborative Growth of Specialized Agents.
MIT License
291 stars 41 forks source link

PydanticUserError while compiling error from `basetool.py` caused by `ToolMetaclass` #63

Closed Jupiter1995 closed 10 months ago

Jupiter1995 commented 10 months ago

When running a customized assembler.py, I received a pydnatic error saying, "Field name doesn't have the annotation." The detailed error screenshot is attached below and some printouts to help understand the problem.

error: image

printout code and printouts: # test block codes inside basetool.py under ToolMetaclass.__new__(): print("----test block-----") print(f"tool name: {name} \n") print(f"namespace dict annotation list: {dct.get('__annotations__', [])} \n") print(f"namespace items: {[k for k,v in dct.items()]} \n") print(f"namespace vals: {[v for k,v in dct.items()]} \n") print("----test block end----") image

github-actions[bot] commented 10 months ago

Greetings! Thanks for your first issue!

billxbf commented 10 months ago

I don't run into this error in my env. Seems like a version mismatch issue. What pydantic version are you using?

If you create a new env and pip install gentopia, you should get pydantic == 1.9.0

Jupiter1995 commented 10 months ago

I don't run into this error in my env. Seems like a version mismatch issue. What pydantic version are you using?

If you create a new env and pip install gentopia, you should get pydantic == 1.9.0

I did install the required packages via requirement.txt under docs. But I think you're right. Mine is 2.4.2. Let me uninstall it and check again. I'll keep you posted.

Jupiter1995 commented 10 months ago

I don't run into this error in my env. Seems like a version mismatch issue. What pydantic version are you using? If you create a new env and pip install gentopia, you should get pydantic == 1.9.0

I did install the required packages via requirement.txt under docs. But I think you're right. Mine is 2.4.2. Let me uninstall it and check again. I'll keep you posted.

I created a new env and ran pip install gentopia, and it solved the old problem! However, I'm receiving a new error from typing package lol: Screenshot 2023-11-19 at 11 46 19 AM Any idea or suggestions?

billxbf commented 10 months ago

what's your agent config file

Jupiter1995 commented 10 months ago

what's your agent config file

The agent.yaml file is attached below. Please ignore the environment as the implementation hasn't finished, so it will ignored in the agent_assembler.py.

name: mark
type: react_conv
version: 0.0.1
description: mark is a professional personal trainer. He is able to create customized plans for different people depends on their expectations and body conditions.
target_tasks:
  - create training plans and strategies.
  - collaborate with nutritionist to adjust training plans.
prompt_template: !prompt multi_agent_test.agents.personal_trainer.prompt.PromptOfTrianer
llm:
  model_name: baize
  params:
    temperature: 0.5
    top_p: 0.9
    repetition_penalty: 0.0
    max_tokens: 1024
environment:
  name: training_plan_test01
plugins:
  - name: google_search
  - name: arxiv_search
    param:
      top_k: 3
  - name: web_page
Jupiter1995 commented 10 months ago

I tried to use the original Gentopia without any changes and also the example agent elon but still received the same error within the new environment I created using pip install gentopia. The agent.yaml attached below.

name: elon
type: react
version: 0.0.1
description: elon is an experienced and visionary entrepreneur. He is able to create a startup from scratch and get a strong team to support his ideas.
target_tasks:
  - create business plans and strategies.
  - arrange a bunch of tools and agents to collaborate on his ideas.
prompt_template: !prompt gentpool.pool.elon.prompt.PromptOfElon
llm:
  model_name: baize
  params:
    temperature: 0.0
    top_p: 0.9
    repetition_penalty: 0.0
    max_tokens: 1024
plugins:
  - name: google_search
  - name: arxiv_search
    param:
      top_k: 3
  - name: web_page
  - name: bash_shell
  - !tool gentpool.pool.elon.tool.ElonDrawing
  - !include ../dr_science/agent.yaml

Screenshot of the error: Screenshot 2023-11-26 at 12 24 45 PM

Jupiter1995 commented 10 months ago

I tried to use the original Gentopia without any changes and also the example agent elon but still received the same error within the new environment I created using pip install gentopia. The agent.yaml attached below.

name: elon
type: react
version: 0.0.1
description: elon is an experienced and visionary entrepreneur. He is able to create a startup from scratch and get a strong team to support his ideas.
target_tasks:
  - create business plans and strategies.
  - arrange a bunch of tools and agents to collaborate on his ideas.
prompt_template: !prompt gentpool.pool.elon.prompt.PromptOfElon
llm:
  model_name: baize
  params:
    temperature: 0.0
    top_p: 0.9
    repetition_penalty: 0.0
    max_tokens: 1024
plugins:
  - name: google_search
  - name: arxiv_search
    param:
      top_k: 3
  - name: web_page
  - name: bash_shell
  - !tool gentpool.pool.elon.tool.ElonDrawing
  - !include ../dr_science/agent.yaml

Screenshot of the error: Screenshot 2023-11-26 at 12 24 45 PM

Problem solved! I'll create a pull request