Unable to run metagpt
(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 __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'
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.
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
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!