From 61557a101adba5755bdabe39ed9ae0903450610a Mon Sep 17 00:00:00 2001 From: H <43509927+guoyuhao2330@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:20:19 +0800 Subject: [PATCH] fix botocore (#1414) ### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/llm/chat_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index 7f70e45bc..f7f137b6f 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -539,7 +539,6 @@ class BedrockChat(Base): def __init__(self, key, model_name, **kwargs): import boto3 - from botocore.exceptions import ClientError self.bedrock_ak = eval(key).get('bedrock_ak', '') self.bedrock_sk = eval(key).get('bedrock_sk', '') self.bedrock_region = eval(key).get('bedrock_region', '') @@ -548,6 +547,7 @@ class BedrockChat(Base): aws_access_key_id=self.bedrock_ak, aws_secret_access_key=self.bedrock_sk) def chat(self, system, history, gen_conf): + from botocore.exceptions import ClientError if system: history.insert(0, {"role": "system", "content": system}) for k in list(gen_conf.keys()): @@ -576,6 +576,7 @@ class BedrockChat(Base): return f"ERROR: Can't invoke '{self.model_name}'. Reason: {e}", 0 def chat_streamly(self, system, history, gen_conf): + from botocore.exceptions import ClientError if system: history.insert(0, {"role": "system", "content": system}) for k in list(gen_conf.keys()):