From 29ab673480d9f9ae3159b75a64b48e148703ccfc Mon Sep 17 00:00:00 2001 From: rookie727 Date: Wed, 20 Nov 2024 22:46:06 +0800 Subject: [PATCH] Add support for importing model configurations from YAML files --- src/agentscope/manager/_model.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/agentscope/manager/_model.py b/src/agentscope/manager/_model.py index 0f63f14be..953283c14 100644 --- a/src/agentscope/manager/_model.py +++ b/src/agentscope/manager/_model.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """The model manager for AgentScope.""" import json +import yaml from typing import Any, Union, Sequence from loguru import logger @@ -80,8 +81,12 @@ def load_model_configs( cfgs = None if isinstance(model_configs, str): - with open(model_configs, "r", encoding="utf-8") as f: - cfgs = json.load(f) + if model_configs.endswith(".yaml"): + with open(model_configs, "r", encoding="utf-8") as f: + cfgs = yaml.safe_load(f) + else: + with open(model_configs, "r", encoding="utf-8") as f: + cfgs = json.load(f) if isinstance(model_configs, dict): cfgs = [model_configs]