Created
March 18, 2025 03:05
-
-
Save KyMidd/2adbb62f008894451e455266576929fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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