Maia Pelletier commited on
Commit ·
d8dccbd
1
Parent(s): cf1d4c5
clean-up inline references
Browse files- app.py +3 -5
- ingestion.py +1 -1
app.py
CHANGED
|
@@ -267,10 +267,9 @@ Answer:"""
|
|
| 267 |
if response_text:
|
| 268 |
# Resolve [Context N] to actual source labels in the body
|
| 269 |
for i, source_label in context_index_to_source.items():
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
)
|
| 274 |
# Only append references when the model actually answered
|
| 275 |
no_answer_phrase = "The provided context does not contain enough information to answer this question."
|
| 276 |
if no_answer_phrase not in response_text:
|
|
@@ -281,7 +280,6 @@ Answer:"""
|
|
| 281 |
key = url or source_label
|
| 282 |
if key not in seen:
|
| 283 |
seen[key] = (source_label, url)
|
| 284 |
-
|
| 285 |
ref_lines = [
|
| 286 |
"",
|
| 287 |
"---",
|
|
|
|
| 267 |
if response_text:
|
| 268 |
# Resolve [Context N] to actual source labels in the body
|
| 269 |
for i, source_label in context_index_to_source.items():
|
| 270 |
+
url = context_index_to_url.get(i)
|
| 271 |
+
replacement = f"[{source_label}]({url})" if url else source_label
|
| 272 |
+
response_text = response_text.replace(f"[Context {i}]", replacement)
|
|
|
|
| 273 |
# Only append references when the model actually answered
|
| 274 |
no_answer_phrase = "The provided context does not contain enough information to answer this question."
|
| 275 |
if no_answer_phrase not in response_text:
|
|
|
|
| 280 |
key = url or source_label
|
| 281 |
if key not in seen:
|
| 282 |
seen[key] = (source_label, url)
|
|
|
|
| 283 |
ref_lines = [
|
| 284 |
"",
|
| 285 |
"---",
|
ingestion.py
CHANGED
|
@@ -162,7 +162,7 @@ class DocumentIngestion:
|
|
| 162 |
parsed = urlparse(url)
|
| 163 |
document_title = parsed.netloc or url
|
| 164 |
if parsed.path and parsed.path != "/":
|
| 165 |
-
document_title +=
|
| 166 |
except Exception:
|
| 167 |
document_title = url
|
| 168 |
for i, chunk in enumerate(chunks):
|
|
|
|
| 162 |
parsed = urlparse(url)
|
| 163 |
document_title = parsed.netloc or url
|
| 164 |
if parsed.path and parsed.path != "/":
|
| 165 |
+
document_title += parsed.path.rstrip("/")
|
| 166 |
except Exception:
|
| 167 |
document_title = url
|
| 168 |
for i, chunk in enumerate(chunks):
|