From e1123bae82c2ed9f8062af0095edb800a6aef986 Mon Sep 17 00:00:00 2001 From: liujun Date: Wed, 13 Mar 2024 09:59:30 +0800 Subject: [PATCH] feat:add user llm config --- metagpt/config2.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/metagpt/config2.py b/metagpt/config2.py index bc6af18c6..4b3d82593 100644 --- a/metagpt/config2.py +++ b/metagpt/config2.py @@ -99,7 +99,20 @@ class Config(CLIParams, YamlModel): dicts += [Config.read_yaml(path) for path in default_config_paths] final = merge_dict(dicts) return Config(**final) - + + @classmethod + def config(cls,config:dict): + """user config llm + example: + llm_config = {"llm": {"api_type": "xxx", "api_key": "xxx", "model": "xxx"} + gpt4 = Config.config(llm_config) + A = Role(name="A", profile="Democratic candidate", goal="Win the election", actions=[a1], watch=[a2], config=gpt4) + """ + dicts = [dict(os.environ)] + dicts += [config] + final = merge_dict(dicts) + return Config(**final) + def update_via_cli(self, project_path, project_name, inc, reqa_file, max_auto_summarize_code): """update config via cli"""