Spaces:
Running
on
Zero
Running
on
Zero
feat: add headings
Browse files
app.py
CHANGED
@@ -64,7 +64,7 @@ def build_markdown_links(file_input):
|
|
64 |
url = f"{github_base_url}/{item['directory']}/{item['source']}"
|
65 |
line = f"**Source {idx}:** [{item['source']}]({url}) on page {item['page']}"
|
66 |
lines.append(line)
|
67 |
-
return "\n
|
68 |
|
69 |
|
70 |
def build_markdown_chunks(docs):
|
@@ -74,7 +74,7 @@ def build_markdown_chunks(docs):
|
|
74 |
page = d['title']['page']
|
75 |
text = d['pages']
|
76 |
lines.append(f"**Chunk {idx}:** {title} on page {page}\n\n{text}")
|
77 |
-
return "\n
|
78 |
|
79 |
@spaces.GPU()
|
80 |
def qa_fn(question, top_k, temperature, max_tokens):
|
@@ -99,13 +99,13 @@ def qa_fn(question, top_k, temperature, max_tokens):
|
|
99 |
output += tok
|
100 |
if "Output:" in output:
|
101 |
output = output.split("Output:", 1)[1].strip()
|
102 |
-
return output, file_links, markdown_chunks
|
103 |
|
104 |
-
heading_answer = gr.Markdown("
|
105 |
outputs_answer = gr.Textbox(label="Answer")
|
106 |
outputs_link = gr.Markdown(label="Source Link")
|
107 |
-
heading_links = gr.Markdown("
|
108 |
-
heading_chunks = gr.Markdown("
|
109 |
outputs_chunks = gr.Markdown(label="Used Chunks")
|
110 |
|
111 |
demo = gr.Interface(
|
@@ -120,8 +120,11 @@ demo = gr.Interface(
|
|
120 |
],
|
121 |
additional_inputs_accordion="Advanced Options",
|
122 |
outputs=[
|
|
|
123 |
outputs_answer,
|
|
|
124 |
outputs_link,
|
|
|
125 |
outputs_chunks
|
126 |
],
|
127 |
title="GDPR Legal Assistant",
|
|
|
64 |
url = f"{github_base_url}/{item['directory']}/{item['source']}"
|
65 |
line = f"**Source {idx}:** [{item['source']}]({url}) on page {item['page']}"
|
66 |
lines.append(line)
|
67 |
+
return "\n\n".join(lines)
|
68 |
|
69 |
|
70 |
def build_markdown_chunks(docs):
|
|
|
74 |
page = d['title']['page']
|
75 |
text = d['pages']
|
76 |
lines.append(f"**Chunk {idx}:** {title} on page {page}\n\n{text}")
|
77 |
+
return "\n\n".join(lines)
|
78 |
|
79 |
@spaces.GPU()
|
80 |
def qa_fn(question, top_k, temperature, max_tokens):
|
|
|
99 |
output += tok
|
100 |
if "Output:" in output:
|
101 |
output = output.split("Output:", 1)[1].strip()
|
102 |
+
return "\n# Generated Answer\n", output,"\n# Used Documents\n", file_links, "\n# Used Context\n", markdown_chunks
|
103 |
|
104 |
+
heading_answer = gr.Markdown(label="Answer Heading")
|
105 |
outputs_answer = gr.Textbox(label="Answer")
|
106 |
outputs_link = gr.Markdown(label="Source Link")
|
107 |
+
heading_links = gr.Markdown(label="Links Heading")
|
108 |
+
heading_chunks = gr.Markdown(label="Chunks Heading")
|
109 |
outputs_chunks = gr.Markdown(label="Used Chunks")
|
110 |
|
111 |
demo = gr.Interface(
|
|
|
120 |
],
|
121 |
additional_inputs_accordion="Advanced Options",
|
122 |
outputs=[
|
123 |
+
heading_answer,
|
124 |
outputs_answer,
|
125 |
+
heading_links,
|
126 |
outputs_link,
|
127 |
+
heading_chunks,
|
128 |
outputs_chunks
|
129 |
],
|
130 |
title="GDPR Legal Assistant",
|