From ac744062609d6218b5cac72be5916067667f9d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Mon, 28 Aug 2023 11:55:09 +0800 Subject: [PATCH] =?UTF-8?q?fixbug:=20+=E7=BC=BA=E7=9C=81=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/actions/action.py | 5 +++-- metagpt/roles/role.py | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/metagpt/actions/action.py b/metagpt/actions/action.py index 86a6664ba..10579d4f4 100644 --- a/metagpt/actions/action.py +++ b/metagpt/actions/action.py @@ -12,13 +12,14 @@ from typing import Optional from tenacity import retry, stop_after_attempt, wait_fixed from metagpt.actions.action_output import ActionOutput +from metagpt.config import Config from metagpt.utils.common import OutputParser from metagpt.logs import logger class Action(ABC): - def __init__(self, options, name: str = '', context=None, llm=None): - self.options = options + def __init__(self, options=None, name: str = '', context=None, llm=None): + self.options = options or Config().runtime_options self.name: str = name self.llm = llm self.context = context diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index f605f5010..4f46bb973 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -103,10 +103,9 @@ class Role: """Role/Proxy""" def __init__(self, options=None, cost_manager=None, name="", profile="", goal="", constraints="", desc="", *args, **kwargs): - if not options: - options = Config().runtime_options - if not cost_manager: - cost_manager = CostManager(*options) + options = options or Config().runtime_options + cost_manager = cost_manager or CostManager(*options) + self._options = Role.supply_options(options=kwargs, default_options=options) name = Role.format_value(name, self._options)