MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

How to pass --project-name in the async python code

Open Unkownforlife opened this issue 1 year ago • 4 comments

How to pass --project-name in the async python code

import asyncio
from metagpt.roles import (
    Architect, 
    Engineer, 
    ProductManager, 
    ProjectManager
)
from metagpt.team import Team

async def startup(idea: str):
    company = Team()
    company.hire(
        [
            ProductManager(), 
            Architect(),
            ProjectManager(),
            Engineer()
        ]
    )

    company.invest(investment=10)
    company.run_project(idea=idea)

    await company.run(n_round=5)

async def main():
    await startup(idea = "Write a snake game in python which works in cli")

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

Unkownforlife avatar Apr 15 '24 07:04 Unkownforlife

You can check the code: set config's project_name. Using typer or fire to parse command args.

seehi avatar Apr 15 '24 08:04 seehi

I have already tried this below is the code but i am facing issue in that as well i got tuple instead of a string

from metagpt.config2 import config
from metagpt.context import Context


project_name="dharmendra",
inc=False,
project_path="",
reqa_file="",
max_auto_summarize_code=0,

config.update_via_cli(project_path, project_name, inc, reqa_file, max_auto_summarize_code)
print(f"##########3config {config}")
ctx = Context(config=config)
print(ctx)

async def startup(idea: str):
    company = Team(context=ctx)
    company.hire(
        [
            ProductManager(), 
            Searcher(),
            Architect(),
            ProjectManager(),
            Engineer()
        ]
    )

    company.invest(investment=10)
    company.run_project(idea=idea)

    await company.run(n_round=5)

async def main():
    await startup(idea = "Write a snake game in python which works in cli")

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

tuple : project_path=('',), project_name=('dharmendra',), inc=True, reqa_file=('',), max_auto_summarize_code=(0,),

##########3config kwargs=AttrDict() config=Config(extra_fields=None, project_path=('',), project_name=('dharmendra',), inc=True, reqa_file=('',), max_auto_summarize_code=(0,), git_reinit=False, llm=LLMConfig(extra_fields=None, api_key='sk-myapikey', api_type=<LLMType.OPENAI: 'openai'>, base_url='https://api.openai.com/v1', api_version=None, model='gpt-3.5-turbo-1106', pricing_plan=None, access_key=None, secret_key=None, endpoint=None, app_id=None, api_secret=None, domain=None, max_token=4096, temperature=0.0, top_p=1.0, top_k=0, repetition_penalty=1.0, stop=None, presence_penalty=0.0, frequency_penalty=0.0, best_of=None, n=None, stream=False, logprobs=None, top_logprobs=None, timeout=600, proxy=None, calc_usage=True), proxy='', search=SearchConfig(extra_fields=None, api_type=<SearchEngineType.DUCK_DUCK_GO: 'ddg'>, api_key='', cse_id='', search_func=None, params={'engine': 'google', 'google_domain': 'google.com', 'gl': 'us', 'hl': 'en'}), browser=BrowserConfig(extra_fields=None, engine=<WebBrowserEngineType.PLAYWRIGHT: 'playwright'>, browser_type='chromium'), mermaid=MermaidConfig(extra_fields=None, engine='nodejs', path='mmdc', puppeteer_config='', pyppeteer_path='/usr/bin/google-chrome-stable'), s3=None, redis=None, repair_llm_output=False, prompt_schema='json', workspace=WorkspaceConfig(extra_fields=None, path=WindowsPath('C:/Users/techc/Desktop/codiste-projects/meta-gpt-api/workspace'), use_uid=False, uid=''), enable_longterm_memory=False, code_review_k_times=2, metagpt_tti_url='', language='English', redis_key='placeholder', iflytek_app_id='', iflytek_api_secret='', iflytek_api_key='', azure_tts_subscription_key='', azure_tts_region='') repo=None git_repo=None src_workspace=None cost_manager=CostManager(total_prompt_tokens=0, total_completion_tokens=0, total_budget=0, max_budget=10.0, total_cost=0, token_costs={'gpt-3.5-turbo': {'prompt': 0.0015, 'completion': 0.002}, 'gpt-3.5-turbo-0301': {'prompt': 0.0015, 'completion': 0.002}, 'gpt-3.5-turbo-0613': {'prompt': 0.0015, 'completion': 0.002}, 'gpt-3.5-turbo-16k': {'prompt': 0.003, 'completion': 0.004}, 'gpt-3.5-turbo-16k-0613': {'prompt': 0.003, 'completion': 0.004}, 'gpt-35-turbo': {'prompt': 0.0015, 'completion': 0.002}, 'gpt-35-turbo-16k': {'prompt': 0.003, 'completion': 0.004}, 'gpt-3.5-turbo-1106': {'prompt': 0.001, 'completion': 0.002}, 'gpt-3.5-turbo-0125': {'prompt': 0.001, 'completion': 0.002}, 'gpt-4-0314': {'prompt': 0.03, 'completion': 0.06}, 'gpt-4': {'prompt': 0.03, 'completion': 0.06}, 'gpt-4-32k': {'prompt': 0.06, 'completion': 0.12}, 'gpt-4-32k-0314': {'prompt': 0.06, 'completion': 0.12}, 'gpt-4-0613': {'prompt': 0.06, 'completion': 0.12}, 'gpt-4-turbo-preview': {'prompt': 0.01, 'completion': 0.03}, 'gpt-4-0125-preview': {'prompt': 0.01, 'completion': 0.03}, 'gpt-4-1106-preview': {'prompt': 0.01, 'completion': 0.03}, 'gpt-4-vision-preview': {'prompt': 0.01, 'completion': 0.03}, 'gpt-4-1106-vision-preview': {'prompt': 0.01, 'completion': 0.03}, 'text-embedding-ada-002': {'prompt': 0.0004, 'completion': 0.0}, 'glm-3-turbo': {'prompt': 0.0007, 'completion': 0.0007}, 'glm-4': {'prompt': 0.014, 'completion': 0.014}, 'gemini-pro': {'prompt': 0.00025, 'completion': 0.0005}, 'moonshot-v1-8k': {'prompt': 0.012, 'completion': 0.012}, 'moonshot-v1-32k': {'prompt': 0.024, 'completion': 0.024}, 'moonshot-v1-128k': {'prompt': 0.06, 'completion': 0.06}, 'open-mistral-7b': {'prompt': 0.00025, 'completion': 0.00025}, 'open-mixtral-8x7b': {'prompt': 0.0007, 'completion': 0.0007}, 'mistral-small-latest': {'prompt': 0.002, 'completion': 0.006}, 'mistral-medium-latest': {'prompt': 0.0027, 'completion': 0.0081}, 'mistral-large-latest': {'prompt': 0.008, 'completion': 0.024}, 'claude-instant-1.2': {'prompt': 0.0008, 'completion': 0.0024}, 'claude-2.0': {'prompt': 0.008, 'completion': 0.024}, 'claude-2.1': {'prompt': 0.008, 'completion': 0.024}, 'claude-3-sonnet-20240229': {'prompt': 0.003, 'completion': 0.015}, 'claude-3-opus-20240229': {'prompt': 0.015, 'completion': 0.075}, 'yi-34b-chat-0205': {'prompt': 0.0003, 'completion': 0.0003}, 'yi-34b-chat-200k': {'prompt': 0.0017, 'completion': 0.0017}})

Unkownforlife avatar Apr 15 '24 08:04 Unkownforlife

Have achieved it through after adding

config.project_name = "new_project_name"

from metagpt.config2 import config
from metagpt.context import Context


project_name="dharmendra",
inc=False,
project_path="",
reqa_file="",
max_auto_summarize_code=0,

#config.update_via_cli(project_path, project_name, inc, reqa_file, max_auto_summarize_code)
config.project_name = "new_project_name"
print(f"##########3config {config}")
ctx = Context(config=config)
print(ctx)

Unkownforlife avatar Apr 15 '24 09:04 Unkownforlife

Guys,,

If i done something like this, It is unable to detect the programing language

[CONTENT] { "Language": "en_us", "Original Requirements": "Do a market research for Blockchain Usecase in decentralised Physical Network, Consider you are a Resesrcher and Expert", "Product Goals": [ "Identify potential blockchain use cases in decentralized physical networks", "Provide insights into the feasibility and benefits of implementing blockchain in physical networks", "Offer recommendations for leveraging blockchain technology in decentralized physical networks" ], "User Stories": [ "As a researcher, I want to understand the current challenges in decentralized physical networks", "As an expert, I want to explore the potential benefits of integrating blockchain technology in physical networks", "As a stakeholder, I want to receive actionable insights and recommendations for implementing blockchain in physical networks" ], "Competitive Analysis": [], "Competitive Quadrant Chart": "", "Requirement Analysis": "", "Requirement Pool": [], "UI Design draft": "", "Anything UNCLEAR": "" } [/CONTENT]

Error: 2024-04-15 15:39:28.668 | ERROR | metagpt.utils.common:log_it:554 - Finished call to 'metagpt.actions.action_node.ActionNode._aask_v1' after 3.484(s), this was the 1st time calling it. exp: 1 validation error for WritePRD_AN Value error, Missing fields: {'Programming Language'} [type=value_error, input_value={'Language': 'en_us', 'Or... 'Anything UNCLEAR': ''}, input_type=dict] For further information visit https://errors.pydantic.dev/2.5/v/value_error

Can anyone give insights on this please?

Unkownforlife avatar Apr 15 '24 10:04 Unkownforlife