mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user