MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

ERROR | metagpt.utils.common:parse_code:192 - ```.*?\s+(.*?)``` not match following text:

Open furyxi opened this issue 2 years ago • 10 comments
trafficstars

Hello everyone!

having discovered metagpt and its code, I tried to make it function with a local llm. for the moment wizardlm-70b gives good results overall, with the sole fact that at one point I find myself faced with this error: "ERROR | metagpt.utils.common:parse_code:192 - .* ?\s+(.*?) not match following text: 2023-09-21 14:22:59.416 | ERROR | metagpt.utils.common:parse_code:193 -

Code Review:

  1. Check 0: Is the code implemented as per the requirements? Yes, based on the provided context and code, it appears that the code is being implemented according to the specified requirements. The game logic module (game_logic.py) seems to be responsible for implementing the core game mechanics such as Snake's movement, collision detection, Food generation, and consumption.

  2. Check 1: Are there any issues with the code logic? There is no obvious issue in the provided context that suggests a problem with the code logic. However, without having access to the actual implementation of game_logic.py, it's hard to provide more specific feedback on this point.

  3. Check 2: Does the existing code follow the "Data structures and interface definitions"? The data structures and interfaces defined in the provided Mermaid diagram seem to be followed by the code as per the context. The classes Game, Snake, and Food are used in the same way they were defined, which is a good sign that the existing code adheres to these definitions.

  4. Check 3: Is there a function in the code that is omitted or not fully implemented that needs to be implemented? Without having access to the actual implementation of game_logic.py, it's hard to provide more specific feedback on this point. However, based on the provided context, it seems like all necessary functions are present and accounted for.

  5. Check 4: Does the code have unnecessary or lack dependencies? The code appears to be using required third-party packages such as Pygame, Ctypes, Pyobjus, and Curses which is a good sign that it doesn't have any unnecessary dependencies. However, without having access to the actual implementation of game_logic.py, it's hard to provide more specific feedback on this point.

Rewrite Code: game/game_logic.py

Please note that due to the lack of the actual"

Is there a way to get around this error even by getting my hands dirty in the code? waiting for a possible clue. thanks in advance

furyxi avatar Sep 21 '23 12:09 furyxi

Could you please post more stacks?

geekan avatar Sep 29 '23 11:09 geekan

I have encountered the same issue. After using GitHub Codespaces, I modified the API key and URL in the config. Then, following the tutorial, I ran "python startup.py --idea "write a cli blackjack game."" However, I encountered the same error, and there is no code in the workspace, only blank files. The complete stack trace is as follows:

@WQL782795 ➜ /workspaces/MetaGPT (v0.4-release) $ python startup.py --idea "write a cli blackjack game" 2023-12-20 05:20:18.131 | INFO | metagpt.const:get_project_root:21 - PROJECT_ROOT set to /workspaces/MetaGPT 2023-12-20 05:20:18.202 | INFO | metagpt.config:init:44 - Config loading done. 2023-12-20 05:20:20.494 | INFO | metagpt.team:invest:39 - Investment: $3.0. 2023-12-20 05:20:20.495 | INFO | metagpt.roles.role:_act:212 - Alice(Product Manager): ready to WritePRD [CONTENT] { "Original Requirements": "Create a command-line interface (CLI) blackjack game", "Product Goals": ["Create a user-friendly CLI blackjack game", "Ensure the game rules are clear and easy to understand", "Ensure the game runs smoothly without any bugs"], "User Stories": ["As a user, I want to be able to start a new game easily", "As a user, I want clear instructions on how to play the game", "As a user, I want to be able to see my current score", "As a user, I want to be able to quit the game at any time", "As a user, I want the game to be fair and random"], "Competitive Analysis": ["Product A: A CLI blackjack game with simple interface but lacks clear instructions", "Product B: A CLI blackjack game with clear instructions but has bugs", "Product C: A CLI blackjack game with good user interface but lacks randomness", "Product D: A CLI blackjack game with randomness but lacks user-friendly interface", "Product E: A CLI blackjack game with clear instructions and user-friendly interface but has bugs"], "Competitive Quadrant Chart": "quadrantChart\n title Reach and engagement of campaigns\n x-axis Low Reach --> High Reach\n y-axis Low Engagement --> High Engagement\n quadrant-1 We should expand\n quadrant-2 Need to promote\n quadrant-3 Re-evaluate\n quadrant-4 May be improved\n "Product A": [0.3, 0.6]\n "Product B": [0.45, 0.23]\n "Product C": [0.57, 0.69]\n "Product D": [0.78, 0.34]\n "Product E": [0.40, 0.34]\n "Our Target Product": [0.5, 0.6]", "Requirement Analysis": "The product should be a CLI blackjack game that is user-friendly, has clear instructions, runs smoothly without any bugs, and is fair and random. The user should be able to start a new game easily, see their current score, and quit the game at any time.", "Requirement Pool": [["P0","Create a user-friendly CLI"], ["P0","Implement blackjack game rules"], ["P0","Ensure the game runs smoothly without any bugs"], ["P1","Implement a scoring system"], ["P1","Implement a quit option"]], "UI Design draft": "The UI should be simple and clean, with clear instructions displayed at the top. The user's current score should be displayed at the bottom. The game should be played in the middle of the screen, with the user's options (hit, stand, etc.) displayed clearly.", "Anything UNCLEAR": "No" } [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:21:18.646 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.062 | Max budget: $3.000 | Current cost: $0.062, prompt_tokens: 895, completion_tokens: 590 2023-12-20 05:21:18.651 | INFO | metagpt.roles.role:_act:212 - Bob(Architect): ready to WriteDesign [CONTENT] { "Implementation approach": "We will use the Python standard library to create the CLI blackjack game. The 'random' module will be used to ensure the game is fair and random. The 'os' module will be used to clear the screen for a better user experience. The 'enum' module will be used to define the suits and ranks of the cards. The 'collections' module will be used to define the deck as a collection of cards. The 'argparse' module will be used to handle command-line arguments. The game logic will be implemented in a Game class, and the Player and Dealer will be implemented as subclasses of a Participant class. The Card and Deck will be implemented as separate classes. The game will be started and controlled from a main function.", "Python package name": "cli_blackjack", "File list": ["main.py", "game.py", "participant.py", "card.py", "deck.py"], "Data structures and interface definitions": ' classDiagram class Card{ +str suit +str rank +init(suit: str, rank: str) } class Deck{ +list[Card] cards +init() +shuffle() +draw(): Card } class Participant{ +Deck hand +int score +init() +draw(deck: Deck) +calculate_score() } Participant <|-- Player Participant <|-- Dealer class Game{ +Player player +Dealer dealer +Deck deck +init(player_name: str) +play_round() +check_winner() } ', "Program call flow": ' sequenceDiagram participant M as main participant G as Game participant P as Player participant D as Dealer participant De as Deck M->>G: init("Player") G->>P: init() G->>D: init() G->>De: init() De->>G: shuffle() loop game round G->>P: draw(De) G->>D: draw(De) G->>P: calculate_score() G->>D: calculate_score() G->>M: check_winner() end ', "Anything UNCLEAR": "The requirement is clear to me." } [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:22:15.770 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.126 | Max budget: $3.000 | Current cost: $0.064, prompt_tokens: 1105, completion_tokens: 516 no mermaid 2023-12-20 05:22:15.776 | WARNING | metagpt.utils.mermaid:mermaid_to_file:37 - RUN npm install -g @mermaid-js/mermaid-cli to install mmdc,or consider changing MERMAID_ENGINE to playwright, pyppeteer, or ink. 2023-12-20 05:22:15.776 | INFO | metagpt.actions.design_api:_save_prd:175 - Saving PRD to /workspaces/MetaGPT/workspace/cli_blackjack/docs/prd.md no mermaid 2023-12-20 05:22:15.777 | WARNING | metagpt.utils.mermaid:mermaid_to_file:37 - RUN npm install -g @mermaid-js/mermaid-cli to install mmdc,or consider changing MERMAID_ENGINE to playwright, pyppeteer, or ink. no mermaid 2023-12-20 05:22:15.779 | WARNING | metagpt.utils.mermaid:mermaid_to_file:37 - RUN npm install -g @mermaid-js/mermaid-cli to install mmdc,or consider changing MERMAID_ENGINE to playwright, pyppeteer, or ink. 2023-12-20 05:22:15.779 | INFO | metagpt.actions.design_api:_save_system_design:188 - Saving System Designs to /workspaces/MetaGPT/workspace/cli_blackjack/docs/system_design.md 2023-12-20 05:22:15.780 | INFO | metagpt.roles.role:_act:212 - Eve(Project Manager): ready to WriteTasks [CONTENT] { "Required Python third-party packages": [],

"Required Other language third-party packages": [],

"Full API spec": "",

"Logic Analysis": [
    ["main.py",["main function"]],
    ["game.py",["Game class","play_round method","check_winner method"]],
    ["participant.py",["Participant class","Player subclass","Dealer subclass","draw method","calculate_score method"]],
    ["card.py",["Card class"]],
    ["deck.py",["Deck class","shuffle method","draw method"]]
],

"Task list": ["card.py", "deck.py", "participant.py", "game.py", "main.py"],

"Shared Knowledge": "The 'game.py' contains the main game logic, 'participant.py' defines the Player and Dealer classes, 'card.py' defines the Card class, 'deck.py' defines the Deck class, and 'main.py' is the entry point of the program.",

"Anything UNCLEAR": "The requirement is clear to me."

} [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:22:38.726 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.171 | Max budget: $3.000 | Current cost: $0.044, prompt_tokens: 1040, completion_tokens: 217 [CONTENT] { "Required Python third-party packages": [],

"Required Other language third-party packages": [],

"Full API spec": "",

"Logic Analysis": [
    ["main.py", "main function to start and control the game"],
    ["game.py", "Game class with methods for playing a round and checking the winner"],
    ["participant.py", "Participant class with methods for drawing a card and calculating score, Player and Dealer subclasses"],
    ["card.py", "Card class with suit and rank attributes"],
    ["deck.py", "Deck class with methods for shuffling and drawing a card"]
],

"Task list": ["card.py", "deck.py", "participant.py", "game.py", "main.py"],

"Shared Knowledge": "The 'random' module from the Python standard library is used for shuffling the deck. The 'os' module is used to clear the screen for a better user experience. The 'enum' module is used to define the suits and ranks of the cards. The 'collections' module is used to define the deck as a collection of cards. The 'argparse' module is used to handle command-line arguments.",

"Anything UNCLEAR": "The requirement is clear, no unclear points."

} [/CONTENT] Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:07.504 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.218 | Max budget: $3.000 | Current cost: $0.047, prompt_tokens: 1040, completion_tokens: 266 0 Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:12.898 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.267 | Max budget: $3.000 | Current cost: $0.049, prompt_tokens: 1627, completion_tokens: 1 2023-12-20 05:23:12.898 | INFO | metagpt.roles.engineer:_act:210 - Alex(Engineer): ready to WriteCode 2023-12-20 05:23:12.899 | INFO | metagpt.actions.write_code:run:77 - Writing card.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:17.670 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.299 | Max budget: $3.000 | Current cost: $0.032, prompt_tokens: 1072, completion_tokens: 0 2023-12-20 05:23:17.671 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:17.671 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:17.671 | INFO | metagpt.actions.write_code_review:run:77 - Code review card.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:22.231 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.332 | Max budget: $3.000 | Current cost: $0.033, prompt_tokens: 1097, completion_tokens: 0 2023-12-20 05:23:22.232 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:22.232 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:22.233 | INFO | metagpt.actions.write_code:run:77 - Writing deck.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:27.088 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.364 | Max budget: $3.000 | Current cost: $0.032, prompt_tokens: 1072, completion_tokens: 0 2023-12-20 05:23:27.089 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:27.089 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:27.090 | INFO | metagpt.actions.write_code_review:run:77 - Code review deck.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:32.398 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.397 | Max budget: $3.000 | Current cost: $0.033, prompt_tokens: 1097, completion_tokens: 0 2023-12-20 05:23:32.399 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:32.399 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:32.399 | INFO | metagpt.actions.write_code:run:77 - Writing participant.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:38.056 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.429 | Max budget: $3.000 | Current cost: $0.032, prompt_tokens: 1072, completion_tokens: 0 2023-12-20 05:23:38.056 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:38.057 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:38.057 | INFO | metagpt.actions.write_code_review:run:77 - Code review participant.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:42.193 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.462 | Max budget: $3.000 | Current cost: $0.033, prompt_tokens: 1097, completion_tokens: 0 2023-12-20 05:23:42.193 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:42.194 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:42.194 | INFO | metagpt.actions.write_code:run:77 - Writing game.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:47.023 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.494 | Max budget: $3.000 | Current cost: $0.032, prompt_tokens: 1072, completion_tokens: 0 2023-12-20 05:23:47.023 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:47.024 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:47.024 | INFO | metagpt.actions.write_code_review:run:77 - Code review game.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:52.310 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.527 | Max budget: $3.000 | Current cost: $0.033, prompt_tokens: 1097, completion_tokens: 0 2023-12-20 05:23:52.310 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:52.311 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:52.311 | INFO | metagpt.actions.write_code:run:77 - Writing main.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:23:59.986 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.559 | Max budget: $3.000 | Current cost: $0.032, prompt_tokens: 1072, completion_tokens: 0 2023-12-20 05:23:59.986 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:23:59.986 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:23:59.987 | INFO | metagpt.actions.write_code_review:run:77 - Code review main.py..

Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-12-20 05:24:04.280 | INFO | metagpt.provider.openai_api:update_cost:91 - Total running cost: $0.592 | Max budget: $3.000 | Current cost: $0.033, prompt_tokens: 1097, completion_tokens: 0 2023-12-20 05:24:04.281 | ERROR | metagpt.utils.common:parse_code:238 - .*?\s+(.*?) not match following text: 2023-12-20 05:24:04.281 | ERROR | metagpt.utils.common:parse_code:239 - 2023-12-20 05:24:04.281 | INFO | metagpt.roles.engineer:_act_sp_precision:202 - Done /workspaces/MetaGPT/workspace/cli_blackjack/cli_blackjack generating. @WQL782795 ➜ /workspaces/MetaGPT (v0.4-release) $ cd workspace/cli_blackjack/ cli_blackjack/ docs/ requirements.txt resources/
@WQL782795 ➜ /workspaces/MetaGPT (v0.4-release) $ cd workspace/cli_blackjack/ cli_blackjack/ docs/ requirements.txt resources/
@WQL782795 ➜ /workspaces/MetaGPT (v0.4-release) $ cd workspace/cli_blackjack/cli_blackjack/ card.py deck.py game.py main.py participant.py
@WQL782795 ➜ /workspaces/MetaGPT (v0.4-release) $ cd workspace/cli_blackjack/cli_blackjack/ card.py deck.py game.py main.py participant.py
@WQL782795 ➜ /workspaces/MetaGPT (v0.4-release) $ cd workspace/cli_blackjack/cli_blackjack/ @WQL782795 ➜ .../MetaGPT/workspace/cli_blackjack/cli_blackjack (v0.4-release) $ ll bash: ll: command not found @WQL782795 ➜ .../MetaGPT/workspace/cli_blackjack/cli_blackjack (v0.4-release) $ ls card.py deck.py game.py main.py participant.py @WQL782795 ➜ .../MetaGPT/workspace/cli_blackjack/cli_blackjack (v0.4-release) $ cat main.py @WQL782795 ➜ .../MetaGPT/workspace/cli_blackjack/cli_blackjack (v0.4-release) $

WQL782795 avatar Dec 20 '23 05:12 WQL782795

After further debugging, it was found that there were no errors in the preceding steps of generating PRD and design documents; there were corresponding outputs. However, during the "write_code" phase, when calling the language model (llm), a situation occurred where the response was blank. The specific error might be hidden at the interface level, making it temporarily impossible to extract information.

101703080593_ pic 131703081482_ pic

WQL782795 avatar Dec 20 '23 14:12 WQL782795

You are right, the problem is that the llm gave an empty response.

Your running record: image

What it is supposed to be (from my run just now): ed15e532-d343-4b93-a684-0337d6235301

May I see your key.yaml or config.yaml? (hide your api key) I'm not able to reproduce your errors.

garylin2099 avatar Dec 21 '23 02:12 garylin2099

This is my config file. I only changed the OpenAI key and BaseUrl. It's not the official path; it's a proxy provided by 'ZhiXueTang.' Maybe there's an issue here. Perhaps it would be helpful to sync up with Professor Sun?

image

WQL782795 avatar Dec 21 '23 03:12 WQL782795

Can you try using the original one below to see if the issue still exists? You have access to openai in github codespace without proxy.

OPENAI_API_BASE: "https://api.openai.com/v1"

This is my config file. I only changed the OpenAI key and BaseUrl. It's not the official path; it's a proxy provided by 'ZhiXueTang.' Maybe there's an issue here. Perhaps it would be helpful to sync up with Professor Sun?

image

garylin2099 avatar Dec 21 '23 03:12 garylin2099

Can you try using the original one below to see if the issue still exists? You have access to openai in github codespace without proxy.

OPENAI_API_BASE: "https://api.openai.com/v1"

This is my config file. I only changed the OpenAI key and BaseUrl. It's not the official path; it's a proxy provided by 'ZhiXueTang.' Maybe there's an issue here. Perhaps it would be helpful to sync up with Professor Sun? image

sorry, I haven't activated the official API yet. I'll try it later when I have it~ Thanks!

WQL782795 avatar Dec 25 '23 17:12 WQL782795

This is my config file. I only changed the OpenAI key and BaseUrl. It's not the official path; it's a proxy provided by 'ZhiXueTang.' Maybe there's an issue here. Perhaps it would be helpful to sync up with Professor Sun?

image

I have encountered the same issue,have you resolved it , if so, how ?

zhanghaoyang667 avatar Jan 11 '24 02:01 zhanghaoyang667

This is my config file. I only changed the OpenAI key and BaseUrl. It's not the official path; it's a proxy provided by 'ZhiXueTang.' Maybe there's an issue here. Perhaps it would be helpful to sync up with Professor Sun? image

I have encountered the same issue,have you resolved it , if so, how ?

Not yet, I lack the official openai key for experimentation

WQL782795 avatar Jan 11 '24 09:01 WQL782795

This issue did not appear in v0.5-release. It is speculated that v0.5-release should have fixed it.

suggestion: use v0.5-release

WQL782795 avatar Jan 14 '24 15:01 WQL782795

I use the latest v-0.8.1 release, but i got the same error when i run any examples/di/* examples

WilkinsLiu avatar Apr 28 '24 14:04 WilkinsLiu

@geekan I resolve the problem like this

class WritePlan(Action): PROMPT_TEMPLATE: str = """ # Context: {context} # Available Task Types: {task_type_desc} # Task: Based on the context, write a plan or modify an existing plan of what you should do to achieve the goal. A plan consists of one to {max_tasks} tasks. If you are modifying an existing plan, carefully follow the instruction, don't make unnecessary changes. Give the whole plan unless instructed to modify only one task of the plan. If you encounter errors on the current task, revise and output the current single task only. Output a list of jsons following the format: json [ {{ "task_id": str = "unique identifier for a task in plan, can be an ordinal", "dependent_task_ids": list[str] = "ids of tasks prerequisite to this task", "instruction": "what you should do in this task, one short phrase or sentence", "task_type": "type of this task, should be one of Available Task Types", }}, ... ] Return json your_json_here with NO other texts. Be sure your json can be load by json.loads(). """

I add Return json your_json_here with NO other texts. Be sure your json can be load by json.loads().

chosenlu avatar Jun 15 '24 09:06 chosenlu