carlosrosash commited on
Commit
ba64a0f
1 Parent(s): 89c3d22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -36
app.py CHANGED
@@ -100,13 +100,6 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum leo a
100
  Ut ac volutpat nisi.
101
  </p>
102
  """
103
- examples = [
104
- [
105
- "Comment faire une bonne madeleine ? Donne-moi une recette détaillée avec les ingrédients.", # user_message
106
- "Proust",
107
- 0.7 # temperature
108
- ]
109
- ]
110
 
111
  list_dropdown = [
112
  'Proust',
@@ -205,37 +198,25 @@ with gr.Blocks(theme = 'carlosrosash/bellay_test') as demo:
205
  return mistral_bot.predict(user_message, style, temperature)
206
 
207
  # Function to handle the button click for clear
208
- def on_clear():
209
- user_input.clear() # Clear the user input
210
- temperature_slider.change(0.7) # Reset the slider to default
211
- output_text.clear() # Clear the output text
212
-
213
- # Reset the dropdown to a default value and update the explanation
214
- default_style = list_dropdown[0] # Assuming the first value is the default
215
- dropdown.change(default_style) # Change the dropdown to the default value
216
- explanation_box.update(explanations[default_style]) # Update the explanation box
217
 
218
  # Examples section
219
  gr.Markdown("<h2>Examples</h2>")
220
-
221
- Example_1 = gr.Button("Comment faire une bonne madeleine ? Donne-moi une recette détaillée avec les ingrédients.")
222
- Example_2 = gr.Button("Proust")
223
- Example_3 = gr.Button("0.7")
224
- # Example data
225
- example_data = pd.DataFrame({
226
- "Question ou votre instruction": [Example_1],
227
- "Style": [Example_2],
228
- "Température": [Example_3]
229
- })
230
- # Function to handle table row click
231
- def fill_example():
232
- user_input.update("Comment faire une bonne madeleine ? Donne-moi une recette détaillée avec les ingrédients.")
233
- dropdown.change("Proust")
234
- temperature_slider.change(0.7)
235
-
236
- examples_df = gr.Dataframe(example_data, interactive=True)
237
- Example_1.click(fill_example, outputs=output_text)
238
- Example_2.click(fill_example, outputs=output_text)
239
- Example_3.click(fill_example, outputs=output_text)
240
 
241
  demo.launch()
 
100
  Ut ac volutpat nisi.
101
  </p>
102
  """
 
 
 
 
 
 
 
103
 
104
  list_dropdown = [
105
  'Proust',
 
198
  return mistral_bot.predict(user_message, style, temperature)
199
 
200
  # Function to handle the button click for clear
201
+ def clear_all():
202
+ return ["", list_dropdown[0], 0.7, ""]
203
+ # Link the submit button to the on_submit function
204
+ submit_button.click(on_submit, inputs=[user_input, dropdown, temperature_slider], outputs=output_text)
205
+ # Link the clear button to the clear_all function
206
+ clear_button.click(clear_all, outputs=[user_input, dropdown, temperature_slider, output_text])
 
 
 
207
 
208
  # Examples section
209
  gr.Markdown("<h2>Examples</h2>")
210
+ gr.Examples(
211
+ examples=[
212
+ ["Comment faire une bonne madeleine ? Donne-moi une recette détaillée avec les ingrédients.", "Proust", 0.7],
213
+ ["Que t'evoque le goût d'une madeleinee", "Proust", 0.5],
214
+ ["Quelles sont les valeurs de la République française", "Constitutions françaises", 1.0]
215
+ ],
216
+ inputs=[user_input, dropdown, temperature_slider],
217
+ outputs=output_text,
218
+ fn=on_submit,
219
+ cache_examples=True,
220
+ )
 
 
 
 
 
 
 
 
 
221
 
222
  demo.launch()