PierreBrunelle commited on
Commit
60a653d
·
verified ·
1 Parent(s): d68d9a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -103,16 +103,18 @@ def process_video(video_file, progress=gr.Progress()):
103
 
104
  # Perform similarity search
105
  def similarity_search(query, num_results, progress=gr.Progress()):
106
-
107
- sentences_view = pxt.get_table('gong_demo.sentences')
108
 
109
  progress(0.5, desc="Performing search...")
110
 
111
  sim = sentences_view.text.similarity(query)
112
  results = sentences_view.order_by(sim, asc=False).limit(num_results).select(sentences_view.text, sim=sim).collect().to_pandas()
113
- return results
114
-
 
 
115
  progress(1.0, desc="Search complete")
 
116
 
117
  def chatbot_response(message, chat_history):
118
  @pxt.udf
@@ -230,6 +232,17 @@ with gr.Blocks(theme=gr.themes.Base()) as demo:
230
  send_btn = gr.Button("Send", variant="secondary", scale=1)
231
  clear = gr.Button("Clear Chat")
232
 
 
 
 
 
 
 
 
 
 
 
 
233
  process_btn.click(
234
  process_video,
235
  inputs=[video_file],
 
103
 
104
  # Perform similarity search
105
  def similarity_search(query, num_results, progress=gr.Progress()):
106
+ sentences_view = pxt.get_table('gong_demo.sentences')
 
107
 
108
  progress(0.5, desc="Performing search...")
109
 
110
  sim = sentences_view.text.similarity(query)
111
  results = sentences_view.order_by(sim, asc=False).limit(num_results).select(sentences_view.text, sim=sim).collect().to_pandas()
112
+
113
+ # Format similarity scores as percentages
114
+ results['sim'] = results['sim'].apply(lambda x: f"{x*100:.2f}%")
115
+
116
  progress(1.0, desc="Search complete")
117
+ return results
118
 
119
  def chatbot_response(message, chat_history):
120
  @pxt.udf
 
232
  send_btn = gr.Button("Send", variant="secondary", scale=1)
233
  clear = gr.Button("Clear Chat")
234
 
235
+ gr.Examples(
236
+ examples=[
237
+ "What were the main topics discussed in this call?",
238
+ "Can you summarize the action items mentioned?",
239
+ "What was the overall sentiment of the conversation?",
240
+ "Were there any objections raised by the client?",
241
+ "What features or products were highlighted during the call?",
242
+ ],
243
+ inputs=msg,
244
+ )
245
+
246
  process_btn.click(
247
  process_video,
248
  inputs=[video_file],