Spaces:
Runtime error
Runtime error
| from modal import Stub, Image, asgi_app | |
| from fastapi import FastAPI | |
| image = ( | |
| Image.debian_slim() | |
| .run_commands(["pip install --upgrade pip"]) | |
| .pip_install( | |
| "gradio", | |
| ) | |
| ) | |
| stub = Stub("secsplorer", image=image) | |
| web_app = FastAPI() | |
| def fastapi_app(): | |
| import gradio as gr | |
| from gradio.routes import mount_gradio_app | |
| import gradio as gr | |
| import random | |
| import time | |
| with gr.Blocks() as demo: | |
| chatbot = gr.Chatbot() | |
| msg = gr.Textbox() | |
| clear = gr.ClearButton([msg, chatbot]) | |
| def respond(message, chat_history): | |
| print("Calling respond...") | |
| bot_message = random.choice( | |
| ["How are you?", "I love you", "I'm very hungry"] | |
| ) | |
| chat_history.append((message, bot_message)) | |
| print("Returning result...") | |
| yield "", chat_history | |
| msg.submit(respond, [msg, chatbot], [msg, chatbot]) | |
| mount_gradio_app(app=web_app, blocks=demo, path="/") | |
| return web_app | |