Skip to content

Commit 9f1adaa

Browse files
authored
Merge pull request #4 from KyMidd/feature/restore-bedrock-agent-runtime-client
restore bedrock agent runtime client
2 parents cd6ae3c + 0bb747d commit 9f1adaa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

python/devopsbot.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@
6464

6565

6666
# Function to retrieve info from RAG with knowledge base
67-
def ask_bedrock_llm_with_knowledge_base(flat_conversation, knowledge_base_id, bedrock_client) -> str:
67+
def ask_bedrock_llm_with_knowledge_base(flat_conversation, knowledge_base_id) -> str:
68+
69+
# Create a Bedrock agent runtime client
70+
bedrock_agent_runtime_client = boto3.client(
71+
"bedrock-agent-runtime",
72+
region_name=model_region_name
73+
)
6874

6975
# uses embedding model to retrieve and generate a response
70-
response = bedrock_client.retrieve(
76+
response = bedrock_agent_runtime_client.retrieve(
7177
retrievalQuery={
7278
'text': flat_conversation
7379
},
@@ -617,7 +623,7 @@ def handle_message_event(client, body, say, bedrock_client, app, token, register
617623
print(f"🚀 Flat conversation: {flat_conversation}")
618624

619625
# Get context data from the knowledge base
620-
knowledge_base_response = ask_bedrock_llm_with_knowledge_base(flat_conversation, ConfluenceKnowledgeBaseId, bedrock_client)
626+
knowledge_base_response = ask_bedrock_llm_with_knowledge_base(flat_conversation, ConfluenceKnowledgeBaseId)
621627

622628
if os.environ.get("VERA_DEBUG", "False") == "True":
623629
print(f"🚀 Knowledge base response: {knowledge_base_response}")

0 commit comments

Comments
 (0)