geekan / MetaGPT

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

Can't run with openai model:gpt-4-1106-preview #533

Open pzhang25 opened 9 months ago

pzhang25 commented 9 months ago

python startup.py --idea "write a cli blackjack game" 2023-12-05 20:27:03.903 | INFO | metagpt.const:get_project_root:21 - PROJECT_ROOT set to /Users/pzhang/ai2/MetaGPT 2023-12-05 20:27:04.205 | INFO | metagpt.config:init:44 - Config loading done. 2023-12-05 20:27:10.301 | INFO | metagpt.team:invest:39 - Investment: $3.0. 2023-12-05 20:27:10.303 | INFO | metagpt.roles.role:_act:212 - Alice(Product Manager): ready to WritePRD [CONTENT] { "Original Requirements": "Write a CLI blackjack game", "Product Goals": [ "Create an engaging and easy-to-use CLI blackjack game", "Ensure the game rules are consistent with standard blackjack", "Provide a clear and intuitive user interface" ], "User Stories": [ "As a user, I want to easily start a game of blackjack so that I can play without hassle.", "As a player, I want to see my current hand and the dealer's visible card to make informed decisions.", "As a gaming enthusiast, I want the option to hit or stand so that I can strategize my gameplay.", "As a casual player, I want to be informed when I win, lose, or draw so that I understand the outcome of the game.", "As a user, I want to be able to quit the game at any time so that I can stop playing whenever I choose." ], "Competitive Analysis": [ "Competitor A offers a variety of card games but lacks a user-friendly interface.", "Competitor B has a strong user base but the game rules do not align with standard blackjack.", "Competitor C provides a good user experience but the game lacks features like betting.", "Competitor D has a visually appealing interface but is not accessible via CLI.", "Competitor E offers a CLI blackjack game but it has frequent bugs and stability issues.", "Competitor F has a well-implemented game logic but lacks documentation and support.", "Competitor G is popular for its multiplayer feature but does not offer a single-player mode." ], "Competitive Quadrant Chart": "quadrantChart\n title Competitive Analysis of CLI Blackjack Games\n x-axis Less Features --> More Features\n y-axis Lower Usability --> Higher Usability\n quadrant-1 We should expand\n quadrant-2 Need to promote\n quadrant-3 Re-evaluate\n quadrant-4 May be improved\n \"Competitor A\": [0.2, 0.3]\n \"Competitor B\": [0.4, 0.2]\n \"Competitor C\": [0.6, 0.7]\n \"Competitor D\": [0.8, 0.4]\n \"Competitor E\": [0.3, 0.5]\n \"Competitor F\": [0.5, 0.6]\n \"Competitor G\": [0.7, 0.8]\n \"Our Target Product\": [0.9, 0.9]", "Requirement Analysis": "The game should be simple, engaging, and adhere to standard blackjack rules. The user interface must be clear and intuitive, allowing for easy gameplay.", "Requirement Pool": [ ["Implement basic blackjack game logic", "P0"], ["Create a simple and intuitive CLI interface", "P0"], ["Allow the user to start a new game or quit", "P1"], ["Implement the options to hit or stand during gameplay", "P1"], ["Display game outcome messages (win/lose/draw)", "P1"] ], "UI Design draft": "The CLI interface will display the user's hand, dealer's visible card, and options to hit or stand. It will have a simple text-based layout with clear instructions at the top, the game state in the middle, and the available commands at the bottom.", "Anything UNCLEAR": "The requirements are clear. However, the complexity of the game logic and potential edge cases in blackjack rules need to be further defined." } [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-05 20:27:58.217 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.032 | Max budget: $3.000 | Current cost: $0.032, prompt_tokens: 895, completion_tokens: 761 2023-12-05 20:27:58.223 | INFO | metagpt.roles.role:_act:212 - Bob(Architect): ready to WriteDesign [CONTENT] { "Implementation approach": "To implement the CLI blackjack game, we will use Python due to its simplicity and the rich ecosystem of open-source libraries. We will leverage the 'cmd' module for creating an interactive command-line interface. The game logic will be encapsulated in classes that handle the game state, player actions, and the dealer's behavior. We will use 'unittest' for testing our game logic and ensuring that all edge cases are covered. The application will be designed to be extensible, allowing for future features such as betting or multiplayer functionality.", "Python package name": "cli_blackjack", "File list": ["main.py", "game.py", "player.py", "dealer.py", "card.py", "deck.py", "ui.py", "constants.py", "test.py"], "Data structures and interface definitions": ' classDiagram class Card { -suit: str -rank: str +init(suit: str, rank: str) +value() -> int } class Deck { -cards: list[Card] +init() +shuffle() -> None +deal_card() -> Card } class Hand { -cards: list[Card] +init() +add_card(card: Card) -> None +value() -> int +is_busted() -> bool +str() -> str } class Player { -hand: Hand +init() +hit(deck: Deck) -> None +stand() -> None +is_busted() -> bool +str() -> str } class Dealer { -hand: Hand +init() +reveal_card() -> None +play(deck: Deck) -> None +str() -> str } class Game { -player: Player -dealer: Dealer -deck: Deck -ui: UI +init(ui: UI) +start() -> None +evaluate_game() -> str } class UI { +start_game_prompt() -> None +show_hands(player_hand: Hand, dealer_hand: Hand) -> None +show_result(result: str) -> None +hit_or_stand_prompt() -> str +quit_prompt() -> bool } Deck "1" -- "" Card : contains Hand "1" -- "" Card : contains Player "1" -- "1" Hand : has Dealer "1" -- "1" Hand : has Game "1" -- "1" Player : has Game "1" -- "1" Dealer : has Game "1" -- "1" Deck : has Game "1" -- "1" UI : uses ', "Program call flow": ' sequenceDiagram participant Main participant UI participant Game participant Player participant Dealer participant Deck Main->>UI: start_game_prompt() UI->>Game: start() Game->>Deck: shuffle() Game->>Player: hit(deck) Game->>Dealer: hit(deck) Game->>UI: show_hands(player_hand, dealer_hand) loop Game Loop UI->>UI: hit_or_stand_prompt() alt Hit UI->>Player: hit(deck) Player->>Game: evaluate_game() Game->>UI: show_result(result) else Stand UI->>Dealer: play(deck) Dealer->>Game: evaluate_game() Game->>UI: show_result(result) end end UI->>Main: quit_prompt() Main->>Game: end game ', "Anything UNCLEAR": "The requirement is clear. The implementation details for handling edge cases in blackjack rules, such as splitting pairs, insurance, and doubling down, are not specified and will not be included in the initial version. These can be added in future iterations if required." } [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-05 20:29:03.383 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.071 | Max budget: $3.000 | Current cost: $0.039, prompt_tokens: 1276, completion_tokens: 879 2023-12-05 20:29:03.410 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/competitive_analysis.pdf.. 2023-12-05 20:29:07.448 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:07.450 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/competitive_analysis.svg.. 2023-12-05 20:29:09.376 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:09.380 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/competitive_analysis.png.. 2023-12-05 20:29:11.449 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:11.451 | INFO | metagpt.actions.design_api:_save_prd:175 - Saving PRD to /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/docs/prd.md 2023-12-05 20:29:11.458 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/data_api_design.pdf.. 2023-12-05 20:29:13.783 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:13.785 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/data_api_design.svg.. 2023-12-05 20:29:16.000 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:16.003 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/data_api_design.png.. 2023-12-05 20:29:18.324 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:18.332 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/seq_flow.pdf.. 2023-12-05 20:29:20.492 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:20.495 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/seq_flow.svg.. 2023-12-05 20:29:22.529 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:22.531 | INFO | metagpt.utils.mermaid:mermaid_to_file:46 - Generating /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/resources/seq_flow.png.. 2023-12-05 20:29:25.144 | INFO | metagpt.utils.mermaid:mermaid_to_file:70 - Generating single mermaid chart

2023-12-05 20:29:25.149 | INFO | metagpt.actions.design_api:_save_system_design:188 - Saving System Designs to /Users/pzhang/ai2/MetaGPT/workspace/cli_blackjack/docs/system_design.md 2023-12-05 20:29:25.155 | INFO | metagpt.roles.role:_act:212 - Eve(Project Manager): ready to WriteTasks [CONTENT] { "Required Python third-party packages": "requirements.txt\npytest==6.2.2\n", "Required Other language third-party packages": "requirements.txt\nNo third-party packages required.\n", "Full API spec": """ openapi: 3.0.0 info: title: CLI Blackjack Game API version: "1.0.0" paths: {} components: {} """, "Logic Analysis": [ ["constants.py", "Define game constants"], ["card.py", "Class Card"], ["deck.py", "Class Deck depends on card.py"], ["hand.py", "Class Hand depends on card.py"], ["player.py", "Class Player depends on hand.py"], ["dealer.py", "Class Dealer depends on hand.py"], ["ui.py", "Class UI"], ["game.py", "Class Game depends on player.py, dealer.py, deck.py, ui.py"], ["main.py", "Main entry point depends on game.py"], ["test.py", "Test cases for all classes"] ], "Task list": [ "constants.py", "card.py", "deck.py", "hand.py", "player.py", "dealer.py", "ui.py", "game.py", "main.py", "test.py" ], "Shared Knowledge": """ The 'constants.py' file will contain all the game constants such as suits, ranks, and blackjack values which will be used across various modules. The 'card.py' module will define the Card class and should be implemented with a method to determine the card's value. The 'deck.py' module will use the Card class from 'card.py' and should provide methods to shuffle and deal cards. The 'hand.py' module will use the Card class from 'card.py' and should provide methods to add cards and calculate the value of a hand. The 'player.py' and 'dealer.py' modules will use the Hand class from 'hand.py' for their respective hand management. The 'ui.py' module will handle all user interactions and should be designed to be easily extendable for future features. The 'game.py' module will be the core of the game, coordinating between the UI, Player, Dealer, and Deck classes. The 'main.py' module will be the entry point of the application and will initialize and start the game using the Game class from 'game.py'. The 'test.py' module will contain all the unit tests for the classes and methods defined in the project. """, "Anything UNCLEAR": "The main entry point should be defined in 'main.py' and should handle the initialization and starting of the game. The integration of the UI with the game logic needs to be clearly defined. The process of initializing third-party libraries, if any, should be documented." } [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-05 20:30:05.342 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.103 | Max budget: $3.000 | Current cost: $0.032, prompt_tokens: 1403, completion_tokens: 613 [CONTENT] { "Required Python third-party packages": "requirements.txt\npytest==6.2.2\n", "Required Other language third-party packages": "requirements.txt\nNo third-party packages required\n", "Full API spec": """ openapi: 3.0.0 info: title: CLI Blackjack Game API version: "1.0.0" paths: /start: get: summary: Start a new game of blackjack responses: '200': description: Game started successfully /hit: post: summary: Player chooses to hit and get another card responses: '200': description: Card dealt to player /stand: post: summary: Player chooses to stand and end their turn responses: '200': description: Player's turn ended /dealer_play: post: summary: Dealer plays their turn responses: '200': description: Dealer's turn played /game_status: get: summary: Get the current status of the game responses: '200': description: Returns the current game status """, "Logic Analysis": [ ["card.py", "Card class with suit, rank, and value methods"], ["deck.py", "Deck class with cards list, shuffle, and deal_card methods"], ["hand.py", "Hand class with cards list, add_card, value, is_busted, and str methods"], ["player.py", "Player class with hand, hit, stand, is_busted, and str methods"], ["dealer.py", "Dealer class with hand, reveal_card, play, and str methods"], ["game.py", "Game class with player, dealer, deck, ui, start, and evaluate_game methods"], ["ui.py", "UI class with start_game_prompt, show_hands, show_result, hit_or_stand_prompt, and quit_prompt methods"], ["main.py", "Main entry point, orchestrates the game flow"], ["test.py", "Test cases for all game logic"] ], "Task list": [ "card.py", "deck.py", "hand.py", "player.py", "dealer.py", "ui.py", "game.py", "main.py", "test.py" ], "Shared Knowledge": """ The 'constants.py' file should contain all the constant values such as suits, ranks, and blackjack values for cards. This file should be created and agreed upon before implementing the 'Card', 'Deck', and 'Hand' classes as they will rely on these constants. """, "Anything UNCLEAR": "The main entry point should be defined in 'main.py' and should properly initialize the game by creating instances of the Game and UI classes and starting the game loop. Make sure to initialize any third-party libraries if needed." } [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-05 20:30:50.316 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.136 | Max budget: $3.000 | Current cost: $0.033, prompt_tokens: 1403, completion_tokens: 628 [CONTENT] { "Required Python third-party packages": "requirements.txt\npytest==6.2.2\n", "Required Other language third-party packages": "requirements.txt\nNo third-party packages required.\n", "Full API spec": """ openapi: 3.0.0 info: title: CLI Blackjack Game API version: "1.0.0" paths: {} components: {} """, "Logic Analysis": [ ["card.py", "Card class with value method"], ["deck.py", "Deck class with shuffle and deal_card methods"], ["hand.py", "Hand class with add_card, value, is_busted, and str methods"], ["player.py", "Player class with hit, stand, is_busted, and str methods"], ["dealer.py", "Dealer class with reveal_card, play, and str methods"], ["game.py", "Game class with start and evaluate_game methods"], ["ui.py", "UI class with start_game_prompt, show_hands, show_result, hit_or_stand_prompt, and quit_prompt methods"], ["main.py", "Main entry point, orchestrates the game flow"], ["test.py", "Test cases for all game logic"] ], "Task list": [ "card.py", "deck.py", "hand.py", "player.py", "dealer.py", "ui.py", "game.py", "main.py", "test.py" ], "Shared Knowledge": """ The 'constants.py' file should contain all the constant values like suits, ranks, and blackjack values which will be used across different modules of the game. """, "Anything UNCLEAR": "The main entry point should be defined in 'main.py' and should handle the initialization and termination of the game. Make sure to initialize any third-party libraries if used." } [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-05 20:31:19.760 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.163 | Max budget: $3.000 | Current cost: $0.026, prompt_tokens: 1403, completion_tokens: 411 Traceback (most recent call last): File "/Users/pzhang/ai2/env3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 50, in call result = await fn(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/MetaGPT/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: 2 validation errors for task Required Python third-party packages value is not a valid list (type=type_error.list) Required Other language third-party packages 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 "/Users/pzhang/ai2/MetaGPT/startup.py", line 72, in fire.Fire(main) File "/Users/pzhang/ai2/env3.11/lib/python3.11/site-packages/fire/core.py", line 141, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/env3.11/lib/python3.11/site-packages/fire/core.py", line 466, in _Fire component, remaining_args = _CallAndUpdateTrace( ^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/env3.11/lib/python3.11/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace component = fn(*varargs, kwargs) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/MetaGPT/startup.py", line 68, in main asyncio.run(startup(idea, investment, n_round, code_review, run_tests, implement)) File "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/MetaGPT/startup.py", line 47, in startup await company.run(n_round=n_round) File "/Users/pzhang/ai2/MetaGPT/metagpt/team.py", line 60, in run await self.environment.run() File "/Users/pzhang/ai2/MetaGPT/metagpt/environment.py", line 67, in run await asyncio.gather(futures) File "/Users/pzhang/ai2/MetaGPT/metagpt/roles/role.py", line 324, in run rsp = await self.react() ^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/MetaGPT/metagpt/roles/role.py", line 283, in react rsp = await self._react() ^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/MetaGPT/metagpt/roles/role.py", line 264, in _react rsp = await self._act() ^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/MetaGPT/metagpt/roles/role.py", line 213, in _act response = await self._rc.todo.run(self._rc.important_memory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/MetaGPT/metagpt/actions/project_management.py", line 184, in run rsp = await self._aask_v1(prompt, "task", OUTPUT_MAPPING, format=format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/env3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped return await fn(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/env3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 47, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/pzhang/ai2/env3.11/lib/python3.11/site-packages/tenacity/init.py", line 326, in iter raise retry_exc from fut.exception() tenacity.RetryError: RetryError[<Future at 0x11ae45f90 state=finished raised ValidationError>]

Undertone0809 commented 9 months ago

current openai sdk version can not support gpt-4-turbo. We should upgrade openai>=1.0.0

geekan commented 9 months ago

519 upgrade openai version to 1.6.0 @Undertone0809

geekan commented 9 months ago

Could you try latest main branch code? @pzhang25