Carlos Rosas commited on
Commit
5f32076
·
verified ·
1 Parent(s): 3e7d748

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -16
app.py CHANGED
@@ -32,11 +32,11 @@ tokenizer.pad_token = tokenizer.eos_token
32
  tokenizer.pad_token_id = 1
33
 
34
  # Define variables
35
- temperature = 0.0
36
- max_new_tokens = 1400
37
  top_p = 0.95
38
  repetition_penalty = 1.0
39
- min_new_tokens = 700
40
  early_stopping = False
41
 
42
  # Connect to the LanceDB database
@@ -130,15 +130,18 @@ def format_references(text):
130
 
131
  import re
132
  for match in re.finditer(ref_pattern, text):
133
- # Add text before the reference
134
- parts.append(text[current_pos:match.start()])
 
 
 
135
 
136
  # Extract reference components
137
- ref_id = match.group(1) # The source ID
138
- ref_text = match.group(2).strip() # The reference text
139
 
140
- # Create tooltip HTML with source ID in bold and add <br> after each reference
141
- tooltip_html = f'<span class="tooltip">[{ref_number}]<span class="tooltiptext"><strong>{ref_id}</strong>: {ref_text}</span></span><br>'
142
  parts.append(tooltip_html)
143
 
144
  current_pos = match.end()
@@ -169,7 +172,8 @@ css = """
169
  .tooltip {
170
  position: relative;
171
  display: inline-block;
172
- color: #2563eb;
 
173
  cursor: pointer;
174
  }
175
  .tooltip .tooltiptext {
@@ -234,16 +238,19 @@ with demo:
234
  </div>
235
  """)
236
 
 
 
 
 
 
 
237
  with gr.Row():
238
- # Left column for input, button and analysis
239
  with gr.Column(scale=2):
240
- text_input = gr.Textbox(label="Votre question ou votre instruction", lines=3)
241
- text_button = gr.Button("Interroger pleias-RAG")
242
- text_output = gr.HTML(label="Analyse des sources") # Moved here
243
-
244
  # Right column for response
245
  with gr.Column(scale=3):
246
- response_output = gr.HTML(label="Réponse") # Moved here
247
 
248
  # Sources at the bottom
249
  with gr.Row():
 
32
  tokenizer.pad_token_id = 1
33
 
34
  # Define variables
35
+ temperature = 0.25
36
+ max_new_tokens = 1200
37
  top_p = 0.95
38
  repetition_penalty = 1.0
39
+ min_new_tokens = 600
40
  early_stopping = False
41
 
42
  # Connect to the LanceDB database
 
130
 
131
  import re
132
  for match in re.finditer(ref_pattern, text):
133
+ # Add text before the reference up to the period
134
+ text_before = text[current_pos:match.start()].rstrip()
135
+ if text_before.endswith('.'):
136
+ text_before = text_before[:-1] # Remove the period temporarily
137
+ parts.append(text_before)
138
 
139
  # Extract reference components
140
+ ref_id = match.group(1)
141
+ ref_text = match.group(2).strip()
142
 
143
+ # Add the reference with period and line break
144
+ tooltip_html = f'<span class="tooltip">[{ref_number}]<span class="tooltiptext"><strong>{ref_id}</strong>: {ref_text}</span></span>.<br>'
145
  parts.append(tooltip_html)
146
 
147
  current_pos = match.end()
 
172
  .tooltip {
173
  position: relative;
174
  display: inline-block;
175
+ color: navy; /* Changed from #2563eb to navy */
176
+ font-weight: bold; /* Make it bold for better visibility */
177
  cursor: pointer;
178
  }
179
  .tooltip .tooltiptext {
 
238
  </div>
239
  """)
240
 
241
+ # Centered input section
242
+ with gr.Column(scale=1):
243
+ text_input = gr.Textbox(label="Votre question ou votre instruction", lines=3)
244
+ text_button = gr.Button("Interroger pleias-RAG")
245
+
246
+ # Analysis and Response in side-by-side columns
247
  with gr.Row():
248
+ # Left column for analysis
249
  with gr.Column(scale=2):
250
+ text_output = gr.HTML(label="Analyse des sources")
 
 
 
251
  # Right column for response
252
  with gr.Column(scale=3):
253
+ response_output = gr.HTML(label="Réponse")
254
 
255
  # Sources at the bottom
256
  with gr.Row():