feat: CostManager改pydantic结构,以备RPC传参

This commit is contained in:
莘权 马 2023-08-22 19:47:35 +08:00
parent 9600787d63
commit 19767496b1
7 changed files with 26 additions and 31 deletions

View file

@ -19,7 +19,7 @@ from tests.metagpt.actions.mock import TASKS_2, WRITE_CODE_PROMPT_SAMPLE
async def test_write_code():
api_design = "设计一个名为'add'的函数,该函数接受两个整数作为输入,并返回它们的和。"
conf = Config()
cost_manager = CostManager(conf.runtime_options)
cost_manager = CostManager(**conf.runtime_options)
llm = LLM(options=conf.runtime_options, cost_manager=cost_manager)
write_code = WriteCode(options=conf.runtime_options, name="write_code", llm=llm)
@ -35,6 +35,6 @@ async def test_write_code():
async def test_write_code_directly():
prompt = WRITE_CODE_PROMPT_SAMPLE + '\n' + TASKS_2[0]
options = Config().runtime_options
llm = LLM(options=options, cost_manager=CostManager(options=options))
llm = LLM(options=options, cost_manager=CostManager(**options))
rsp = await llm.aask(prompt)
logger.info(rsp)

View file

@ -26,7 +26,7 @@ def env():
def test_add_role(env: Environment):
conf = Config()
cost_manager = CostManager(options=conf.runtime_options)
cost_manager = CostManager(**conf.runtime_options)
role = ProductManager(options=conf.runtime_options,
cost_manager=cost_manager,
name="Alice",
@ -39,7 +39,7 @@ def test_add_role(env: Environment):
def test_get_roles(env: Environment):
conf = Config()
cost_manager = CostManager(options=conf.runtime_options)
cost_manager = CostManager(**conf.runtime_options)
role1 = Role(options=conf.runtime_options, cost_manager=cost_manager, name="Alice", profile="product manager",
goal="create a new product", constraints="limited resources")
role2 = Role(options=conf.runtime_options, cost_manager=cost_manager, name="Bob", profile="engineer",
@ -53,7 +53,7 @@ def test_get_roles(env: Environment):
@pytest.mark.asyncio
async def test_publish_and_process_message(env: Environment):
conf = Config()
cost_manager = CostManager(options=conf.runtime_options)
cost_manager = CostManager(**conf.runtime_options)
product_manager = ProductManager(options=conf.runtime_options,
cost_manager=cost_manager,
name="Alice", profile="Product Manager",

View file

@ -16,7 +16,7 @@ from metagpt.provider.openai_api import OpenAIGPTAPI as LLM, CostManager
@pytest.fixture()
def llm():
options = Config().runtime_options
return LLM(options=options, cost_manager=CostManager(options))
return LLM(options=options, cost_manager=CostManager(**options))
@pytest.mark.asyncio