Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,30 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
| 3 |
def chat(message, system_message, max_tokens, temperature, top_p):
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Fonction qui répond à l'utilisateur
|
| 4 |
def chat(message, system_message, max_tokens, temperature, top_p):
|
| 5 |
+
# Pour l'instant, juste un écho simple
|
| 6 |
+
# Plus tard tu pourras remplacer par une vraie IA comme Mistral
|
| 7 |
+
return f"Neo : Tu as dit '{message}'"
|
| 8 |
|
| 9 |
+
# Crée l'interface Gradio
|
| 10 |
+
with gr.Blocks() as demo:
|
| 11 |
+
# Inputs
|
| 12 |
+
msg_input = gr.Textbox(label="Message")
|
| 13 |
+
sys_input = gr.Textbox(label="System message", value="Tu es Neo, un assistant d'étude utile.")
|
| 14 |
+
max_tokens_input = gr.Number(label="Max tokens", value=512)
|
| 15 |
+
temp_input = gr.Number(label="Temperature", value=0.7)
|
| 16 |
+
top_p_input = gr.Number(label="Top p", value=0.95)
|
| 17 |
+
|
| 18 |
+
# Output
|
| 19 |
+
output = gr.Textbox(label="Réponse")
|
| 20 |
+
|
| 21 |
+
# Bouton
|
| 22 |
+
btn = gr.Button("Envoyer")
|
| 23 |
+
btn.click(
|
| 24 |
+
fn=chat,
|
| 25 |
+
inputs=[msg_input, sys_input, max_tokens_input, temp_input, top_p_input],
|
| 26 |
+
outputs=output,
|
| 27 |
+
api_name="chat" # Important ! C’est le nom de l’endpoint
|
| 28 |
+
)
|
| 29 |
|
| 30 |
demo.launch()
|