Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize error message when validating api_key failed #1324

Merged
merged 2 commits into from
Jun 22, 2024

Conversation

usamimeri
Copy link
Contributor

@usamimeri usamimeri commented Jun 5, 2024

Features
Added a more user-friendly error message for API_KEY validation failure for #1290, #1322 and #1220.
Users can use metagpt --init-config to add a config2.yaml under home/username/.metagpt/config2.yaml.
However, the config file in the home directory will overwrite the one in the MetaGPT repository, which may cause unexpected results. Therefore, the error message has been optimized.
Result

  1. When two paths exist or only the config under home path exists and there is no api_key in the home path one:
ValidationError: 1 validation error for Config
llm.api_key
  Value error, Please set your API key in /home/usamimeri/.metagpt/config2.yaml. If you also set your config in /home/usamimeri/MetaGPT/config/config2.yaml, 
the former will overwrite the latter. This may cause unexpected result.
 [type=value_error, input_value='YOUR_API_KEY', input_type=str]
    For further information visit https://errors.pydantic.dev/2.6/v/value_error
  1. When only the config under the repository exists:
ValidationError: 1 validation error for Config
llm.api_key
  Value error, Please set your API key in /home/usamimeri/MetaGPT/config/config2.yaml [type=value_error, input_value='YOUR_API_KEY', input_type=str]
    For further information visit https://errors.pydantic.dev/2.6/v/value_error

@better629 better629 merged commit 9f8f0a2 into geekan:main Jun 22, 2024
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants