Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -124,6 +124,21 @@ def make_html_source(source,i):
|
|
124 |
"""
|
125 |
|
126 |
return card
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
# --------------------------------------------------------------------
|
128 |
# Gradio
|
129 |
# --------------------------------------------------------------------
|
|
|
124 |
"""
|
125 |
|
126 |
return card
|
127 |
+
|
128 |
+
def parse_output_llm_with_sources(output):
|
129 |
+
# Split the content into a list of text and "[Doc X]" references
|
130 |
+
content_parts = re.split(r'\[(Doc\s?\d+(?:,\s?Doc\s?\d+)*)\]', output)
|
131 |
+
parts = []
|
132 |
+
for part in content_parts:
|
133 |
+
if part.startswith("Doc"):
|
134 |
+
subparts = part.split(",")
|
135 |
+
subparts = [subpart.lower().replace("doc","").strip() for subpart in subparts]
|
136 |
+
subparts = [f"""<a href="#doc{subpart}" class="a-doc-ref" target="_self"><span class='doc-ref'><sup>{subpart}</sup></span></a>""" for subpart in subparts]
|
137 |
+
parts.append("".join(subparts))
|
138 |
+
else:
|
139 |
+
parts.append(part)
|
140 |
+
content_parts = "".join(parts)
|
141 |
+
return content_parts
|
142 |
# --------------------------------------------------------------------
|
143 |
# Gradio
|
144 |
# --------------------------------------------------------------------
|