From 6452adf82aa16b10ad19d76377672da486aa17ca Mon Sep 17 00:00:00 2001 From: usamimeri_renko <1710269958@qq.com> Date: Thu, 25 Apr 2024 21:47:57 +0800 Subject: [PATCH] update provider package --- metagpt/configs/llm_config.py | 4 +--- metagpt/provider/__init__.py | 2 ++ metagpt/provider/bedrock/amazon_bedrock_api.py | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/metagpt/configs/llm_config.py b/metagpt/configs/llm_config.py index 170005c21..ae8c57ec5 100644 --- a/metagpt/configs/llm_config.py +++ b/metagpt/configs/llm_config.py @@ -100,6 +100,4 @@ class LLMConfig(YamlModel): @classmethod def check_timeout(cls, v): return v or LLM_API_TIMEOUT - - def get(self, key: str, default = None): - return getattr(self, key, default) + diff --git a/metagpt/provider/__init__.py b/metagpt/provider/__init__.py index 14d5e7682..dd5b4f89d 100644 --- a/metagpt/provider/__init__.py +++ b/metagpt/provider/__init__.py @@ -17,6 +17,7 @@ from metagpt.provider.spark_api import SparkLLM from metagpt.provider.qianfan_api import QianFanLLM from metagpt.provider.dashscope_api import DashScopeLLM from metagpt.provider.anthropic_api import AnthropicLLM +from metagpt.provider.bedrock.amazon_bedrock_api import AmazonBedrockLLM __all__ = [ "GeminiLLM", @@ -30,4 +31,5 @@ __all__ = [ "QianFanLLM", "DashScopeLLM", "AnthropicLLM", + "AmazonBedrockLLM" ] diff --git a/metagpt/provider/bedrock/amazon_bedrock_api.py b/metagpt/provider/bedrock/amazon_bedrock_api.py index 2a72de019..7262a11be 100644 --- a/metagpt/provider/bedrock/amazon_bedrock_api.py +++ b/metagpt/provider/bedrock/amazon_bedrock_api.py @@ -39,7 +39,7 @@ class AmazonBedrockLLM(BaseLLM): def _generate_kwargs(self) -> dict: # for now only use temperature due to the difference of request body return { - "temperature": self.config.get("temperature", 0.1), + "temperature": self.config.temperature } def completion(self, messages: list[dict]) -> str: @@ -74,11 +74,12 @@ class AmazonBedrockLLM(BaseLLM): return full_text async def acompletion(self, messages: list[dict]): + # Amazon bedrock doesn't support async now return self._achat_completion(messages) async def _achat_completion(self, messages: list[dict], timeout=USE_CONFIG_TIMEOUT): - # TODO:make it async return self.completion(messages) async def _achat_completion_stream(self, messages: list[dict], timeout=USE_CONFIG_TIMEOUT): return self._chat_completion_stream(messages) +