mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-15 11:02:36 +02:00
Clean up existing unused code according to flake8
This commit is contained in:
parent
0722257cd8
commit
d74215c502
68 changed files with 57 additions and 161 deletions
|
|
@ -510,4 +510,3 @@ Process finished with exit code 1'''
|
|||
|
||||
MEILI_CODE_REFINED = """
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,7 @@
|
|||
@Author : alexanderwu
|
||||
@File : test_action.py
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from metagpt.actions import Action, WritePRD, WriteTest
|
||||
from metagpt.logs import logger
|
||||
|
||||
|
||||
def test_action_repr():
|
||||
|
|
|
|||
|
|
@ -14,12 +14,10 @@ from metagpt.actions.debug_error import DebugError
|
|||
async def test_debug_error():
|
||||
code = "def add(a, b):\n return a - b"
|
||||
error = "AssertionError: Expected add(1, 1) to equal 2 but got 0"
|
||||
fixed_code = "def add(a, b):\n return a + b"
|
||||
|
||||
debug_error = DebugError("debug_error")
|
||||
|
||||
result = await debug_error.run(code, error)
|
||||
|
||||
prompt = f"以下是一段Python代码:\n\n{code}\n\n执行时发生了以下错误:\n\n{error}\n\n请尝试修复这段代码中的错误。"
|
||||
# mock_llm.ask.assert_called_once_with(prompt)
|
||||
assert len(result) > 0
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions.design_api import WriteDesign
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles.architect import Architect
|
||||
from tests.metagpt.actions.mock import PRD_SAMPLE
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ API列表:
|
|||
3. next(): 跳到播放列表的下一首歌曲。
|
||||
4. previous(): 跳到播放列表的上一首歌曲。
|
||||
"""
|
||||
api_review = "API设计看起来非常合理,满足了PRD中的所有需求。"
|
||||
_ = "API设计看起来非常合理,满足了PRD中的所有需求。"
|
||||
|
||||
design_api_review = DesignReview("design_api_review")
|
||||
|
||||
result = await design_api_review.run(prd, api_design)
|
||||
|
||||
prompt = f"以下是产品需求文档(PRD):\n\n{prd}\n\n以下是基于这个PRD设计的API列表:\n\n{api_design}\n\n请审查这个API设计是否满足PRD的需求,以及是否符合良好的设计实践。"
|
||||
_ = f"以下是产品需求文档(PRD):\n\n{prd}\n\n以下是基于这个PRD设计的API列表:\n\n{api_design}\n\n请审查这个API设计是否满足PRD的需求,以及是否符合良好的设计实践。"
|
||||
# mock_llm.ask.assert_called_once_with(prompt)
|
||||
assert len(result) > 0
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
@File : test_project_management.py
|
||||
"""
|
||||
|
||||
from metagpt.actions.project_management import AssignTasks, WriteTasks
|
||||
|
||||
|
||||
class TestCreateProjectPlan:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -36,4 +36,3 @@ result = add(1, '2')
|
|||
result = await run_code.run(code)
|
||||
|
||||
assert "TypeError: unsupported operand type(s) for +" in result
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions.write_code_review import WriteCodeReview
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.logs import logger
|
||||
from tests.metagpt.actions.mock import SEARCH_CODE_SAMPLE
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"""
|
||||
import pytest
|
||||
|
||||
from metagpt.actions import BossRequirement, WritePRD
|
||||
from metagpt.actions import BossRequirement
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles.product_manager import ProductManager
|
||||
from metagpt.schema import Message
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions.write_test import WriteTest
|
||||
from metagpt.logs import logger
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@
|
|||
@Author : alexanderwu
|
||||
@File : test_chromadb_store.py
|
||||
"""
|
||||
import pytest
|
||||
from sentence_transformers import SentenceTransformer
|
||||
|
||||
from metagpt.document_store.chromadb_store import ChromaStore
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@File : test_document.py
|
||||
"""
|
||||
import pytest
|
||||
from loguru import logger
|
||||
|
||||
from metagpt.const import DATA_PATH
|
||||
from metagpt.document_store.document import Document
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import pytest
|
|||
|
||||
from metagpt.const import DATA_PATH
|
||||
from metagpt.document_store import FaissStore
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import CustomerService, Sales
|
||||
|
||||
DESC = """## 原则(所有事情都不可绕过原则)
|
||||
|
|
|
|||
|
|
@ -221,11 +221,8 @@ task_list = [
|
|||
```
|
||||
'''
|
||||
|
||||
|
||||
|
||||
TASK = """smart_search_engine/knowledge_base.py"""
|
||||
|
||||
|
||||
STRS_FOR_PARSING = [
|
||||
"""
|
||||
## 1
|
||||
|
|
|
|||
|
|
@ -7,16 +7,9 @@
|
|||
"""
|
||||
import pytest
|
||||
|
||||
from metagpt.actions import BossRequirement
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import Architect
|
||||
from metagpt.schema import Message
|
||||
from tests.metagpt.roles.mock import (
|
||||
BOSS_REQUIREMENT,
|
||||
DETAIL_REQUIREMENT,
|
||||
PRD,
|
||||
MockMessages,
|
||||
)
|
||||
from tests.metagpt.roles.mock import MockMessages
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -5,19 +5,13 @@
|
|||
@Author : alexanderwu
|
||||
@File : test_engineer.py
|
||||
"""
|
||||
import ast
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles.engineer import Engineer
|
||||
from metagpt.schema import Message
|
||||
from metagpt.utils.common import CodeParser
|
||||
from tests.metagpt.roles.mock import (
|
||||
PRD,
|
||||
STRS_FOR_PARSING,
|
||||
SYSTEM_DESIGN,
|
||||
TASKS,
|
||||
TASKS_TOMATO_CLOCK,
|
||||
MockMessages,
|
||||
|
|
@ -71,6 +65,9 @@ def test_parse_file_list():
|
|||
assert isinstance(tasks, list)
|
||||
assert target_list == tasks
|
||||
|
||||
file_list = CodeParser.parse_file_list("Task list", TASKS_TOMATO_CLOCK, lang="python")
|
||||
logger.info(file_list)
|
||||
|
||||
|
||||
target_code = """task_list = [
|
||||
"smart_search_engine/knowledge_base.py",
|
||||
|
|
@ -93,8 +90,3 @@ def test_parse_code():
|
|||
logger.info(code)
|
||||
assert isinstance(code, str)
|
||||
assert target_code == code
|
||||
|
||||
|
||||
def test_parse_file_list():
|
||||
file_list = CodeParser.parse_file_list("Task list", TASKS_TOMATO_CLOCK, lang="python")
|
||||
logger.info(file_list)
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@
|
|||
"""
|
||||
import pytest
|
||||
|
||||
from metagpt.actions import BossRequirement
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import ProductManager
|
||||
from metagpt.schema import Message
|
||||
from tests.metagpt.roles.mock import BOSS_REQUIREMENT, DETAIL_REQUIREMENT, MockMessages
|
||||
from tests.metagpt.roles.mock import MockMessages
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ import pytest
|
|||
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import ProjectManager
|
||||
from metagpt.schema import Message
|
||||
from tests.metagpt.roles.mock import SYSTEM_DESIGN, MockMessages
|
||||
from tests.metagpt.roles.mock import MockMessages
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -5,4 +5,3 @@
|
|||
@Author : alexanderwu
|
||||
@File : test_qa_engineer.py
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class TestGPT:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_llm_api_costs(self, llm_api):
|
||||
answer = await llm_api.aask('hello chatgpt')
|
||||
await llm_api.aask('hello chatgpt')
|
||||
costs = llm_api.get_costs()
|
||||
logger.info(costs)
|
||||
assert costs.total_cost > 0
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ async def test_llm_aask_batch(llm):
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_llm_aask(llm):
|
||||
|
||||
async def test_llm_acompletion(llm):
|
||||
hello_msg = [{'role': 'user', 'content': 'hello'}]
|
||||
assert len(await llm.acompletion(hello_msg)) > 0
|
||||
assert len(await llm.acompletion_batch([hello_msg])) > 0
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ def test_messages():
|
|||
]
|
||||
text = str(msgs)
|
||||
roles = ['user', 'system', 'assistant', 'QA']
|
||||
assert all([i in text for i in roles])
|
||||
assert all([i in text for i in roles])
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
import pytest
|
||||
|
||||
from metagpt.logs import logger
|
||||
from metagpt.tools.search_engine import SearchEngine
|
||||
|
||||
CASES = [
|
||||
"""# 上下文
|
||||
[{'title': '抗痘 / 控油 / 毛孔調理 臉部保養 商品 | 屈臣氏 Watsons', 'href': 'https://www.watsons.com.tw/%E8%87%89%E9%83%A8%E4%BF%9D%E9%A4%8A/%E6%8A%97%E7%97%98-%E6%8E%A7%E6%B2%B9-%E6%AF%9B%E5%AD%94%E8%AA%BF%E7%90%86/c/10410601', 'body': '抗痘 / 控油 / 毛孔調理等臉部保養用品盡在屈臣氏,多樣抗痘 / 控油 / 毛孔調理商品全面符合您的需求。3M, 3M Nexcare, ARIN, Biore 蜜妮, CEZANNE等眾多推薦品牌快來屈臣氏選購。'}, {'title': '有哪些祛痘印产品曾惊艳过你? - 知乎', 'href': 'https://www.zhihu.com/question/380098171', 'body': '有哪些祛痘印产品曾惊艳过你? ... 素姬水杨酸精华 祛痘产品里绝对不能少了水杨酸这个成分!用这个品牌主要是信赖它的温和性,而且价格便宜,去粉刺痘痘效果又好,对闭口和黑头都有效果。 ... 购买比较方便,我在屈臣氏买的,50RMB. 西班牙IFC duo祛痘凝露 ...'}, {'title': '屈臣氏祛痘系列_百度知道', 'href': 'https://zhidao.baidu.com/question/581355167.html', 'body': '2014-08-28 屈臣氏里有哪些祛痘效果好的产品? 26 2007-08-25 屈臣氏有卖哪些祛痘产品 61 2019-05-27 屈臣氏有哪些祛痘产品 什么方法会比较好?? 2015-09-27 屈臣氏白金祛痘系列的使用顺序 30 2014-11-03 屈臣氏卖的祛痘产品叫什么 1 2011-05-24 屈臣氏的祛痘好用的产品有那些 ...'}, {'title': '屈臣氏里有哪些祛痘效果好的产品? - 百度知道', 'href': 'https://zhidao.baidu.com/question/360679400530686652.html', 'body': '阿达帕林是一款医药系列的祛痘产品,它里面蕴含了非常丰富的甲酸类化合物,涂抹在皮肤上会有很好的消炎效果,对于粉刺、闭口、痘痘等痤疮系列的皮肤问题也有很好的修复,可以让毛囊上的皮肤细胞正常分化。. 用户实测评分:9.663分. 实验室效果评测:9. ...'}, {'title': '33款屈臣氏最值得买的好物! - 知乎 - 知乎专栏', 'href': 'https://zhuanlan.zhihu.com/p/31366278', 'body': '屈臣氏深层卸妆棉. 19.9元/25*2. 一般出差不想带很多瓶瓶罐罐就会带卸妆棉,当时是买一送一,就觉得超划算。. 棉质很好,很舒服,厚度适中,温和不刺激,淡淡的香味,卸得很舒心,卸得也很干净。. 眼妆也可以用这个卸,因为它不含酒精,所以一点也不辣 ...'}, {'title': '屈臣氏官网 - Watsons', 'href': 'https://www.watsons.com.cn/', 'body': '屈臣氏百年正品口碑,现金优惠多多多,2小时闪电送到家,还能屈臣氏门店自提。美妆洗护,口腔保健,日用百货,男士护理,更便捷的操作,满足你更多。屈臣氏始创于1841年,线下门店覆盖全球12个国家地区,超过5500家门店。在中国,400多个城市已超过3000家门店,6000万名会员与你一起放心买好货!'}, {'title': '15款日本最具口碑的祛痘神器! - 知乎 - 知乎专栏', 'href': 'https://zhuanlan.zhihu.com/p/63349036', 'body': '乐敦. Acnes药用祛痘抗痘粉尘暗疮药膏. 药用抗痘药膏清爽啫哩質地,维生素E衍生物,维生素B6组合,膏体不腻,轻透很好吸收,淡淡清香味主要针对红肿且疼痛的大颗痘痘,排出脓液、杀灭细菌、消除红肿,第二天就会有效果。. DHC. 祛痘净痘调理精华. 含有o-Cymen ...'}, {'title': '请问屈臣氏什么产品可以去痘疤的 - Sina', 'href': 'https://iask.sina.com.cn/b/1STygN4RT2wZ.html', 'body': '请问屈臣氏什么产品可以去痘疤的本人很少长痘痘,偶尔冒几颗。脸颊上的痘痘来的快去的快,不怎么留疤,就是额头和下巴嘴角边的痘痘感觉超级敏感,一挤就留疤,苦恼! ... 想问下屈臣氏有什么产品能去痘疤的,要有效哦~谢谢各位了! ...'}, {'title': '屈臣氏祛痘凝胶新款 - 屈臣氏祛痘凝胶2021年新款 - 京东', 'href': 'https://www.jd.com/xinkuan/16729c68245569aae4c3.html', 'body': '屈臣氏芦荟凝胶清凉滋润舒缓祛痘印痘坑痘疤补水保湿晒后修复凝胶 【保湿芦荟凝胶】3瓶900g. 2+ 条评论. 屈臣氏 Leaf Simple简单叶子水杨酸祛痘凝胶去痘印粉刺闭口淡化痘坑研春堂收缩毛孔改善粉刺 两支. 4+ 条评论. 屈臣氏 Leaf Simple简单叶子水杨酸祛痘凝胶去痘印 ...'}]
|
||||
|
|
|
|||
|
|
@ -5,18 +5,12 @@
|
|||
@Author : alexanderwu
|
||||
@File : test_custom_aio_session.py
|
||||
"""
|
||||
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from metagpt.logs import logger
|
||||
from metagpt.provider.openai_api import OpenAIGPTAPI
|
||||
from metagpt.utils.custom_aio_session import CustomAioSession
|
||||
|
||||
|
||||
async def try_hello(api):
|
||||
batch = [[{'role': 'user', 'content': 'hello'}],]
|
||||
batch = [[{'role': 'user', 'content': 'hello'}]]
|
||||
results = await api.acompletion_batch_text(batch)
|
||||
return results
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@
|
|||
@Author : chengmaoyu
|
||||
@File : test_output_parser.py
|
||||
"""
|
||||
|
||||
import ast
|
||||
import re
|
||||
from typing import List, Tuple
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
@File : test_read_docx.py
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from metagpt.const import PROJECT_ROOT
|
||||
from metagpt.utils.read_document import read_docx
|
||||
|
||||
|
|
|
|||
|
|
@ -66,4 +66,4 @@ def test_count_string_tokens_gpt_4():
|
|||
"""Test that the string tokens are counted correctly."""
|
||||
|
||||
string = "Hello, world!"
|
||||
assert count_string_tokens(string, model_name="gpt-4-0314") == 4
|
||||
assert count_string_tokens(string, model_name="gpt-4-0314") == 4
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue