Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -93,21 +93,21 @@ def query_vectara(question):
|
|
93 |
|
94 |
def convert_to_markdown(vectara_response):
|
95 |
if vectara_response:
|
96 |
-
|
97 |
-
|
98 |
-
summary = response_set.get('summary', [{}])[0] # get the first summary
|
99 |
summary_text = summary.get('text', 'No summary available')
|
100 |
sources = response_set.get('response', [])[:5]
|
101 |
sources_text = [source.get('text', '') for source in sources]
|
102 |
|
103 |
# Format the summary and sources as Markdown
|
104 |
-
markdown_summary = f
|
105 |
-
markdown_sources = "\n".join([f
|
106 |
|
107 |
-
return f"{markdown_summary}**Sources
|
108 |
else:
|
109 |
return "No data found in the response."
|
110 |
|
|
|
111 |
iface = gr.Interface(
|
112 |
fn=query_vectara,
|
113 |
inputs=[gr.Textbox(label="Input Text")],
|
|
|
93 |
|
94 |
def convert_to_markdown(vectara_response):
|
95 |
if vectara_response:
|
96 |
+
response_set = vectara_response.get('responseSet', [{}])[0]
|
97 |
+
summary = response_set.get('summary', [{}])[0]
|
|
|
98 |
summary_text = summary.get('text', 'No summary available')
|
99 |
sources = response_set.get('response', [])[:5]
|
100 |
sources_text = [source.get('text', '') for source in sources]
|
101 |
|
102 |
# Format the summary and sources as Markdown
|
103 |
+
markdown_summary = f'**Summary:** {summary_text}\n\n'
|
104 |
+
markdown_sources = "\n".join([f'{i + 1}. {source}' for i, source in enumerate(sources_text)])
|
105 |
|
106 |
+
return f"{markdown_summary}**Sources:**\n{markdown_sources}"
|
107 |
else:
|
108 |
return "No data found in the response."
|
109 |
|
110 |
+
|
111 |
iface = gr.Interface(
|
112 |
fn=query_vectara,
|
113 |
inputs=[gr.Textbox(label="Input Text")],
|