🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
fixbug: config.yaml
莘权 马6a1690095364
diff --git a/config/config.yaml b/config/config.yamlindex 711110f97..5025a4977 100644--- a/config/config.yaml+++ b/config/config.yaml@@ -121,7 +121,6 @@ TIMEOUT: 60 # Timeout for llm invocation# PROMPT_FORMAT: json #json or markdown-<<<<<<< HEAD### Agent configurations# RAISE_NOT_CONFIG_ERROR: true # "true" if the LLM key is not configured, throw a NotConfiguredException, else "false".# WORKSPACE_PATH_WITH_UID: false # "true" if using `{workspace}/{uid}` as the workspace path; "false" use `{workspace}`.diff --git a/metagpt/tools/azure_tts.py b/metagpt/tools/azure_tts.pyindex 8fdb10c13..d3e67c269 100644--- a/metagpt/tools/azure_tts.py+++ b/metagpt/tools/azure_tts.py@@ -6,7 +6,6 @@@File : azure_tts.py@Modified by: mashenquan, 2023/8/17. Azure TTS OAS3 api, which provides text-to-speech functionality"""-import asyncioimport base64from pathlib import Pathfrom uuid import uuid4@@ -14,7 +13,7 @@ from uuid import uuid4import aiofilesfrom azure.cognitiveservices.speech import AudioConfig, SpeechConfig, SpeechSynthesizer-from metagpt.config import CONFIG, Config+from metagpt.config import CONFIGfrom metagpt.logs import logger@@ -103,11 +102,3 @@ async def oas3_azsure_tts(text, lang="", voice="", style="", role="", subscriptireturn ""return base64_string---if __name__ == "__main__":- Config()- loop = asyncio.new_event_loop()- v = loop.create_task(oas3_azsure_tts("测试,test"))- loop.run_until_complete(v)- print(v)diff --git a/metagpt/tools/hello.py b/metagpt/tools/hello.pyindex 8a21e1b4e..52d2d11c1 100644--- a/metagpt/tools/hello.py+++ b/metagpt/tools/hello.py@@ -12,6 +12,7 @@-H 'Content-Type: application/json' \-d '{}'"""+from pathlib import Pathimport connexion@@ -22,6 +23,7 @@ async def post_greeting(name: str) -> str:if __name__ == "__main__":- app = connexion.AioHttpApp(__name__, specification_dir="../../.well-known/")+ specification_dir = Path(__file__).parent.parent.parent / ".well-known"+ app = connexion.AsyncApp(__name__, specification_dir=str(specification_dir))app.add_api("openapi.yaml", arguments={"title": "Hello World Example"})app.run(port=8080)diff --git a/requirements-test.txt b/requirements-test.txtnew file mode 100644index 000000000..39ba608b7--- /dev/null+++ b/requirements-test.txt@@ -0,0 +1,5 @@+# For unit test+-r requirements.txt++connexion[uvicorn]~=3.0.5+azure-cognitiveservices-speech~=1.31.0\ No newline at end of filediff --git a/requirements.txt b/requirements.txtindex 5cb01ab99..f2566fb15 100644--- a/requirements.txt+++ b/requirements.txt@@ -40,12 +40,12 @@ typing_extensions==4.7.0libcst==1.0.1qdrant-client==1.4.0pytest-mock==3.11.1-# open-interpreter==0.1.7; python_version>"3.9"+# open-interpreter==0.1.7; python_version>"3.9" # Conflict with openai 1.xta==0.10.2semantic-kernel==0.4.0.dev0wrapt==1.15.0#aiohttp_jinja2-#azure-cognitiveservices-speech~=1.31.0+# azure-cognitiveservices-speech~=1.31.0 # Used by metagpt/tools/azure_tts.py#aioboto3~=11.3.0#redis==4.3.5websocket-client==1.6.2@@ -54,8 +54,8 @@ gitpython==3.1.40zhipuai==1.0.7socksio~=1.0.0gitignore-parser==0.1.9-# connexion[swagger-ui]+# connexion[uvicorn]~=3.0.5 # Used by metagpt/tools/hello.pywebsockets~=12.0networkx~=3.2.1google-generativeai==0.3.1-playwright==1.40.0\ No newline at end of file+playwright==1.40.0diff --git a/tests/metagpt/tools/test_azure_tts.py b/tests/metagpt/tools/test_azure_tts.pyindex b7f94a19c..38fef557e 100644--- a/tests/metagpt/tools/test_azure_tts.py+++ b/tests/metagpt/tools/test_azure_tts.py@@ -7,13 +7,20 @@@Modified By: mashenquan, 2023-8-9, add more text formatting options@Modified By: mashenquan, 2023-8-17, move to `tools` folder."""-import asyncio++import pytest+from azure.cognitiveservices.speech import ResultReasonfrom metagpt.config import CONFIGfrom metagpt.tools.azure_tts import AzureTTS-def test_azure_tts():+async def test_azure_tts():+ # Prerequisites+ assert CONFIG.AZURE_TTS_SUBSCRIPTION_KEY and CONFIG.AZURE_TTS_SUBSCRIPTION_KEY != "YOUR_API_KEY"+ assert CONFIG.AZURE_TTS_REGION+azure_tts = AzureTTS(subscription_key="", region="")text = """女儿看见父亲走了进来,问道:@@ -25,20 +32,19 @@ def test_azure_tts():“Writing a binary file in Python is similar to writing a regular text file, but you'll work with bytes instead of strings.”</mstts:express-as>"""- path = CONFIG.workspace / "tts"+ path = CONFIG.workspace_path / "tts"path.mkdir(exist_ok=True, parents=True)filename = path / "girl.wav"- loop = asyncio.new_event_loop()- v = loop.create_task(- azure_tts.synthesize_speech(lang="zh-CN", voice="zh-CN-XiaomoNeural", text=text, output_file=str(filename))+ filename.unlink(missing_ok=True)+ result = await azure_tts.synthesize_speech(+ lang="zh-CN", voice="zh-CN-XiaomoNeural", text=text, output_file=str(filename))- result = loop.run_until_complete(v)-print(result)-- # 运行需要先配置 SUBSCRIPTION_KEY- # TODO: 这里如果要检验,还要额外加上对应的asr,才能确保前后生成是接近一致的,但现在还没有+ assert result+ assert result.audio_data+ assert result.reason == ResultReason.SynthesizingAudioCompleted+ assert filename.exists()if __name__ == "__main__":- test_azure_tts()+ pytest.main([__file__, "-s"])diff --git a/tests/metagpt/tools/test_code_interpreter.py b/tests/metagpt/tools/test_code_interpreter.pyindex 03d4ce8df..b8380967c 100644--- a/tests/metagpt/tools/test_code_interpreter.py+++ b/tests/metagpt/tools/test_code_interpreter.py@@ -1,3 +1,13 @@+#!/usr/bin/env python+# -*- coding: utf-8 -*-+"""+@Time :+@Author :+@File : test_code_interpreter.py+@Warning : open-interpreter 0.1.17 requires openai<0.29.0,>=0.28.0, but you have openai 1.6.0 which is incompatible.+ open-interpreter 0.1.17 requires tiktoken<0.5.0,>=0.4.0, but you have tiktoken 0.5.2 which is incompatible.+"""+from pathlib import Pathimport pandas as pd@@ -23,6 +33,9 @@ class CreateStockIndicators(Action):@pytest.mark.asyncioasync def test_actions():+ # Prerequisites+ # Conflict with openai 1.x+# 计算指标indicators = ["Simple Moving Average", "BollingerBands"]stocker = CreateStockIndicators()@@ -41,3 +54,7 @@ async def test_actions():f"使用seaborn对{df_path}中与股票布林带有关的数据列的Date, Close, SMA, BB_upper(布林带上界), BB_lower(布林带下界)进行可视化, 可视化图片保存在{figure_path}中。不需要任何指标计算,把Date列转换为日期类型。要求图片优美,BB_upper, BB_lower之间使用合适的颜色填充。")assert Path(figure_path).is_file()+++if __name__ == "__main__":+ pytest.main([__file__, "-s"])diff --git a/tests/metagpt/tools/test_hello.py b/tests/metagpt/tools/test_hello.pynew file mode 100644index 000000000..037dcd1b7--- /dev/null+++ b/tests/metagpt/tools/test_hello.py@@ -0,0 +1,30 @@+#!/usr/bin/env python+# -*- coding: utf-8 -*-+"""+@Time : 2023/12/26+@Author : mashenquan+@File : test_hello.py+"""+import subprocess+from pathlib import Path++import pytest+import requests+++async def test_hello():+ script_pathname = Path(__file__).resolve()+ process = subprocess.Popen(["python", str(script_pathname)])++ url = "http://localhost:8080/openapi/greeting/dave"+ headers = {"accept": "text/plain", "Content-Type": "application/json"}+ data = {}+ response = requests.post(url, headers=headers, json=data)+ assert response.text == "Hello dave\n"++ process.terminate()+++if __name__ == "__main__":+ pytest.main([__file__, "-s"])