Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created March 18, 2025 03:05
Show Gist options
  • Select an option

  • Save KyMidd/2adbb62f008894451e455266576929fa to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/2adbb62f008894451e455266576929fa to your computer and use it in GitHub Desktop.
# Function to retrieve info from RAG with knowledge base
def ask_bedrock_llm_with_knowledge_base(flat_conversation, knowledge_base_id, bedrock_client) -> str:
# Structure response
kb_responses = [
{
"text": result['content']['text'],
"url": result['location']['confluenceLocation']['url']
} for result in kb_response['retrievalResults']
]
if enable_rerank:
# Rerank the knowledge base results
kb_responses = rerank_text(
flat_conversation,
kb_responses,
bedrock_client
)
return kb_responses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment