diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index ed02575db..f605f5010 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -14,7 +14,9 @@ from __future__ import annotations from typing import Iterable, Type, Dict from pydantic import BaseModel, Field -from metagpt.provider.openai_api import OpenAIGPTAPI as LLM + +from metagpt.config import Config +from metagpt.provider.openai_api import OpenAIGPTAPI as LLM, CostManager from metagpt.actions import Action, ActionOutput from metagpt.logs import logger from metagpt.memory import Memory, LongTermMemory @@ -100,7 +102,11 @@ class RoleContext(BaseModel): class Role: """Role/Proxy""" - def __init__(self, options, cost_manager, name="", profile="", goal="", constraints="", desc="", *args, **kwargs): + 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) self._options = Role.supply_options(options=kwargs, default_options=options) name = Role.format_value(name, self._options)