Merge pull request #997 from liujun3660105/feat/add-cusotm-llm-config

feat:add user llm config
This commit is contained in:
Alexander Wu 2024-03-15 23:32:56 +08:00 committed by GitHub
commit eb8e8460b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,6 +100,20 @@ class Config(CLIParams, YamlModel):
final = merge_dict(dicts)
return Config(**final)
@classmethod
def from_llm_config(cls, llm_config: dict):
"""user config llm
example:
llm_config = {"api_type": "xxx", "api_key": "xxx", "model": "xxx"}
gpt4 = Config.from_llm_config(llm_config)
A = Role(name="A", profile="Democratic candidate", goal="Win the election", actions=[a1], watch=[a2], config=gpt4)
"""
llm_config = LLMConfig.model_validate(llm_config)
dicts = [dict(os.environ)]
dicts += [{"llm": llm_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"""