mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-29 15:59:42 +02:00
Merge pull request #784 from iorisa/feature/remove_global_context
feat: Replace `CONTEXT` with `Context()`
This commit is contained in:
commit
7f78c56ad7
13 changed files with 49 additions and 32 deletions
BIN
tests/data/audio/hello.mp3
Normal file
BIN
tests/data/audio/hello.mp3
Normal file
Binary file not shown.
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue