Commit ·
32f8638
1
Parent(s): 5b48ad6
small fixes
Browse files- main.py +1 -1
- ui/components.py +9 -5
- ui/pages.py +4 -2
main.py
CHANGED
|
@@ -309,4 +309,4 @@ ui.run_with(
|
|
| 309 |
if __name__ == "__main__":
|
| 310 |
import uvicorn
|
| 311 |
|
| 312 |
-
uvicorn.run("main:app", host="0.0.0.0", port=7860, log_level="info", reload=
|
|
|
|
| 309 |
if __name__ == "__main__":
|
| 310 |
import uvicorn
|
| 311 |
|
| 312 |
+
uvicorn.run("main:app", host="0.0.0.0", port=7860, log_level="info", reload=False)
|
ui/components.py
CHANGED
|
@@ -29,8 +29,10 @@ def render_answer(result):
|
|
| 29 |
content = result.answer + "\n\n### Sources Cited\n"
|
| 30 |
for idx, passage in enumerate(result.passages):
|
| 31 |
metadata = getattr(passage, "metadata", {})
|
| 32 |
-
title = metadata.get("
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
content += f"{idx + 1}. {title} - {url}\n"
|
| 35 |
|
| 36 |
# Serialize to JSON to handle quotes/newlines safely
|
|
@@ -78,11 +80,13 @@ def render_sources(passages):
|
|
| 78 |
# Extract passage info
|
| 79 |
text = getattr(passage, "text", "")
|
| 80 |
metadata = getattr(passage, "metadata", {})
|
| 81 |
-
paper_title = metadata.get("
|
|
|
|
|
|
|
| 82 |
paper_id = getattr(passage, "paper_id", "")
|
| 83 |
section = metadata.get("section", "")
|
| 84 |
# Try to get PDF URL from metadata
|
| 85 |
-
pdf_url = metadata.get("url", "")
|
| 86 |
|
| 87 |
with ui.expansion().classes("source-card").props("dense") as expansion:
|
| 88 |
# Header slot for title
|
|
@@ -179,7 +183,7 @@ class SearchProgress:
|
|
| 179 |
with ui.step("Reading Documents"):
|
| 180 |
with ui.column().classes("gap-2"):
|
| 181 |
ui.label(
|
| 182 |
-
"
|
| 183 |
).classes("text-slate-600")
|
| 184 |
ui.spinner("dots", size="lg", color="primary")
|
| 185 |
|
|
|
|
| 29 |
content = result.answer + "\n\n### Sources Cited\n"
|
| 30 |
for idx, passage in enumerate(result.passages):
|
| 31 |
metadata = getattr(passage, "metadata", {})
|
| 32 |
+
title = metadata.get("paper_title") or metadata.get(
|
| 33 |
+
"title", "Unknown Source"
|
| 34 |
+
)
|
| 35 |
+
url = metadata.get("pdf_url") or metadata.get("url", "")
|
| 36 |
content += f"{idx + 1}. {title} - {url}\n"
|
| 37 |
|
| 38 |
# Serialize to JSON to handle quotes/newlines safely
|
|
|
|
| 80 |
# Extract passage info
|
| 81 |
text = getattr(passage, "text", "")
|
| 82 |
metadata = getattr(passage, "metadata", {})
|
| 83 |
+
paper_title = metadata.get("paper_title") or metadata.get(
|
| 84 |
+
"title", "Unknown Source"
|
| 85 |
+
)
|
| 86 |
paper_id = getattr(passage, "paper_id", "")
|
| 87 |
section = metadata.get("section", "")
|
| 88 |
# Try to get PDF URL from metadata
|
| 89 |
+
pdf_url = metadata.get("pdf_url") or metadata.get("url", "")
|
| 90 |
|
| 91 |
with ui.expansion().classes("source-card").props("dense") as expansion:
|
| 92 |
# Header slot for title
|
|
|
|
| 183 |
with ui.step("Reading Documents"):
|
| 184 |
with ui.column().classes("gap-2"):
|
| 185 |
ui.label(
|
| 186 |
+
"Reading and processing retrieved content..."
|
| 187 |
).classes("text-slate-600")
|
| 188 |
ui.spinner("dots", size="lg", color="primary")
|
| 189 |
|
ui/pages.py
CHANGED
|
@@ -375,8 +375,10 @@ def init_ui(fastapi_app):
|
|
| 375 |
serialized_passages.append(
|
| 376 |
{
|
| 377 |
"content": content_snippet,
|
| 378 |
-
"title": metadata.get("
|
| 379 |
-
|
|
|
|
|
|
|
| 380 |
"score": score,
|
| 381 |
"section": metadata.get("section", ""),
|
| 382 |
}
|
|
|
|
| 375 |
serialized_passages.append(
|
| 376 |
{
|
| 377 |
"content": content_snippet,
|
| 378 |
+
"title": metadata.get("paper_title")
|
| 379 |
+
or metadata.get("title", "Unknown"),
|
| 380 |
+
"url": metadata.get("pdf_url")
|
| 381 |
+
or metadata.get("url", ""),
|
| 382 |
"score": score,
|
| 383 |
"section": metadata.get("section", ""),
|
| 384 |
}
|