Skip to content

Instantly share code, notes, and snippets.

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

  • Save KyMidd/7a7d68f109011a8ea45f57789a42c777 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/7a7d68f109011a8ea45f57789a42c777 to your computer and use it in GitHub Desktop.
# Iterate through the rank response and reorder the kb_responses and add relevance_score
# We're also filtering just for the most relevant results according to rerank_number_of_results
ranked_kb_responses = [
{
# Use the index value in rank_response to find the correct kb_response
"text": kb_responses[rank_response['index']]["text"],
"url": kb_responses[rank_response['index']]["url"],
"relevance_score": rank_response['relevance_score']
} for rank_response in rank_response_body['results']
]
return ranked_kb_responses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment