Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created February 1, 2025 16:45
Show Gist options
  • Save KyMidd/90808c54654440dad88e6fcc8ef72b84 to your computer and use it in GitHub Desktop.
Save KyMidd/90808c54654440dad88e6fcc8ef72b84 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:
# uses embedding model to retrieve vectors
response = bedrock_client.retrieve(
retrievalQuery={
'text': flat_conversation
},
knowledgeBaseId=knowledge_base_id,
retrievalConfiguration={
'vectorSearchConfiguration': {
'numberOfResults': knowledgeBaseContextNumberOfResults,
#'overrideSearchType': "HYBRID", # optional, default is the KB chooses the search type
}
},
)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment