fixbug: runtime options

This commit is contained in:
莘权 马 2023-08-28 11:48:38 +08:00
parent aaf18d2641
commit c677897561

View file

@ -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)