MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

TypeError: issubclass() arg 1 must be a class

Open luberion opened this issue 1 year ago • 4 comments

(base) dope@dope:~/Documents/metagpt$ python startup.py "Write a cli snake game" 2023-07-12 19:22:49.402 | INFO | metagpt.config:init:43 - Config loading done. 2023-07-12 19:22:49.402 | INFO | metagpt.config:init:49 - Set OPENAI_API_BASE in case of network issues Traceback (most recent call last): File "/home/dope/Documents/metagpt/startup.py", line 5, in from metagpt.software_company import SoftwareCompany File "/home/dope/Documents/metagpt/metagpt/software_company.py", line 11, in from metagpt.actions import BossRequirement File "/home/dope/Documents/metagpt/metagpt/actions/init.py", line 10, in from metagpt.actions.action import Action File "/home/dope/Documents/metagpt/metagpt/actions/action.py", line 15, in from metagpt.utils.common import OutputParser File "/home/dope/Documents/metagpt/metagpt/utils/common.py", line 15, in from langchain.schema import AgentAction, AgentFinish, OutputParserException File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/init.py", line 6, in from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/agents/init.py", line 2, in from langchain.agents.agent import ( File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/agents/agent.py", line 16, in from langchain.agents.tools import InvalidTool File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/agents/tools.py", line 8, in from langchain.tools.base import BaseTool, Tool, tool File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/tools/init.py", line 3, in from langchain.tools.arxiv.tool import ArxivQueryRun File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/tools/arxiv/tool.py", line 12, in from langchain.utilities.arxiv import ArxivAPIWrapper File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/utilities/init.py", line 3, in from langchain.utilities.apify import ApifyWrapper File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/utilities/apify.py", line 5, in from langchain.document_loaders import ApifyDatasetLoader File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/document_loaders/init.py", line 44, in from langchain.document_loaders.embaas import EmbaasBlobLoader, EmbaasLoader File "/home/dope/anaconda3/lib/python3.10/site-packages/langchain-0.0.230-py3.10.egg/langchain/document_loaders/embaas.py", line 54, in class BaseEmbaasLoader(BaseModel): File "pydantic/main.py", line 204, in pydantic.main.ModelMetaclass.new File "pydantic/fields.py", line 488, in pydantic.fields.ModelField.infer File "pydantic/fields.py", line 419, in pydantic.fields.ModelField.init File "pydantic/fields.py", line 539, in pydantic.fields.ModelField.prepare File "pydantic/fields.py", line 801, in pydantic.fields.ModelField.populate_validators File "pydantic/validators.py", line 696, in find_validators File "pydantic/validators.py", line 585, in pydantic.validators.make_typeddict_validator File "pydantic/annotated_types.py", line 35, in pydantic.annotated_types.create_model_from_typeddict File "pydantic/main.py", line 972, in pydantic.main.create_model File "pydantic/main.py", line 204, in pydantic.main.ModelMetaclass.new File "pydantic/fields.py", line 488, in pydantic.fields.ModelField.infer File "pydantic/fields.py", line 419, in pydantic.fields.ModelField.init File "pydantic/fields.py", line 534, in pydantic.fields.ModelField.prepare File "pydantic/fields.py", line 638, in pydantic.fields.ModelField._type_analysis File "/home/dope/anaconda3/lib/python3.10/typing.py", line 1158, in subclasscheck return issubclass(cls, self.origin) TypeError: issubclass() arg 1 must be a class

luberion avatar Jul 12 '23 11:07 luberion

Pull again and retry. I've removed langchain.

geekan avatar Jul 12 '23 16:07 geekan

Thanks! There still seemed to be an error.

My environment details: Created a conda environment named mgpt with python 3.9 installed cause it just dont work with the latest 3.10/11

GPT version: 3.5-turbo MAX_TOKENS: 1500 RPM: 10

Output: (mgpt) dope@dope:~/Documents/MetaGPT$ python startup.py "Create a cli snake game" 2023-07-13 02:46:38.155 | INFO | metagpt.config:init:43 - Config loading done. 2023-07-13 02:46:38.155 | INFO | metagpt.config:init:49 - Set OPENAI_API_BASE in case of network issues 2023-07-13 02:46:38.981 | INFO | metagpt.software_company:invest:39 - Investment: $3.0. 2023-07-13 02:46:38.982 | INFO | metagpt.roles.role:_act:155 - Alice(Product Manager): ready to WritePRD 2023-07-13 02:46:38.982 | WARNING | metagpt.actions.search_and_summarize:run:114 - Configure SERPAPI_API_KEY to unlock full feature

Original Requirements:

The boss wants you to create a command-line snake game.

Product Goals:

  • Create a fun and engaging snake game.
  • Provide a user-friendly command-line interface.
  • Ensure smooth and responsive gameplay.

User Stories:

  • As a player, I want to control the snake using arrow keys.
  • As a player, I want to see my score and the length of the snake on the screen.
  • As a player, I want the game to end if the snake hits the wall or itself.
  • As a player, I want the speed of the snake to increase as I score more points.
  • As a player, I want to be able to pause and resume the game.

Competitive Analysis:

  • Python Snake Game: A simple snake game implemented in Python with basic features.
  • CLI Snake: A command-line snake game with customizable settings and high scores.
  • Terminal Snake: A snake game with a retro-style interface and challenging gameplay.
  • Snake CLI: A snake game with power-ups and different game modes.
  • Snake Terminal: A snake game with colorful graphics and smooth controls.
  • Snake Game: A classic snake game with multiple levels and obstacles.
  • Snake Console: A snake game with customizable settings and leaderboard.

Competitive Quadrant Chart:

quadrantChart
    title Reach and engagement of snake games
    x-axis Low Reach --> High Reach
    y-axis Low Engagement --> High Engagement
    quadrant-1 Simple and basic
    quadrant-2 Customizable and feature-rich
    quadrant-3 Retro-style and challenging
    quadrant-4 Colorful and smooth
    "Python Snake Game": [0.2, 0.3]
    "CLI Snake": [0.4, 0.5]
    "Terminal Snake": [0.3, 0.6]
    "Snake CLI": [0.5, 0.7]
    "Snake Terminal": [0.6, 0.8]
    "Snake Game": [0.7, 0.4]
    "Snake Console": [0.5, 0.6]
    "Our Target Product": [0.6, 0.7]

Requirement Analysis:

The product should be a command-line snake game with smooth controls, responsive gameplay, and a user-friendly interface. It should have basic features such as controlling the snake with arrow keys, displaying the score and snake length, and ending the game if the snake hits the wall or itself. The game should also increase the speed of the snake as the player scores more points and allow pausing and resuming the game.

Requirement Pool:

[
    ("End game if snake hits the wall or itself", "P0"),
    ("Display score and snake length on the screen", "P1"),
    ("Increase snake speed as the player scores more points", "P1"),
    ("Allow pausing and resuming the game", "P2")
]

Anything UNCLEAR:

There are no unclear points. Warning: gpt-3.5-turbo may change over time. Returning num tokens assuming gpt-3.5-turbo-0301. 2023-07-13 02:46:54.571 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.003 | Max budget: $3.000 | Current cost: $0.003, prompt_tokens=800, completion_tokens=622

Original Requirements:

The boss wants us to create a command-line interface (CLI) snake game.

Product Goals:

  • Create a fun and engaging snake game that can be played in the command line.
  • Provide a smooth and responsive user experience.
  • Implement various game modes and difficulty levels to cater to different players.

User Stories:

  • As a user, I want to be able to control the snake using the arrow keys.
  • As a user, I want to see my score and the length of the snake displayed on the screen.
  • As a user, I want to be able to pause and resume the game at any time.
  • As a user, I want to be able to choose different game modes and difficulty levels.
  • As a user, I want to be able to restart the game after losing.

Competitive Analysis:

  • Python Snake Game: A simple snake game implemented in Python with basic features.
  • CLI Snake: A command-line snake game with additional power-ups and obstacles.
  • Terminal Snake: A snake game with a minimalist design and smooth controls.
  • Snake CLI: A snake game with customizable colors and different game modes.
  • Retro Snake: A classic snake game with retro graphics and sound effects.
  • Snake Terminal: A snake game with a customizable play area and adjustable speed.
  • ASCII Snake: A snake game with ASCII art graphics and multiple difficulty levels.

Competitive Quadrant Chart:

quadrantChart
    title Reach and engagement of snake games
    x-axis Low Reach --> High Reach
    y-axis Low Engagement --> High Engagement
    quadrant-1 We should expand
    quadrant-2 Need to promote
    quadrant-3 Re-evaluate
    quadrant-4 May be improved
    "Python Snake Game": [0.3, 0.6]
    "CLI Snake": [0.45, 0.23]
    "Terminal Snake": [0.57, 0.69]
    "Snake CLI": [0.78, 0.34]
    "Retro Snake": [0.40, 0.34]
    "Snake Terminal": [0.35, 0.78]
    "ASCII Snake": [0.6, 0.7]
    "Our Target Product": [0.5, 0.6]

Requirement Analysis:

The product should be a command-line snake game with smooth controls, multiple game modes, and difficulty levels. It should display the score and length of the snake on the screen. The game should allow the user to pause and resume at any time and provide the option to restart after losing. The design should be simple and intuitive, providing a smooth and responsive user experience.

Requirement Pool:

[
    ("End game condition when the snake collides with the wall or itself", "P0"),
    ("Implement different game modes (e.g., classic, timed, endless)", "P1"),
    ("Implement different difficulty levels (e.g., easy, medium, hard)", "P1"),
    ("Display the current score and length of the snake on the screen", "P2"),
    ("Allow the user to pause and resume the game at any time", "P2")
]

Anything UNCLEAR:

There are no unclear points. Warning: gpt-3.5-turbo may change over time. Returning num tokens assuming gpt-3.5-turbo-0301. 2023-07-13 02:47:12.651 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.006 | Max budget: $3.000 | Current cost: $0.003, prompt_tokens=800, completion_tokens=674 Traceback (most recent call last): File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/site-packages/tenacity/_asyncio.py", line 50, in call result = await fn(*args, **kwargs) File "/home/dope/Documents/MetaGPT/metagpt/actions/action.py", line 60, in _aask_v1 instruct_content = output_class(**parsed_data) File "pydantic/main.py", line 331, in pydantic.main.BaseModel.init pydantic.error_wrappers.ValidationError: 3 validation errors for prd Product Goals value is not a valid list (type=type_error.list) User Stories value is not a valid list (type=type_error.list) Competitive Analysis value is not a valid list (type=type_error.list)

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

Traceback (most recent call last): File "/home/dope/Documents/MetaGPT/startup.py", line 29, in fire.Fire(main) File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/site-packages/fire-0.5.0-py3.9.egg/fire/core.py", line 141, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/site-packages/fire-0.5.0-py3.9.egg/fire/core.py", line 475, in _Fire component, remaining_args = _CallAndUpdateTrace( File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/site-packages/fire-0.5.0-py3.9.egg/fire/core.py", line 691, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/home/dope/Documents/MetaGPT/startup.py", line 25, in main asyncio.run(startup(idea, investment, n_round)) File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete return future.result() File "/home/dope/Documents/MetaGPT/startup.py", line 15, in startup await company.run(n_round=n_round) File "/home/dope/Documents/MetaGPT/metagpt/software_company.py", line 60, in run await self.environment.run() File "/home/dope/Documents/MetaGPT/metagpt/environment.py", line 64, in run await asyncio.gather(*futures) File "/home/dope/Documents/MetaGPT/metagpt/roles/role.py", line 229, in run rsp = await self._react() File "/home/dope/Documents/MetaGPT/metagpt/roles/role.py", line 200, in _react return await self._act() File "/home/dope/Documents/MetaGPT/metagpt/roles/role.py", line 156, in _act response = await self._rc.todo.run(self._rc.important_memory) File "/home/dope/Documents/MetaGPT/metagpt/actions/write_prd.py", line 138, in run prd = await self._aask_v1(prompt, "prd", OUTPUT_MAPPING) File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped return await fn(*args, **kwargs) File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/site-packages/tenacity/_asyncio.py", line 47, in call do = self.iter(retry_state=retry_state) File "/home/dope/anaconda3/envs/mgpt/lib/python3.9/site-packages/tenacity/init.py", line 326, in iter raise retry_exc from fut.exception() tenacity.RetryError: RetryError[<Future at 0x7f1f27e30400 state=finished raised ValidationError>]

luberion avatar Jul 12 '23 18:07 luberion

This problem stems from the fact that gpt-3.5-turbo instruction follow is not stable enough (the success rate is about 30% visually, but it changes with the demand), gpt-4 will be much more stable (almost 100%)

we're working in progress to improve the succ rate of gpt-3.5-turbo, but it still need time. https://github.com/geekan/MetaGPT/pull/37

meanwhile, another issue is we cannot call browser / browser core in the docker and the mermaid graph is not generating @voidking

geekan avatar Jul 13 '23 01:07 geekan

https://github.com/geekan/MetaGPT/pull/41 and https://github.com/geekan/MetaGPT/pull/43 almost fix this issue. pull & retry.

geekan avatar Jul 13 '23 06:07 geekan