fix dashcope spell

This commit is contained in:
betterwang 2024-02-24 15:00:45 +08:00
parent 79c71dc5ad
commit 2d17da2826
3 changed files with 8 additions and 8 deletions

View file

@ -37,7 +37,7 @@ from metagpt.provider.base_llm import BaseLLM, LLMConfig
from metagpt.provider.llm_provider_registry import LLMType, register_provider
from metagpt.provider.openai_api import log_and_reraise
from metagpt.utils.cost_manager import CostManager
from metagpt.utils.token_counter import DashScore_TOKEN_COSTS
from metagpt.utils.token_counter import DashScope_TOKEN_COSTS
def build_api_arequest(
@ -167,7 +167,7 @@ class DashScopeLLM(BaseLLM):
def __init_dashscope(self):
self.model = self.config.model
self.api_key = self.config.api_key
self.token_costs = DashScore_TOKEN_COSTS
self.token_costs = DashScope_TOKEN_COSTS
self.aclient: AGeneration = AGeneration
# check support system_message models

View file

@ -91,10 +91,10 @@ QianFan_EndPoint_TOKEN_COSTS = {
}
"""
DashScore Token price https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing
DashScope Token price https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing
Different model has different detail page. Attention, some model are free for a limited time.
"""
DashScore_TOKEN_COSTS = {
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},

View file

@ -62,12 +62,12 @@ async def test_dashscope_acompletion(mocker):
mocker.patch("dashscope.aigc.generation.Generation.call", mock_dashscope_call)
mocker.patch("metagpt.provider.dashscope_api.AGeneration.acall", mock_dashscope_acall)
dashscore_llm = DashScopeLLM(mock_llm_config_dashscope)
dashscope_llm = DashScopeLLM(mock_llm_config_dashscope)
resp = dashscore_llm.completion(messages)
resp = dashscope_llm.completion(messages)
assert resp.choices[0]["message"]["content"] == resp_cont
resp = await dashscore_llm.acompletion(messages)
resp = await dashscope_llm.acompletion(messages)
assert resp.choices[0]["message"]["content"] == resp_cont
await llm_general_chat_funcs_test(dashscore_llm, prompt, messages, resp_cont)
await llm_general_chat_funcs_test(dashscope_llm, prompt, messages, resp_cont)