Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,7 +79,7 @@ class ParrotletRetriever:
|
|
| 79 |
docs.append({
|
| 80 |
"Rank": i + 1,
|
| 81 |
"Score": f"{match['score']:.4f}",
|
| 82 |
-
"Document": text
|
| 83 |
"ID": match["concept_id"],
|
| 84 |
})
|
| 85 |
|
|
@@ -94,19 +94,19 @@ retriever = ParrotletRetriever(MODEL_NAME, PINECONE_API_KEY, PINECONE_INDEX_NAME
|
|
| 94 |
def retrieve_documents(query: str, top_k: int = 5):
|
| 95 |
"""Perform retrieval and return results."""
|
| 96 |
if not query.strip():
|
| 97 |
-
return pd.DataFrame(), "
|
| 98 |
|
| 99 |
try:
|
| 100 |
results = retriever.search(query, top_k)
|
| 101 |
if not results:
|
| 102 |
-
return pd.DataFrame(), "
|
| 103 |
|
| 104 |
df = pd.DataFrame(results)
|
| 105 |
-
status = f"
|
| 106 |
return df, status
|
| 107 |
|
| 108 |
except Exception as e:
|
| 109 |
-
return pd.DataFrame(), f"
|
| 110 |
|
| 111 |
|
| 112 |
# =========================
|
|
@@ -119,11 +119,7 @@ SAMPLE_QUERIES = [
|
|
| 119 |
"వాంతులు"
|
| 120 |
]
|
| 121 |
|
| 122 |
-
with gr.Blocks(title="Parrotlet-
|
| 123 |
-
gr.Markdown("""
|
| 124 |
-
# 🦜 Parrotlet-E: Indic Medical Entities Retrieval
|
| 125 |
-
Retrieve top-5 semantically similar medical entities from Pinecone using Parrotlet-E embeddings.
|
| 126 |
-
""")
|
| 127 |
|
| 128 |
with gr.Row():
|
| 129 |
with gr.Column(scale=1):
|
|
@@ -147,7 +143,7 @@ with gr.Blocks(title="Parrotlet-E Retrieval (Pinecone)", theme=gr.themes.Soft())
|
|
| 147 |
label="Top-K Retrieved"
|
| 148 |
)
|
| 149 |
|
| 150 |
-
search_btn = gr.Button("
|
| 151 |
|
| 152 |
with gr.Column(scale=2):
|
| 153 |
results_output = gr.Dataframe(
|
|
|
|
| 79 |
docs.append({
|
| 80 |
"Rank": i + 1,
|
| 81 |
"Score": f"{match['score']:.4f}",
|
| 82 |
+
"Document": text,
|
| 83 |
"ID": match["concept_id"],
|
| 84 |
})
|
| 85 |
|
|
|
|
| 94 |
def retrieve_documents(query: str, top_k: int = 5):
|
| 95 |
"""Perform retrieval and return results."""
|
| 96 |
if not query.strip():
|
| 97 |
+
return pd.DataFrame(), "Please enter a valid query."
|
| 98 |
|
| 99 |
try:
|
| 100 |
results = retriever.search(query, top_k)
|
| 101 |
if not results:
|
| 102 |
+
return pd.DataFrame(), "No results found."
|
| 103 |
|
| 104 |
df = pd.DataFrame(results)
|
| 105 |
+
status = f"Retrieved top {len(results)} documents."
|
| 106 |
return df, status
|
| 107 |
|
| 108 |
except Exception as e:
|
| 109 |
+
return pd.DataFrame(), f"Error: {str(e)}"
|
| 110 |
|
| 111 |
|
| 112 |
# =========================
|
|
|
|
| 119 |
"వాంతులు"
|
| 120 |
]
|
| 121 |
|
| 122 |
+
with gr.Blocks(title="Parrotlet-e Retrieval", theme=gr.themes.Soft()) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
with gr.Row():
|
| 125 |
with gr.Column(scale=1):
|
|
|
|
| 143 |
label="Top-K Retrieved"
|
| 144 |
)
|
| 145 |
|
| 146 |
+
search_btn = gr.Button("retrieve", variant="primary")
|
| 147 |
|
| 148 |
with gr.Column(scale=2):
|
| 149 |
results_output = gr.Dataframe(
|