Tonic commited on
Commit
b4ae1f8
1 Parent(s): 8d84915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -93,21 +93,21 @@ def query_vectara(question):
93
 
94
  def convert_to_markdown(vectara_response):
95
  if vectara_response:
96
- # Extract summary and the first 5 sources
97
- response_set = vectara_response.get('responseSet', [{}])[0] # get the first response set
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"**Summary**: {summary_text}\n\n"
105
- markdown_sources = "\n".join([f"- {source}" for source in sources_text])
106
 
107
- return f"{markdown_summary}**Sources**:\n{markdown_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")],