MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

Unable to run metagpt

Open yousia33 opened this issue 1 year ago โ€ข 3 comments

(metagpt) PS F:\codetest\Metagpt> metagpt "create a 2048 game" 2024-06-05 16:46:27.754 | INFO | metagpt.const:get_metagpt_package_root:29 - Package root set to f:\codetest\metagpt โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚ f:\codetest\metagpt\metagpt\software_company.py:108 in startup โ”‚ โ”‚ โ”‚ โ”‚ 105 โ”‚ โ”‚ typer.echo("Missing argument 'IDEA'. Run 'metagpt --help' for more โ”‚ โ”‚ 106 โ”‚ โ”‚ raise typer.Exit() โ”‚ โ”‚ 107 โ”‚ โ”‚ โ”‚ โฑ 108 โ”‚ return generate_repo( โ”‚ โ”‚ 109 โ”‚ โ”‚ idea, โ”‚ โ”‚ 110 โ”‚ โ”‚ investment, โ”‚ โ”‚ 111 โ”‚ โ”‚ n_round, โ”‚ โ”‚ โ”‚ โ”‚ f:\codetest\metagpt\metagpt\software_company.py:30 in generate_repo โ”‚ โ”‚ โ”‚ โ”‚ 27 โ”‚ recover_path=None, โ”‚ โ”‚ 28 ) -> ProjectRepo: โ”‚ โ”‚ 29 โ”‚ """Run the startup logic. Can be called from CLI or other Python scrip โ”‚ โ”‚ โฑ 30 โ”‚ from metagpt.config2 import config โ”‚ โ”‚ 31 โ”‚ from metagpt.context import Context โ”‚ โ”‚ 32 โ”‚ from metagpt.roles import ( โ”‚ โ”‚ 33 โ”‚ โ”‚ Architect, โ”‚ โ”‚ โ”‚ โ”‚ f:\codetest\metagpt\metagpt\config2.py:164 in โ”‚ โ”‚ โ”‚ โ”‚ 161 โ”‚ return result โ”‚ โ”‚ 162 โ”‚ โ”‚ 163 โ”‚ โ”‚ โฑ 164 config = Config.default() โ”‚ โ”‚ 165 โ”‚ โ”‚ โ”‚ โ”‚ f:\codetest\metagpt\metagpt\config2.py:106 in default โ”‚ โ”‚ โ”‚ โ”‚ 103 โ”‚ โ”‚ dicts = [dict(os.environ)] โ”‚ โ”‚ 104 โ”‚ โ”‚ dicts += [Config.read_yaml(path) for path in default_config_paths] โ”‚ โ”‚ 105 โ”‚ โ”‚ final = merge_dict(dicts) โ”‚ โ”‚ โฑ 106 โ”‚ โ”‚ return Config(**final) โ”‚ โ”‚ 107 โ”‚ โ”‚ โ”‚ 108 โ”‚ @classmethod โ”‚ โ”‚ 109 โ”‚ def from_llm_config(cls, llm_config: dict): โ”‚ โ”‚ โ”‚ โ”‚ F:\anacoda\envs\metagpt\Lib\site-packages\pydantic\main.py:176 in init โ”‚ โ”‚ โ”‚ โ”‚ 173 โ”‚ โ”‚ """ โ”‚ โ”‚ 174 โ”‚ โ”‚ # __tracebackhide__ tells pytest and some other tools to omit t โ”‚ โ”‚ 175 โ”‚ โ”‚ tracebackhide = True โ”‚ โ”‚ โฑ 176 โ”‚ โ”‚ self.pydantic_validator.validate_python(data, self_instance=s โ”‚ โ”‚ 177 โ”‚ โ”‚ โ”‚ 178 โ”‚ # The following line sets a flag that we use to determine when `__ini โ”‚ โ”‚ 179 โ”‚ init.pydantic_base_init = True # pyright: ignore[reportFunct โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ ValidationError: 1 validation error for Config llm.api_key Value error, Please set your API key in config2.yaml [type=value_error, input_value='YOUR_API_KEY', input_type=str] For further information visit https://errors.pydantic.dev/2.7/v/value_error

MY config๏ผšllm:

api_type: "qianfan" access_key: "XXX" secret_key: "XXX" model: 'ERNIE-3.5-8K'

yousia33 avatar Jun 05 '24 08:06 yousia33

MY config๏ผšllm:

api_type: "qianfan" access_key: "GWzMbdC" secret_key: "QUnQH0LRfnHL432X" model: 'ERNIE-3.5-8K'

don't post your key here, revoke it.

usamimeri avatar Jun 05 '24 09:06 usamimeri

Value error, Please set your API key in config2.yaml [type=value_error,
input_value='YOUR_API_KEY', input_type=str]

indicated that you didn't set your API_KEY in config.yaml. This might because there is also a config2.yaml under home path which overwrites your local settings. You can test this with the following code:

from metagpt.const import CONFIG_ROOT
import os
print(CONFIG_ROOT)
print(os.path.exists(CONFIG_ROOT))

You can delete it if it exists.

For more information: https://github.com/geekan/MetaGPT/blob/main/metagpt/config2.py#L98-L106

usamimeri avatar Jun 05 '24 09:06 usamimeri

Value error, Please set your API key in config2.yaml [type=value_error,
input_value='YOUR_API_KEY', input_type=str]

indicated that you didn't set your API_KEY in config.yaml. This might because there is also a config2.yaml in your Home directory, and MetaGPT read the configuration from there, which overrides your local settings. You can test this with the following code:

from metagpt.const import CONFIG_ROOT
import os
print(CONFIG_ROOT)
print(os.path.exists(CONFIG_ROOT))

You can delete it if it exists.

For more information: https://github.com/geekan/MetaGPT/blob/main/metagpt/config2.py#L98-L106

Thanks! This helps a lot!

yousia33 avatar Jun 05 '24 11:06 yousia33