Spaces:
Paused
Paused
Download app.py from MDotstream/neo: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/MDotstream/neo/resolve/main/app.py
- Command line
-
hf download hf://spaces/MDotstream/neo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MDotstream/neo/resolve/main/app.py
1.21 kB
| import gradio as gr | |
| # Fonction principale du chatbot | |
| def chat(message, system_message, max_tokens, temperature, top_p): | |
| try: | |
| # Pour l'instant, Neo fait juste un écho du message | |
| # Ici tu pourras mettre une vraie IA (Mistral, LLM, etc.) | |
| response = f"Neo : Tu as dit '{message}'" | |
| return response | |
| except Exception as e: | |
| # Toujours renvoyer une string même en cas d'erreur | |
| return f"Erreur interne : {str(e)}" | |
| # Crée l'interface Gradio | |
| with gr.Blocks() as demo: | |
| # Inputs | |
| msg_input = gr.Textbox(label="Message") | |
| sys_input = gr.Textbox(label="System message", value="Tu es Neo, un assistant d'étude utile.") | |
| max_tokens_input = gr.Number(label="Max tokens", value=512) | |
| temp_input = gr.Number(label="Temperature", value=0.7) | |
| top_p_input = gr.Number(label="Top p", value=0.95) | |
| # Output | |
| output = gr.Textbox(label="Réponse") | |
| # Bouton pour envoyer | |
| btn = gr.Button("Envoyer") | |
| btn.click( | |
| fn=chat, | |
| inputs=[msg_input, sys_input, max_tokens_input, temp_input, top_p_input], | |
| outputs=output, | |
| api_name="chat" # IMPORTANT : ceci crée l'endpoint /chat | |
| ) | |
| # Lance le Space | |
| demo.launch() |