geekan / MetaGPT

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

feat: add tencent hunyuan api #1359

Open david-zlj opened 1 week ago

david-zlj commented 1 week ago

Features

Feature Docs

Influence

Result

测试内容:

import asyncio
from metagpt.context import Context
from metagpt.roles.product_manager import ProductManager
from metagpt.logs import logger

async def main():
    msg = "Write a PRD for a snake game"
    context = Context()
    role = ProductManager(context=context)
    while msg:
        msg = await role.run(msg)
        logger.info(str(msg))

if __name__ == "__main__":
    asyncio.run(main())

测试输出结果:

2024-06-20 10:10:07.905 | INFO     | metagpt.const:get_metagpt_package_root:29 - Package root set to e:\python_workspace\aiagent\metagpt_a\metagpt
2024-06-20 10:10:12.182 | INFO     | metagpt.roles.role:_act:402 - Alice(Product Manager): to do PrepareDocuments(PrepareDocuments)
2024-06-20 10:10:12.502 | INFO     | metagpt.utils.file_repository:save:57 - save to: E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\20240620101012\docs\requirement.txt
2024-06-20 10:10:12.505 | INFO     | metagpt.roles.role:_act:402 - Alice(Product Manager): to do WritePRD(WritePRD)
2024-06-20 10:10:12.508 | INFO     | metagpt.actions.write_prd:run:86 - New requirement detected: Write a PRD for a snake game
[CONTENT]
{
    "Language": "en_us",
    "Programming Language": "Python",
    "Original Requirements": "Write a PRD for a snake game",
    "Project Name": "snake_game",
    "Product Goals": [
        "Create an engaging user experience",
        "Improve accessibility, be responsive",
        "More beautiful UI"
    ],
    "User Stories": [
        "As a player, I want to control the snake using arrow keys",
        "As a player, I want to eat food to grow longer",
        "As a player, I want to avoid hitting walls or myself",
        "As a player, I want to see my high score and current score",
        "As a player, I want to have multiple levels with increasing difficulty"
    ],
    "Competitive Analysis": [
        "Snake Classic: Basic gameplay, no frills",
        "Super Snake: Colorful graphics, power-ups, and levels",
        "Snake Adventure: Engaging storyline, different environments"
    ],
    "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": "",
    "Requirement Pool": [
        [
            "P0",
            "Implement the snake game logic"
        ],
        [
            "P1",
            "Design and implement the user interface"
        ],
        [
            "P2",
            "Add power-ups and level progression"
        ],
        [
            "P3",
            "Ensure responsive gameplay on various devices"
        ],
        [
            "P4",
            "Implement scoring and high score tracking"
        ]
    ],
    "UI Design draft": "A simple grid layout with a snake represented by a series of connected squares. The snake moves automatically and the player can control its direction using arrow keys. The game includes a scoreboard at the top and a play area in the center. Power-ups appear randomly and change the snake's behavior temporarily.",
    "Anything UNCLEAR": ""
}
2024-06-20 10:10:21.620 | WARNING  | metagpt.utils.cost_manager:update_cost:49 - Model hunyuan-standard not found in TOKEN_COSTS.
[/CONTENT]
2024-06-20 10:10:21.638 | INFO     | metagpt.utils.git_repository:rename_root:203 - Delete directory E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game
2024-06-20 10:10:21.749 | WARNING  | metagpt.utils.git_repository:rename_root:214 - Move E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\20240620101012 to E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game error: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'E:\\python_workspace\\aiagent\\metagpt_a\\MetaGPT\\workspace\\20240620101012'
2024-06-20 10:10:21.752 | INFO     | metagpt.utils.git_repository:rename_root:219 - Rename directory E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\20240620101012 to E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game
2024-06-20 10:10:21.760 | INFO     | metagpt.utils.file_repository:save:57 - save to: E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game\docs\prd\20240620101021.json
C:\Users\zlj\AppData\Roaming\npm\mmdc
C:\Users\zlj\AppData\Roaming\npm\mmdc.cmd
2024-06-20 10:10:21.944 | INFO     | metagpt.utils.mermaid:mermaid_to_file:44 - Generating E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game\resources\competitive_analysis\20240620101021.pdf..
2024-06-20 10:10:24.224 | INFO     | metagpt.utils.mermaid:mermaid_to_file:68 - Generating single mermaid chart

2024-06-20 10:10:24.226 | INFO     | metagpt.utils.mermaid:mermaid_to_file:44 - Generating E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game\resources\competitive_analysis\20240620101021.svg..
2024-06-20 10:10:26.470 | INFO     | metagpt.utils.mermaid:mermaid_to_file:68 - Generating single mermaid chart

2024-06-20 10:10:26.472 | INFO     | metagpt.utils.mermaid:mermaid_to_file:44 - Generating E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game\resources\competitive_analysis\20240620101021.png..
2024-06-20 10:10:28.837 | INFO     | metagpt.utils.mermaid:mermaid_to_file:68 - Generating single mermaid chart

2024-06-20 10:10:28.841 | INFO     | metagpt.utils.file_repository:save:57 - save to: E:\python_workspace\aiagent\metagpt_a\MetaGPT\workspace\snake_game\resources\prd\20240620101021.md
2024-06-20 10:10:28.843 | INFO     | __main__:main:16 - Alice(Product Manager): {'docs': {'20240620101021.json': {'root_path': 'docs\\prd', 'filename': '20240620101021.json', 'content': '{"Language":"en_us","Programming Language":"Python","Original Requirements":"Write a PRD for a snake game","Project Name":"snake_game","Product Goals":["Create an engaging user experience","Improve accessibility, be responsive","More beautiful UI"],"User Stories":["As a player, I want to control the snake using arrow keys","As a player, I want to eat food to grow longer","As a player, I want to avoid hitting walls or myself","As 
a player, I want to see my high score and current score","As a player, I want to have multiple levels with increasing difficulty"],"Competitive Analysis":["Snake Classic: Basic gameplay, no frills","Super Snake: Colorful graphics, power-ups, and levels","Snake Adventure: Engaging storyline, different environments"],"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    \\"Campaign A\\": [0.3, 0.6]\\n    \\"Campaign B\\": [0.45, 0.23]\\n    \\"Campaign C\\": [0.57, 0.69]\\n    \\"Campaign D\\": [0.78, 0.34]\\n    \\"Campaign E\\": [0.40, 0.34]\\n    \\"Campaign F\\": [0.35, 0.78]\\n    \\"Our Target Product\\": [0.5, 0.6]","Requirement Analysis":"","Requirement Pool":[["P0","Implement the snake game logic"],["P1","Design and implement the user interface"],["P2","Add power-ups and level progression"],["P3","Ensure responsive gameplay on various devices"],["P4","Implement scoring and high score tracking"]],"UI Design draft":"A simple grid layout with a snake represented by a series of connected squares. The snake moves automatically and the player can control its direction using arrow keys. The game includes a scoreboard at the top and a play area in the center. Power-ups appear randomly and change the snake\'s behavior temporarily.","Anything UNCLEAR":""}'}}}
2024-06-20 10:10:28.846 | INFO     | __main__:main:16 - None

Other

参考资料

david-zlj commented 1 week ago

对应文档:https://github.com/geekan/MetaGPT-docs/pull/153

usamimeri commented 1 week ago

Amazing work! I have reviewed it and provided some potential improvement suggestions.