Commit
·
300ea0d
1
Parent(s):
0fe3d16
Update app.py
Browse files
app.py
CHANGED
@@ -208,28 +208,18 @@ explanations = {
|
|
208 |
'Derrida': "Jacques Derrida, a philosopher best known for developing deconstruction, a critical approach that questions the relationship between text and meaning.",
|
209 |
'Baudrillard': "Jean Baudrillard, a cultural theorist known for his analysis of consumerism, simulation, and hyperreality."
|
210 |
}
|
|
|
211 |
|
212 |
# Function to return the explanation based on the selected artist or style
|
213 |
def update_explanation(choice):
|
214 |
-
global selected_style
|
215 |
-
selected_style = choice
|
216 |
return explanations.get(choice, "No explanation available.")
|
217 |
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
value=0.7, # Default value
|
222 |
-
minimum=0.05,
|
223 |
-
maximum=1.0,
|
224 |
-
step=0.05,
|
225 |
-
interactive=True,
|
226 |
-
info="Des valeurs plus élevées donne plus de créativité, mais aussi d'étrangeté",
|
227 |
-
),
|
228 |
-
]
|
229 |
|
230 |
-
#
|
231 |
with gr.Blocks() as demo:
|
232 |
-
# Block 1: Title, Description, Dropdown, Explanation
|
233 |
gr.Markdown(title)
|
234 |
gr.Markdown(description)
|
235 |
with gr.Row():
|
@@ -237,16 +227,32 @@ with gr.Blocks() as demo:
|
|
237 |
explanation_box = gr.Textbox(label="Explanation", type="text", lines=5, interactive=False)
|
238 |
dropdown.change(update_explanation, inputs=dropdown, outputs=explanation_box)
|
239 |
|
240 |
-
#
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
|
249 |
-
|
250 |
-
|
251 |
|
252 |
-
demo.launch()
|
|
|
208 |
'Derrida': "Jacques Derrida, a philosopher best known for developing deconstruction, a critical approach that questions the relationship between text and meaning.",
|
209 |
'Baudrillard': "Jean Baudrillard, a cultural theorist known for his analysis of consumerism, simulation, and hyperreality."
|
210 |
}
|
211 |
+
# ... [Previous code remains the same]
|
212 |
|
213 |
# Function to return the explanation based on the selected artist or style
|
214 |
def update_explanation(choice):
|
|
|
|
|
215 |
return explanations.get(choice, "No explanation available.")
|
216 |
|
217 |
+
# Adjusted predict function to handle None temperature
|
218 |
+
def predict(user_message, selected_style, temperature=0.7):
|
219 |
+
# ... [Function code remains the same]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
+
# Define the Gradio interface using Blocks
|
222 |
with gr.Blocks() as demo:
|
|
|
223 |
gr.Markdown(title)
|
224 |
gr.Markdown(description)
|
225 |
with gr.Row():
|
|
|
227 |
explanation_box = gr.Textbox(label="Explanation", type="text", lines=5, interactive=False)
|
228 |
dropdown.change(update_explanation, inputs=dropdown, outputs=explanation_box)
|
229 |
|
230 |
+
# Define the columns for input and output
|
231 |
+
with gr.Row():
|
232 |
+
with gr.Column():
|
233 |
+
user_input = gr.Textbox(label="Question or your instruction", type="text", lines=5, placeholder="Start typing here")
|
234 |
+
temperature_slider = gr.Slider(label="Temperature", value=0.7, minimum=0.05, maximum=1.0, step=0.05, interactive=True)
|
235 |
+
with gr.Column():
|
236 |
+
output_text = gr.Textbox(label="Response", type="text", lines=10)
|
237 |
+
|
238 |
+
# Define the buttons
|
239 |
+
with gr.Row():
|
240 |
+
submit_button = gr.Button("Submit")
|
241 |
+
clear_button = gr.Button("Clear")
|
242 |
+
|
243 |
+
# Function to handle the button click for submit
|
244 |
+
def on_submit(user_message, selected_style, temperature):
|
245 |
+
return predict(user_message, selected_style, temperature)
|
246 |
+
|
247 |
+
# Function to handle the button click for clear
|
248 |
+
def on_clear():
|
249 |
+
user_input.clear()
|
250 |
+
temperature_slider.change(0.7)
|
251 |
+
output_text.clear()
|
252 |
+
explanation_box.update("")
|
253 |
+
dropdown.change("Proust")
|
254 |
|
255 |
+
submit_button.click(on_submit, inputs=[user_input, dropdown, temperature_slider], outputs=output_text)
|
256 |
+
clear_button.click(on_clear)
|
257 |
|
258 |
+
demo.launch()
|