mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-15 11:02:36 +02:00
Merge branch 'dev' into dev_incremental
This commit is contained in:
commit
32f9fbb46b
24 changed files with 75 additions and 48 deletions
|
|
@ -17,7 +17,7 @@ default_resp = {
|
|||
}
|
||||
|
||||
|
||||
async def mock_zhipuai_acreate_stream(self, **kwargs):
|
||||
async def mock_zhipuai_acreate_stream(**kwargs):
|
||||
class MockResponse(object):
|
||||
async def _aread(self):
|
||||
class Iterator(object):
|
||||
|
|
@ -37,7 +37,7 @@ async def mock_zhipuai_acreate_stream(self, **kwargs):
|
|||
return MockResponse()
|
||||
|
||||
|
||||
async def mock_zhipuai_acreate(self, **kwargs) -> dict:
|
||||
async def mock_zhipuai_acreate(**kwargs) -> dict:
|
||||
return default_resp
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ from typing import Any, Tuple
|
|||
|
||||
import pytest
|
||||
import zhipuai
|
||||
from zhipuai.model_api.api import InvokeType
|
||||
from zhipuai.utils.http_client import headers as zhipuai_default_headers
|
||||
|
||||
from metagpt.provider.zhipuai.zhipu_model_api import ZhiPuModelAPI
|
||||
|
||||
|
|
@ -23,14 +21,7 @@ async def mock_requestor_arequest(self, **kwargs) -> Tuple[Any, Any, str]:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_zhipu_model_api(mocker):
|
||||
header = ZhiPuModelAPI.get_header()
|
||||
zhipuai_default_headers.update({"Authorization": api_key})
|
||||
assert header == zhipuai_default_headers
|
||||
|
||||
ZhiPuModelAPI.get_sse_header()
|
||||
# assert len(sse_header["Authorization"]) == 191
|
||||
|
||||
url_prefix, url_suffix = ZhiPuModelAPI.split_zhipu_api_url(InvokeType.SYNC, kwargs={"model": "chatglm_turbo"})
|
||||
url_prefix, url_suffix = ZhiPuModelAPI(api_key=api_key).split_zhipu_api_url()
|
||||
assert url_prefix == "https://open.bigmodel.cn/api"
|
||||
assert url_suffix == "/paas/v4/chat/completions"
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ def test_parse_code():
|
|||
|
||||
def test_todo():
|
||||
role = Engineer()
|
||||
assert role.todo == any_to_name(WriteCode)
|
||||
assert role.action_description == any_to_name(WriteCode)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -144,3 +144,7 @@ async def test_team_recover_multi_roles_save(mocker, context):
|
|||
assert new_company.env.get_role(role_b.profile).rc.state == 1
|
||||
|
||||
await new_company.run(n_round=4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
@File : test_context.py
|
||||
"""
|
||||
from metagpt.configs.llm_config import LLMType
|
||||
from metagpt.context import CONTEXT, AttrDict, Context
|
||||
from metagpt.context import AttrDict, Context
|
||||
|
||||
|
||||
def test_attr_dict_1():
|
||||
|
|
@ -51,11 +51,12 @@ def test_context_1():
|
|||
|
||||
|
||||
def test_context_2():
|
||||
llm = CONTEXT.config.get_openai_llm()
|
||||
ctx = Context()
|
||||
llm = ctx.config.get_openai_llm()
|
||||
assert llm is not None
|
||||
assert llm.api_type == LLMType.OPENAI
|
||||
|
||||
kwargs = CONTEXT.kwargs
|
||||
kwargs = ctx.kwargs
|
||||
assert kwargs is not None
|
||||
|
||||
kwargs.test_key = "test_value"
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ async def test_config_priority():
|
|||
if not home_dir.exists():
|
||||
assert gpt4t is None
|
||||
gpt35 = Config.default()
|
||||
gpt35.llm.model = "gpt-3.5-turbo-1106"
|
||||
gpt4 = Config.default()
|
||||
gpt4.llm.model = "gpt-4-0613"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from pathlib import Path
|
|||
import pytest
|
||||
|
||||
from metagpt.actions import UserRequirement
|
||||
from metagpt.context import CONTEXT
|
||||
from metagpt.environment import Environment
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import Architect, ProductManager, Role
|
||||
|
|
@ -44,9 +43,9 @@ def test_get_roles(env: Environment):
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_publish_and_process_message(env: Environment):
|
||||
if CONTEXT.git_repo:
|
||||
CONTEXT.git_repo.delete_repository()
|
||||
CONTEXT.git_repo = None
|
||||
if env.context.git_repo:
|
||||
env.context.git_repo.delete_repository()
|
||||
env.context.git_repo = None
|
||||
|
||||
product_manager = ProductManager(name="Alice", profile="Product Manager", goal="做AI Native产品", constraints="资源有限")
|
||||
architect = Architect(
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ async def test_recover():
|
|||
role.recovered = True
|
||||
role.latest_observed_msg = Message(content="recover_test")
|
||||
role.rc.state = 0
|
||||
assert role.first_action == any_to_name(MockAction)
|
||||
assert role.action_description == any_to_name(MockAction)
|
||||
|
||||
rsp = await role.run()
|
||||
assert rsp.cause_by == any_to_str(MockAction)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue