geekan / MetaGPT

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
https://deepwisdom.ai/
MIT License
45.33k stars 5.39k forks source link

tenacity.RetryError: RetryError[<Future at 0x158f5c4c0 state=finished raised ValidationError>] #527

Closed lemon-little closed 11 months ago

lemon-little commented 11 months ago

python metagpt_openapi_test.py 2023-12-05 14:21:49.090 | INFO | metagpt.const:get_project_root:27 - PROJECT_ROOT set to current working directory: /Users/liuchenyang/github-project/qwen-api 2023-12-05 14:21:49.176 | INFO | metagpt.config:init:44 - Config loading done. 2023-12-05 14:21:50.428 | INFO | metagpt.team:invest:39 - Investment: $3.0. 2023-12-05 14:21:50.428 | INFO | metagpt.roles.role:_act:212 - Alice(Product Manager): ready to WritePRD

Original Requirements

Write a simple Python-based version of the classic game Snake.

Product Goals

[
    "Create a simple, playable version of the classic game Snake.",
    "Ensure the game is responsive and smooth.",
    "Provide basic gameplay features such as movement, collision detection, and score tracking."
]

User Stories

[
    "As a player, I want to be able to control the snake using arrow keys so that I can move it around the screen.",
    "As a player, I want the snake to grow in length when it eats food so that the game becomes more challenging over time.",
    "As a player, I want the game to end if the snake collides with itself or the wall so that there is a clear win/loss condition.",
    "As a player, I want to see my current score displayed on the screen so that I can track my progress.",
    "As a player, I want the ability to restart the game after it has ended so that I can play again immediately."
]

Competitive Analysis

[
    "Python Snake Game: A basic implementation of Snake in Python. Provides limited customization options and no online multiplayer functionality.",
    "Snake Game Online: A web-based version of Snake with various game modes and online leaderboards. Requires an internet connection to play.",
    "Classic Arcade Games: An app that includes multiple classic arcade games, including Snake. Offers various customization options but requires payment to access all features.",
    "Slither.io: A popular online multiplayer version of Snake. Provides a large map and various power-ups but can be overwhelming for new players.",
    "Khan Academy Snake Game: An educational version of Snake designed for learning programming concepts. Limited gameplay features compared to other versions.",
    "Snek: A modernized version of Snake with colorful graphics and fast-paced gameplay. Offers various game modes but can be difficult for casual players.",
    "Apple's built-in version of Snake: A simple, pre-installed version of Snake on Apple devices. No customization options or additional features."
]

Competitive Quadrant Chart

quadrantChart
    title Reach and engagement of campaigns
    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
    "Campaign: A": [0.3, 0.6]
    "Campaign B": [0.45, 0.23]
    "Campaign C": [0.57, 0.69]
    "Campaign D": [0.78, 0.34]
    "Campaign E": [0.40, 0.34]
    "Campaign F": [0.35, 0.78]
    "Our Target Product": [0.6, 0.7]

Requirement Analysis

The product should be a simple, playable version of the classic game Snake. The game should have smooth, responsive gameplay with basic features such as movement, collision detection, and score tracking. The user should be able to control the snake using arrow keys and eat food to increase its length. The game should end if the snake collide Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-05 14:22:30.466 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.066 | Max budget: $3.000 | Current cost: $0.066, prompt_tokens: 849, completion_tokens: 681

Original Requirements

Create a simple and engaging Python Snake Game with increasing difficulty levels and user-friendly interface.

Product Goals

[
    "Create an easy-to-use interface for the game.",
    "Develop a game that gradually increases in difficulty as the player progresses through levels.",
    "Provide an enjoyable gaming experience to users."
]

User Stories

[
    "As a user, I want to be able to start playing the game quickly without having to go through complex instructions or tutorials.",
    "As a user, I want the game to get progressively harder so that it remains challenging and keeps me engaged.",
    "As a user, I want to be able to see my score and progress throughout the game.",
    "As a user, I want the game to have a visually appealing interface that is easy on the eyes.",
    "As a user, I want the game to be responsive and not lag while playing."
]

Competitive Analysis

[
    "Python Snake Game: A basic implementation of the classic snake game written in Python. The game lacks any additional features and has a very minimalistic design.",
    "Snake.io: An online version of the snake game that allows players to compete against each other. It has an attractive interface but can be laggy at times.",
    "Slither.io: Another popular online multiplayer snake game that offers different skins and power-ups. However, the gameplay can be overwhelming for some players.",
    "SnakeAI: An open-source implementation of the snake game that uses AI algorithms to control the movements of the snake. It is more geared towards developers rather than casual gamers.",
    "Kivy Snake Game: A mobile-friendly implementation of the snake game using Kivy framework. It has a clean interface but lacks advanced features.",
    "Snek: A modern take on the classic snake game with vibrant graphics and dynamic gameplay. However, it can be difficult for beginners to pick up.",
    "Classic Arcade Snake: A browser-based version of the snake game that stays true to the original design. It does not offer any new features or challenges."
]

Competitive Quadrant Chart

quadrantChart
    title Reach and engagement of campaigns
    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
    "Campaign: A": [0.3, 0.6]
    "Campaign B": [0.45, 0.23]
    "Campaign C": [0.57, 0.69]
    "Campaign D": [0.78, 0.34]
    "Campaign E": [0.40, 0.34]
    "Campaign F": [0.35, 0.78]
    "Our Target Product": [0.5, 0.6]

Requirement Analysis

The product should be a simple yet engaging Python Snake Game with increasing difficulty levels and user-friendly interface. The game should have an intuitive design that allows users to start playing right away without having to navigate through complicated instructions or tutorials. The game should also gradually increase in difficulty as the player progresses through levels to keep them engaged and challenged. Additionally, the game should have a visually appealing interface that is easy on the eyes and responsive while playing.

Requirement Pool

[
    ["Start playing
Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613.
2023-12-05 14:23:07.192 | INFO     | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.135 | Max budget: $3.000 | Current cost: $0.069, prompt_tokens: 849, completion_tokens: 719
## Original Requirements
Write a贪吃蛇小游戏

## Product Goals
```python
[
    "Create an engaging and easy-to-play game for users",
    "Provide a competitive leaderboard system to encourage replayability",
    "Ensure the game is compatible with multiple platforms, including mobile devices"
]

User Stories

[
    "As a user, I want to be able to control my snake using arrow keys or touch controls so that I can navigate through the game easily.",
    "As a user, I want to see food appear on the board at random locations so that I have something to eat and grow longer.",
    "As a user, I want to avoid hitting the walls or my own tail so that I don't lose the game.",
    "As a user, I want to earn points for each piece of food I eat so that I can compete with other players on the leaderboard.",
    "As a user, I want to view the leaderboard to see how well I rank compared to other players."
]

Competitive Analysis

[
    "Python Snake Game: This is a basic implementation of the classic snake game written in Python. The graphics are simple and not visually appealing.",
    "Snake.io: This is a popular mobile game that offers a modern twist on the classic snake game. It has colorful graphics, smooth gameplay, and a global leaderboard.",
    "Slither.io: Another popular mobile game that features multiplayer gameplay where players can compete against each other. The game has bright and colorful graphics, but the controls can be difficult to master.",
    "Classic Snake Game: This is a browser-based version of the classic snake game. The graphics are minimalistic, and the gameplay is straightforward.",
    "Snake VS Block: A mobile game that adds a new twist to the classic snake game by allowing players to break blocks and collect power-ups. The game has colorful graphics and fun gameplay.",
    "NBA Snakes: A unique spin on the classic snake game that features NBA players as snakes. The game has cartoonish graphics and is a fun way to pass the time.",
    "Snake Game 3D: A 3D version of the classic snake game that features realistic graphics and smooth gameplay. The game is challenging and requires good reflexes."
]

Competitive Quadrant Chart

quadrantChart
    title Reach and engagement of campaigns
    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
    "Campaign: A": [0.3, 0.6]
    "Campaign B": [0.45, 0.23]
    "Campaign C": [0.57, 0.69]
    "Campaign D": [0.78, 0.34]
    "Campaign E": [0.40, 0.34]
    "Campaign F": [0.35, 0.78]
    "Our Target Product": [0.5, 0.6]

Requirement Analysis

The product should be a贪吃蛇小游戏 that is engaging and easy to play for users. The game should include elements such as food to eat, walls and tails to avoid, and a scoring system to track progress. Additionally, the game should include a leaderboard system to encourage replayability and competition among users.

Requirement Pool


[
    ["Include a leaderboard system", "P0"],
    ["Implement smooth gameplay and controls", "P1"],
    ["Support multiple platforms, including mobile devices", "P1"],
    ["Add colorful and visually appealing graphics
Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613.
2023-12-05 14:23:57.172 | INFO     | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.207 | Max budget: $3.000 | Current cost: $0.073, prompt_tokens: 849, completion_tokens: 784
Traceback (most recent call last):
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/tenacity/_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/actions/action.py", line 84, in _aask_v1
    instruct_content = output_class(**parsed_data)
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 3 validation errors for prd
Requirement Pool
  value is not a valid list (type=type_error.list)
UI Design draft
  field required (type=value_error.missing)
Anything UNCLEAR
  field required (type=value_error.missing)

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

Traceback (most recent call last):
  File "/Users/liuchenyang/github-project/qwen-api/metagpt_openapi_test.py", line 33, in <module>
    asyncio.run(startup(idea="写一个贪吃蛇小游戏"))
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/liuchenyang/github-project/qwen-api/metagpt_openapi_test.py", line 29, in startup
    await company.run(n_round=5)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/team.py", line 60, in run
    await self.environment.run()
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/environment.py", line 67, in run
    await asyncio.gather(*futures)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/roles/role.py", line 324, in run
    rsp = await self.react()
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/roles/role.py", line 283, in react
    rsp = await self._react()
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/roles/role.py", line 264, in _react
    rsp = await self._act()
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/roles/role.py", line 213, in _act
    response = await self._rc.todo.run(self._rc.important_memory)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/metagpt/actions/write_prd.py", line 240, in run
    prd = await self._aask_v1(prompt, "prd", OUTPUT_MAPPING, format=format)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/tenacity/_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
  File "/Users/liuchenyang/miniconda3/envs/MetaGPT/lib/python3.9/site-packages/tenacity/__init__.py", line 326, in iter
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x158f5c4c0 state=finished raised ValidationError>]
jackq007 commented 11 months ago

我遇到了同样的问题,请问你的问题解决了没

lemon-little commented 11 months ago

我遇到了同样的问题,请问你的问题解决了没

这是由于LLM所生成的回复不满足程序所定义的解析程序所造成的错误,我使用github最新版本的metagpt解决了该问题,您也可以更换更强大的LLM解决这个问题