Spaces:
Build error
Build error
Download app.py from QnoM/Gradio_multi_test: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/QnoM/Gradio_multi_test/resolve/main/app.py
- Command line
-
hf download hf://spaces/QnoM/Gradio_multi_test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/QnoM/Gradio_multi_test/resolve/main/app.py
1.42 kB
| import gradio as gr | |
| import os | |
| # Ajouter un chemin statique | |
| static_dir = os.path.abspath("/img") # Chemin vers le répertoire actuel contenant `ascii_image.png` | |
| gr.set_static_paths(static_dir) | |
| def load(): | |
| # Retourne des paires texte + HTML pour le Chatbot | |
| return [ | |
| ("Here's an audio", "<audio controls><source src='https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav'></audio>"), | |
| ("Here's a video", "<video controls width='300'><source src='https://github.com/gradio-app/gradio/raw/main/demo/video_component/files/world.mp4'></video>"), | |
| ("Here's an image", "<img src='https://emmanuelmancuso.com/portfolio/static/img/ASCII-art.png' width='300' />"), | |
| ("Here's an image", "<img src='/file=ascii_image.png' width='300' />") | |
| ] | |
| with gr.Blocks() as demo: | |
| chatbot = gr.Chatbot() | |
| button = gr.Button("Load audio, video, and image") | |
| def update_chatbot(): | |
| # Récupère les éléments et les formate correctement pour le Chatbot | |
| data = load() | |
| chat_history = [] | |
| for message, content in data: | |
| # Combine texte et contenu HTML dans la même bulle | |
| combined_message = f"{message}{content}" | |
| chat_history.append(("", combined_message)) # "" pour l'utilisateur, réponse pour le bot | |
| return chat_history | |
| button.click(update_chatbot, inputs=None, outputs=chatbot) | |
| demo.launch() |