From 712dfb23b257e738905a20932531498e177b3194 Mon Sep 17 00:00:00 2001 From: usamimeri_renko <1710269958@qq.com> Date: Tue, 21 May 2024 13:13:10 +0800 Subject: [PATCH 1/6] update qwen --- metagpt/utils/token_counter.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/metagpt/utils/token_counter.py b/metagpt/utils/token_counter.py index a8652e607..e23cf5682 100644 --- a/metagpt/utils/token_counter.py +++ b/metagpt/utils/token_counter.py @@ -128,11 +128,15 @@ DashScope Token price https://help.aliyun.com/zh/dashscope/developer-reference/t Different model has different detail page. Attention, some model are free for a limited time. """ DASHSCOPE_TOKEN_COSTS = { - "qwen-turbo": {"prompt": 0.0011, "completion": 0.0011}, - "qwen-plus": {"prompt": 0.0028, "completion": 0.0028}, - "qwen-max": {"prompt": 0.0, "completion": 0.0}, - "qwen-max-1201": {"prompt": 0.0, "completion": 0.0}, - "qwen-max-longcontext": {"prompt": 0.0, "completion": 0.0}, + "qwen-turbo": {"prompt": 0.00028, "completion": 0.00083}, + "qwen-long": {"prompt": 0.00007, "completion": 0.00028}, + "qwen-plus": {"prompt": 0.00055, "completion": 0.00166}, + "qwen-max": {"prompt": 0.0055, "completion": 0.0166}, + "qwen-max-0428": {"prompt": 0.0055, "completion": 0.0166}, + "qwen-max-0403": {"prompt": 0.0055, "completion": 0.0166}, + "qwen-max-0107": {"prompt": 0.0055, "completion": 0.0166}, + "qwen-max-1201": {"prompt": 0.0166, "completion": 0.0166}, + "qwen-max-longcontext": {"prompt": 0.0055, "completion": 0.0166}, "llama2-7b-chat-v2": {"prompt": 0.0, "completion": 0.0}, "llama2-13b-chat-v2": {"prompt": 0.0, "completion": 0.0}, "qwen-72b-chat": {"prompt": 0.0, "completion": 0.0}, From 700f9aae41ae4ca6eccd82752747078ba975ea5c Mon Sep 17 00:00:00 2001 From: usamimeri_renko <93753250+usamimeri@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:47:15 +0800 Subject: [PATCH 2/6] optimize error message when validating api_key failed --- metagpt/configs/llm_config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/metagpt/configs/llm_config.py b/metagpt/configs/llm_config.py index 12bb8541e..469613dc1 100644 --- a/metagpt/configs/llm_config.py +++ b/metagpt/configs/llm_config.py @@ -12,7 +12,7 @@ from pydantic import field_validator from metagpt.const import LLM_API_TIMEOUT from metagpt.utils.yaml_model import YamlModel - +from metagpt.const import METAGPT_ROOT, CONFIG_ROOT class LLMType(Enum): OPENAI = "openai" @@ -94,7 +94,15 @@ class LLMConfig(YamlModel): @classmethod def check_llm_key(cls, v): if v in ["", None, "YOUR_API_KEY"]: - raise ValueError("Please set your API key in config2.yaml") + 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") + 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") return v @field_validator("timeout") From b9c6c91cfe6f258b5d5c4e289574c63a56e2a4ce Mon Sep 17 00:00:00 2001 From: usamimeri_renko <1710269958@qq.com> Date: Thu, 20 Jun 2024 10:28:26 +0800 Subject: [PATCH 3/6] update qianfan version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 240ab2300..a75b47aea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -66,7 +66,7 @@ anytree ipywidgets==8.1.1 Pillow imap_tools==1.5.0 # Used by metagpt/tools/libs/email_login.py -qianfan==0.3.2 +qianfan==0.3.16 dashscope==1.14.1 rank-bm25==0.2.2 # for tool recommendation gymnasium==0.29.1 From 4797c9116804442c672f4b10bee528276458eb69 Mon Sep 17 00:00:00 2001 From: usamimeri_renko <93753250+usamimeri@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:33:54 +0800 Subject: [PATCH 4/6] Update latest qwen price and max token --- metagpt/utils/token_counter.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/metagpt/utils/token_counter.py b/metagpt/utils/token_counter.py index 43f04cfef..b3391a7e2 100644 --- a/metagpt/utils/token_counter.py +++ b/metagpt/utils/token_counter.py @@ -137,6 +137,18 @@ DashScope Token price https://help.aliyun.com/zh/dashscope/developer-reference/t Different model has different detail page. Attention, some model are free for a limited time. """ DASHSCOPE_TOKEN_COSTS = { + "qwen2-72b-instruct": {"prompt": 0.000714, "completion": 0.001428}, + "qwen2-57b-a14b-instruct": {"prompt": 0.0005, "completion": 0.001}, + "qwen2-7b-instruct": {"prompt": 0.000143, "completion": 0.000286}, + "qwen2-1.5b-instruct": {"prompt": 0, "completion": 0}, + "qwen2-0.5b-instruct": {"prompt": 0, "completion": 0}, + "qwen1.5-110b-chat": {"prompt": 0.001, "completion": 0.002}, + "qwen1.5-72b-chat": {"prompt": 0.000714, "completion": 0.001428}, + "qwen1.5-32b-chat": {"prompt": 0.0005, "completion": 0.001}, + "qwen1.5-14b-chat": {"prompt": 0.000286, "completion": 0.000571}, + "qwen1.5-7b-chat": {"prompt": 0.000143, "completion": 0.000286}, + "qwen1.5-1.8b-chat": {"prompt": 0, "completion": 0}, + "qwen1.5-0.5b-chat": {"prompt": 0, "completion": 0}, "qwen-turbo": {"prompt": 0.00028, "completion": 0.00083}, "qwen-long": {"prompt": 0.00007, "completion": 0.00028}, "qwen-plus": {"prompt": 0.00055, "completion": 0.00166}, @@ -148,7 +160,7 @@ DASHSCOPE_TOKEN_COSTS = { "qwen-max-longcontext": {"prompt": 0.0055, "completion": 0.0166}, "llama2-7b-chat-v2": {"prompt": 0.0, "completion": 0.0}, "llama2-13b-chat-v2": {"prompt": 0.0, "completion": 0.0}, - "qwen-72b-chat": {"prompt": 0.0, "completion": 0.0}, + "qwen-72b-chat": {"prompt": 0.0028, "completion": 0.0028}, "qwen-14b-chat": {"prompt": 0.0011, "completion": 0.0011}, "qwen-7b-chat": {"prompt": 0.00084, "completion": 0.00084}, "qwen-1.8b-chat": {"prompt": 0.0, "completion": 0.0}, @@ -228,6 +240,26 @@ TOKEN_MAX = { "doubao-pro-4k-240515": 4000, "doubao-pro-32k-240515": 32000, "doubao-pro-128k-240515": 128000, + # Qwen https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-7b-14b-72b-api-detailes?spm=a2c4g.11186623.0.i20 + "qwen2-57b-a14b-instruct": 32768, + "qwen2-72b-instruct": 131072, + "qwen2-7b-instruct": 32768, + "qwen2-1.5b-instruct": 32768, + "qwen2-0.5b-instruct": 32768, + "qwen1.5-110b-chat": 32000, + "qwen1.5-72b-chat": 32000, + "qwen1.5-32b-chat": 32000, + "qwen1.5-14b-chat": 8000, + "qwen1.5-7b-chat": 32000, + "qwen1.5-1.8b-chat": 32000, + "qwen1.5-0.5b-chat": 32000, + "codeqwen1.5-7b-chat": 64000, + "qwen-72b-chat": 32000, + "qwen-14b-chat": 8000, + "qwen-7b-chat": 32000, + "qwen-1.8b-longcontext-chat": 32000, + "qwen-1.8b-chat": 8000, + } # For Amazon Bedrock US region From cb89295db87523de44c49e71f7885411ed4174c4 Mon Sep 17 00:00:00 2001 From: usamimeri_renko <93753250+usamimeri@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:05:23 +0800 Subject: [PATCH 5/6] Update requirements.txt --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index a75b47aea..dc8a86ae2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -66,9 +66,9 @@ anytree ipywidgets==8.1.1 Pillow imap_tools==1.5.0 # Used by metagpt/tools/libs/email_login.py -qianfan==0.3.16 -dashscope==1.14.1 +qianfan~=0.3.16 +dashscope~=1.19.3 rank-bm25==0.2.2 # for tool recommendation gymnasium==0.29.1 boto3~=1.34.69 -spark_ai_python~=0.3.30 \ No newline at end of file +spark_ai_python~=0.3.30 From 76b009513a4458a5a7246afd2627f2c65e5df3f0 Mon Sep 17 00:00:00 2001 From: usamimeri_renko <93753250+usamimeri@users.noreply.github.com> Date: Sat, 22 Jun 2024 14:57:47 +0800 Subject: [PATCH 6/6] Update llm_config.py --- metagpt/configs/llm_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metagpt/configs/llm_config.py b/metagpt/configs/llm_config.py index 469613dc1..0284c8993 100644 --- a/metagpt/configs/llm_config.py +++ b/metagpt/configs/llm_config.py @@ -94,8 +94,8 @@ class LLMConfig(YamlModel): @classmethod def check_llm_key(cls, v): if v in ["", None, "YOUR_API_KEY"]: - repo_config_path=(METAGPT_ROOT / "config/config2.yaml") - root_config_path=(CONFIG_ROOT / "config2.yaml") + 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")