From 20b362353636b2c58f1efb4dc51626f5f243ae89 Mon Sep 17 00:00:00 2001 From: voidking Date: Tue, 16 Jul 2024 15:21:50 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E5=A4=8D=E5=8D=95=E6=B5=8B?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E9=97=AE=E9=A2=98(=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E5=AE=89=E5=8D=93=E5=8D=95=E6=B5=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/unittest.yaml | 2 +- metagpt/configs/llm_config.py | 11 +++---- metagpt/roles/researcher.py | 4 ++- metagpt/utils/stream_pipe.py | 2 +- metagpt/utils/token_counter.py | 5 ++-- setup.py | 52 +++++++++++++++++---------------- 6 files changed, 40 insertions(+), 36 deletions(-) diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml index afa9faba7..dc5ae605b 100644 --- a/.github/workflows/unittest.yaml +++ b/.github/workflows/unittest.yaml @@ -32,7 +32,7 @@ jobs: run: | export ALLOW_OPENAI_API_CALL=0 mkdir -p ~/.metagpt && cp tests/config2.yaml ~/.metagpt/config2.yaml - pytest tests/ --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20 | tee unittest.txt + pytest tests/ --ignore=tests/metagpt/environment/android_env --ignore=tests/metagpt/ext/android_assistant --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20 | tee unittest.txt - name: Show coverage report run: | coverage report -m diff --git a/metagpt/configs/llm_config.py b/metagpt/configs/llm_config.py index 0284c8993..67fb6afdb 100644 --- a/metagpt/configs/llm_config.py +++ b/metagpt/configs/llm_config.py @@ -10,9 +10,9 @@ from pydantic import field_validator -from metagpt.const import LLM_API_TIMEOUT +from metagpt.const import CONFIG_ROOT, LLM_API_TIMEOUT, METAGPT_ROOT from metagpt.utils.yaml_model import YamlModel -from metagpt.const import METAGPT_ROOT, CONFIG_ROOT + class LLMType(Enum): OPENAI = "openai" @@ -97,12 +97,13 @@ def check_llm_key(cls, v): repo_config_path = METAGPT_ROOT / "config/config2.yaml" root_config_path = CONFIG_ROOT / "config2.yaml" if root_config_path.exists(): - raise ValueError( - f"Please set your API key in {root_config_path}. If you also set your config in {repo_config_path}, \nthe former will overwrite the latter. This may cause unexpected result.\n") + raise ValueError( + f"Please set your API key in {root_config_path}. If you also set your config in {repo_config_path}, \nthe former will overwrite the latter. This may cause unexpected result.\n" + ) elif repo_config_path.exists(): raise ValueError(f"Please set your API key in {repo_config_path}") else: - raise ValueError(f"Please set your API key in config2.yaml") + raise ValueError("Please set your API key in config2.yaml") return v @field_validator("timeout") diff --git a/metagpt/roles/researcher.py b/metagpt/roles/researcher.py index 5c6c1d9f4..8be2ba6f4 100644 --- a/metagpt/roles/researcher.py +++ b/metagpt/roles/researcher.py @@ -58,7 +58,9 @@ async def _act(self) -> Message: ) elif isinstance(todo, WebBrowseAndSummarize): links = instruct_content.links - todos = (todo.run(*url, query=query, system_text=research_system_text) for (query, url) in links.items() if url) + todos = ( + todo.run(*url, query=query, system_text=research_system_text) for (query, url) in links.items() if url + ) if self.enable_concurrency: summaries = await asyncio.gather(*todos) else: diff --git a/metagpt/utils/stream_pipe.py b/metagpt/utils/stream_pipe.py index 1cccda7ee..15a1eef1f 100644 --- a/metagpt/utils/stream_pipe.py +++ b/metagpt/utils/stream_pipe.py @@ -11,7 +11,7 @@ class StreamPipe: - def __init__(self,name=None): + def __init__(self, name=None): self.name = name self.parent_conn, self.child_conn = Pipe() self.finish: bool = False diff --git a/metagpt/utils/token_counter.py b/metagpt/utils/token_counter.py index 0d69fca10..fda19cdba 100644 --- a/metagpt/utils/token_counter.py +++ b/metagpt/utils/token_counter.py @@ -226,8 +226,8 @@ "claude-2.1": 200000, "claude-3-sonnet-20240229": 200000, "claude-3-opus-20240229": 200000, - "claude-3-5-sonnet-20240620":200000, - "claude-3-haiku-20240307":200000, + "claude-3-5-sonnet-20240620": 200000, + "claude-3-haiku-20240307": 200000, "yi-34b-chat-0205": 4000, "yi-34b-chat-200k": 200000, "yi-large": 16385, @@ -263,7 +263,6 @@ "qwen-7b-chat": 32000, "qwen-1.8b-longcontext-chat": 32000, "qwen-1.8b-chat": 8000, - } # For Amazon Bedrock US region diff --git a/setup.py b/setup.py index 6a15d5eda..8ba4c8a72 100644 --- a/setup.py +++ b/setup.py @@ -45,30 +45,6 @@ def run(self): "llama-index-postprocessor-flag-embedding-reranker==0.1.2", "docx2txt==0.8", ], - "android_assistant": [ - "pyshine==0.0.9", - "opencv-python==4.6.0.66", - "protobuf<3.20,>=3.9.2", - "modelscope", - "tensorflow==2.9.1; os_name == 'linux'", - "tensorflow==2.9.1; os_name == 'win32'", - "tensorflow-macos==2.9; os_name == 'darwin'", - "keras==2.9.0", - "torch", - "torchvision", - "transformers", - "opencv-python", - "matplotlib", - "pycocotools", - "SentencePiece", - "tf_slim", - "tf_keras", - "pyclipper", - "shapely", - "groundingdino-py", - "datasets==2.18.0", - "clip-openai", - ], } extras_require["test"] = [ @@ -85,6 +61,9 @@ def run(self): "aioboto3~=12.4.0", "gradio==3.0.0", "grpcio-status==1.48.2", + "grpcio-tools==1.48.2", + "google-api-core==2.17.1", + "protobuf==3.19.6", "pylint==3.0.3", "pybrowsers", ] @@ -93,7 +72,30 @@ def run(self): "pyppeteer>=1.0.2" ] # pyppeteer is unmaintained and there are conflicts with dependencies extras_require["dev"] = (["pylint~=3.0.3", "black~=23.3.0", "isort~=5.12.0", "pre-commit~=3.6.0"],) - +extras_require["android_assistant"] = [ + "pyshine==0.0.9", + "opencv-python==4.6.0.66", + "protobuf<3.20,>=3.9.2", + "modelscope", + "tensorflow==2.9.1; os_name == 'linux'", + "tensorflow==2.9.1; os_name == 'win32'", + "tensorflow-macos==2.9; os_name == 'darwin'", + "keras==2.9.0", + "torch", + "torchvision", + "transformers", + "opencv-python", + "matplotlib", + "pycocotools", + "SentencePiece", + "tf_slim", + "tf_keras", + "pyclipper", + "shapely", + "groundingdino-py", + "datasets==2.18.0", + "clip-openai", +] setup( name="metagpt",