Last active
September 15, 2025 07:30
-
-
Save svngoku/a4bc89fa3c1f8a4b03e2d0212b45259f 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
| import os | |
| from zeroentropy import ZeroEntropy | |
| ZEROENTROPY_API_KEY = os. | |
| client = ZeroEntropy( | |
| api_key=ZEROENTROPY_API_KEY | |
| ) | |
| # Define the name of the collection | |
| collection_name = "african_history_book" | |
| # Perform a search with a rerank | |
| def search_african_history(collection_name, query, k=21, reranker='zerank-1'): | |
| """ | |
| Performs a search on the african history collection. | |
| Args: | |
| collection_name (str): The name of the ZeroEntropy collection. | |
| query (str): The search query. | |
| k (int, optional): The number of top results to return. Defaults to 3. | |
| reranker (str, optional): The reranker to use. Defaults to 'zerank-1'. | |
| Returns: | |
| list: A list of search results. | |
| """ | |
| response = client.queries.top_snippets( | |
| collection_name=collection_name, | |
| query=query, | |
| k=k, | |
| precise_responses=True, | |
| reranker=reranker | |
| ) | |
| return response.results | |
| # Run the function to perform a search | |
| search_african_history(collection_name, "What was the estimated crude oil production in 2018?") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment