Carlos Rosas commited on
Commit
77ef75a
Β·
verified Β·
1 Parent(s): 69ffa48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -45,16 +45,24 @@ table = db.open_table("edunat19")
45
 
46
  def hybrid_search(text):
47
  results = table.search(text, query_type="hybrid").limit(5).to_pandas()
48
-
 
 
 
49
  document = []
50
  document_html = []
51
  for _, row in results.iterrows():
52
  hash_id = str(row['hash'])
 
 
 
 
 
 
53
  title = row['section']
54
  content = row['text']
55
 
56
  document.append(f"<|source_start|><|source_id_start|>{hash_id}<|source_id_end|>{title}\n{content}<|source_end|>")
57
-
58
  document_html.append(f'<div class="source" id="{hash_id}"><p><b>{hash_id}</b> : {title}<br>{content}</div>')
59
 
60
  document = "\n".join(document)
@@ -216,7 +224,7 @@ demo = gr.Blocks(css=css)
216
  with demo:
217
  # Header with black bar
218
  gr.HTML("""
219
- <div style="display: flex; justify-content: center; width: 100%; background-color: black; padding: 10px 0;">
220
  <pre style="font-family: monospace; line-height: 1.2; font-size: 24px; color: #00ffea; margin: 0;">
221
  ╔═══════════════════╗
222
  β•‘ pleias-RAG 1.0 β•‘
@@ -226,15 +234,15 @@ with demo:
226
  """)
227
 
228
  with gr.Row():
229
- # Left column for input, button and answer
230
  with gr.Column(scale=2):
231
  text_input = gr.Textbox(label="Votre question ou votre instruction", lines=3)
232
  text_button = gr.Button("Interroger pleias-RAG")
233
- response_output = gr.HTML(label="RΓ©ponse")
234
 
235
- # Right column for analysis
236
  with gr.Column(scale=3):
237
- text_output = gr.HTML(label="Analyse des sources")
238
 
239
  # Sources at the bottom
240
  with gr.Row():
 
45
 
46
  def hybrid_search(text):
47
  results = table.search(text, query_type="hybrid").limit(5).to_pandas()
48
+
49
+ # Add a check for duplicate hashes
50
+ seen_hashes = set()
51
+
52
  document = []
53
  document_html = []
54
  for _, row in results.iterrows():
55
  hash_id = str(row['hash'])
56
+
57
+ # Skip if we've already seen this hash
58
+ if hash_id in seen_hashes:
59
+ continue
60
+
61
+ seen_hashes.add(hash_id)
62
  title = row['section']
63
  content = row['text']
64
 
65
  document.append(f"<|source_start|><|source_id_start|>{hash_id}<|source_id_end|>{title}\n{content}<|source_end|>")
 
66
  document_html.append(f'<div class="source" id="{hash_id}"><p><b>{hash_id}</b> : {title}<br>{content}</div>')
67
 
68
  document = "\n".join(document)
 
224
  with demo:
225
  # Header with black bar
226
  gr.HTML("""
227
+ <div style="display: flex; justify-content: center; width: 100%; background-color: black; padding: 5px 0;">
228
  <pre style="font-family: monospace; line-height: 1.2; font-size: 24px; color: #00ffea; margin: 0;">
229
  ╔═══════════════════╗
230
  β•‘ pleias-RAG 1.0 β•‘
 
234
  """)
235
 
236
  with gr.Row():
237
+ # Left column for input, button and analysis
238
  with gr.Column(scale=2):
239
  text_input = gr.Textbox(label="Votre question ou votre instruction", lines=3)
240
  text_button = gr.Button("Interroger pleias-RAG")
241
+ text_output = gr.HTML(label="Analyse des sources") # Moved here
242
 
243
+ # Right column for response
244
  with gr.Column(scale=3):
245
+ response_output = gr.HTML(label="RΓ©ponse") # Moved here
246
 
247
  # Sources at the bottom
248
  with gr.Row():