Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,12 +67,13 @@ class ParrotletRetriever:
|
|
| 67 |
|
| 68 |
docs = []
|
| 69 |
for i, match in enumerate(results["matches"]):
|
| 70 |
-
|
|
|
|
| 71 |
docs.append({
|
| 72 |
"Rank": i + 1,
|
| 73 |
-
"Score": f"{match['score']:.
|
| 74 |
"Document": text,
|
| 75 |
-
"ID":
|
| 76 |
})
|
| 77 |
|
| 78 |
return docs
|
|
@@ -126,13 +127,12 @@ with gr.Blocks(title="Parrotlet-e Retrieval", theme=gr.themes.Soft()) as demo:
|
|
| 126 |
inputs=query_input,
|
| 127 |
label="Example Queries"
|
| 128 |
)
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
maximum=10,
|
| 133 |
value=5,
|
| 134 |
-
|
| 135 |
-
|
| 136 |
)
|
| 137 |
|
| 138 |
search_btn = gr.Button("retrieve", variant="primary")
|
|
@@ -148,13 +148,9 @@ with gr.Blocks(title="Parrotlet-e Retrieval", theme=gr.themes.Soft()) as demo:
|
|
| 148 |
|
| 149 |
search_btn.click(
|
| 150 |
fn=retrieve_documents,
|
| 151 |
-
inputs=[query_input,
|
| 152 |
outputs=[results_output, status_box],
|
| 153 |
)
|
| 154 |
|
| 155 |
-
|
| 156 |
-
# =========================
|
| 157 |
-
# Run App
|
| 158 |
-
# =========================
|
| 159 |
if __name__ == "__main__":
|
| 160 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 67 |
|
| 68 |
docs = []
|
| 69 |
for i, match in enumerate(results["matches"]):
|
| 70 |
+
metadata = match["metadata"]
|
| 71 |
+
text = metadata.get("text")
|
| 72 |
docs.append({
|
| 73 |
"Rank": i + 1,
|
| 74 |
+
"Score": f"{match['score']:.2f}",
|
| 75 |
"Document": text,
|
| 76 |
+
"ID": metadata.get("concept_id")
|
| 77 |
})
|
| 78 |
|
| 79 |
return docs
|
|
|
|
| 127 |
inputs=query_input,
|
| 128 |
label="Example Queries"
|
| 129 |
)
|
| 130 |
+
|
| 131 |
+
top_k_input = gr.Number(
|
| 132 |
+
label="K",
|
|
|
|
| 133 |
value=5,
|
| 134 |
+
precision=0,
|
| 135 |
+
interactive=True
|
| 136 |
)
|
| 137 |
|
| 138 |
search_btn = gr.Button("retrieve", variant="primary")
|
|
|
|
| 148 |
|
| 149 |
search_btn.click(
|
| 150 |
fn=retrieve_documents,
|
| 151 |
+
inputs=[query_input, top_k_input],
|
| 152 |
outputs=[results_output, status_box],
|
| 153 |
)
|
| 154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
if __name__ == "__main__":
|
| 156 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|