Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metagpt/roles/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ async def _react(self) -> Message:
Use llm to select actions in _think dynamically
"""
actions_taken = 0
rsp = Message(content="No actions taken yet") # will be overwritten after Role _act
rsp = Message(content="No actions taken yet", cause_by=Action) # will be overwritten after Role _act
while actions_taken < self.rc.max_react_loop:
# think
await self._think()
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def run(self):
"gradio==3.0.0",
"grpcio-status==1.48.2",
"mock==5.1.0",
"pylint==3.0.3",
]

extras_require["pyppeteer"] = [
Expand Down
10 changes: 9 additions & 1 deletion tests/metagpt/actions/test_write_prd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"""
import pytest

from metagpt.actions import UserRequirement
from metagpt.actions import UserRequirement, WritePRD
from metagpt.config import CONFIG
from metagpt.const import DOCS_FILE_REPO, PRDS_FILE_REPO, REQUIREMENT_FILENAME
from metagpt.logs import logger
from metagpt.roles.product_manager import ProductManager
from metagpt.roles.role import RoleReactMode
from metagpt.schema import Message
from metagpt.utils.common import any_to_str
from metagpt.utils.file_repository import FileRepository


Expand All @@ -22,11 +24,17 @@ async def test_write_prd(new_filename):
product_manager = ProductManager()
requirements = "开发一个基于大语言模型与私有知识库的搜索引擎,希望可以基于大语言模型进行搜索总结"
await FileRepository.save_file(filename=REQUIREMENT_FILENAME, content=requirements, relative_path=DOCS_FILE_REPO)
product_manager.rc.react_mode = RoleReactMode.BY_ORDER
prd = await product_manager.run(Message(content=requirements, cause_by=UserRequirement))
assert prd.cause_by == any_to_str(WritePRD)
logger.info(requirements)
logger.info(prd)

# Assert the prd is not None or empty
assert prd is not None
assert prd.content != ""
assert CONFIG.git_repo.new_file_repository(relative_path=PRDS_FILE_REPO).changed_files


if __name__ == "__main__":
pytest.main([__file__, "-s"])
1 change: 1 addition & 0 deletions tests/metagpt/roles/test_teacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


@pytest.mark.asyncio
@pytest.mark.skip
async def test_init():
class Inputs(BaseModel):
name: str
Expand Down
11 changes: 10 additions & 1 deletion tests/metagpt/tools/test_metagpt_text_to_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@Author : mashenquan
@File : test_metagpt_text_to_image.py
"""
import base64
from unittest.mock import AsyncMock

import pytest

Expand All @@ -13,7 +15,14 @@


@pytest.mark.asyncio
async def test_draw():
async def test_draw(mocker):
# mock
mock_post = mocker.patch("aiohttp.ClientSession.post")
mock_response = AsyncMock()
mock_response.status = 200
mock_response.json.return_value = {"images": [base64.b64encode(b"success")], "parameters": {"size": 1110}}
mock_post.return_value.__aenter__.return_value = mock_response

# Prerequisites
assert CONFIG.METAGPT_TEXT_TO_IMAGE_MODEL_URL

Expand Down
6 changes: 3 additions & 3 deletions tests/metagpt/utils/test_di_graph_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Input(BaseModel):
repo_parser = RepoParser(base_directory=data.path)
symbols = repo_parser.generate_symbols()
for s in symbols:
await GraphRepository.update_graph_db(graph_db=graph, file_info=s)
await GraphRepository.update_graph_db_with_file_info(graph_db=graph, file_info=s)
data = graph.json()
assert data

Expand All @@ -71,11 +71,11 @@ async def test_codes():
for file_info in symbols:
for code_block in file_info.page_info:
try:
val = code_block.json(ensure_ascii=False)
val = code_block.model_dump_json()
assert val
except TypeError as e:
assert not e
await GraphRepository.update_graph_db(graph_db=graph, file_info=file_info)
await GraphRepository.update_graph_db_with_file_info(graph_db=graph, file_info=file_info)
data = graph.json()
assert data
print(data)
Expand Down
2 changes: 2 additions & 0 deletions tests/metagpt/utils/test_read_docx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
@Author : alexanderwu
@File : test_read_docx.py
"""
import pytest

from metagpt.const import METAGPT_ROOT
from metagpt.utils.read_document import read_docx


@pytest.mark.skip # https://copyprogramming.com/howto/python-docx-error-opening-file-bad-magic-number-for-file-header-eoferror
class TestReadDocx:
def test_read_docx(self):
docx_sample = METAGPT_ROOT / "tests/data/docx_for_test.docx"
Expand Down