import pongo
#Replace the key with your actual API key
pongo_client = pongo.PongoClient(PONGO_SECRET_KEY)
query = "What color are apples?"
#pass in the top ~50-100 results from your existing pipeline, passing more results will catch more edge cases but take longer to process
results_to_filter = [{"id": 1, "text": "Oranges are orange", "metadata": {}},
{"id": 2, "text": "Apples can be red or green", "metadata": {}},
{"id": 3, "text": "Grapes can be purple or green", "metadata": {}},
{"id": 4, "text": "Banannas are yellow", "metadata": {}}]
pongo_result = pongo_client.filter(docs=results_to_filter, query=query, num_results=10, public_metadata_field="metadata", key_field="id", text_field='text')
#List of the 10 most relevant documents to the query
filtered_docs = pongo_result.json()