Create API interface for Semantic Search

Use FastAPI, Uvicorn to create app with API endpoint at /search
Example Query: http://localhost:8000/?q="why sleep?"&t="notes'&n=5
This commit is contained in:
Debanjum Singh Solanky
2021-08-15 17:50:08 -07:00
parent e3088c8cf8
commit d75df54385
3 changed files with 75 additions and 0 deletions

View File

@@ -130,6 +130,16 @@ def render_results(hits, entries, count=5, display_biencoder_results=False):
print(f"CrossScore: {hit['cross-score']:.3f}\n-----------------\n{entries[hit['corpus_id']]}")
def collate_results(hits, entries, count=5, verbose=False):
return [
{
"Entry": entries[hit['corpus_id']],
"Score": f"{hit['cross-score']:.3f}"
}
for hit
in hits[0:count]]
if __name__ == '__main__':
# Setup Argument Parser
parser = argparse.ArgumentParser(description="Map Org-Mode notes into JSONL format")