Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Last active March 18, 2025 03:16
Show Gist options
  • Select an option

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

Select an option

Save KyMidd/b69b7dc67a53b8db038c863496b18019 to your computer and use it in GitHub Desktop.
# Format kb_responses into a list of sources
kb_responses_text = []
for kb_response in kb_responses:
kb_responses_text.append(
[
kb_response['text']
]
)
# Flatten
kb_responses_text = [item[0] for item in kb_responses_text]
# Construct body
body = json.dumps(
{
"query": flat_conversation,
"documents": kb_responses_text,
"top_n": rerank_number_of_results,
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment