Emperor555 Claude commited on
Commit
b7e3c16
·
1 Parent(s): f2c5e84

Try explainor-v4 with FastAPI mount approach

Browse files

Use gr.mount_gradio_app with FastAPI for proper ASGI
compatibility with Modal.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. modal_app.py +9 -5
modal_app.py CHANGED
@@ -7,7 +7,7 @@ Run locally: modal serve modal_app.py
7
  import modal
8
 
9
  # Define the Modal app
10
- app = modal.App("explainor-v3")
11
 
12
  # Create image with dependencies
13
  image = (
@@ -17,6 +17,7 @@ image = (
17
  "elevenlabs>=1.0.0",
18
  "httpx>=0.25.0",
19
  "python-dotenv>=1.0.0",
 
20
  )
21
  .add_local_dir("src", remote_path="/app/src", copy=True)
22
  )
@@ -40,6 +41,7 @@ def serve():
40
  import os
41
  import tempfile
42
  import gradio as gr
 
43
  from src.personas import get_persona_names, get_persona
44
  from src.agent import run_agent
45
  from src.tts import generate_speech
@@ -147,8 +149,10 @@ def serve():
147
  outputs=[audio_output],
148
  )
149
 
150
- # Use Gradio's queue with specific settings for Modal
151
- demo.queue(default_concurrency_limit=5)
152
 
153
- # Return the ASGI app
154
- return demo.app
 
 
 
7
  import modal
8
 
9
  # Define the Modal app
10
+ app = modal.App("explainor-v4")
11
 
12
  # Create image with dependencies
13
  image = (
 
17
  "elevenlabs>=1.0.0",
18
  "httpx>=0.25.0",
19
  "python-dotenv>=1.0.0",
20
+ "fastapi",
21
  )
22
  .add_local_dir("src", remote_path="/app/src", copy=True)
23
  )
 
41
  import os
42
  import tempfile
43
  import gradio as gr
44
+ from fastapi import FastAPI
45
  from src.personas import get_persona_names, get_persona
46
  from src.agent import run_agent
47
  from src.tts import generate_speech
 
149
  outputs=[audio_output],
150
  )
151
 
152
+ # Create FastAPI app and mount Gradio
153
+ fastapi_app = FastAPI()
154
 
155
+ # Mount Gradio app
156
+ fastapi_app = gr.mount_gradio_app(fastapi_app, demo, path="/")
157
+
158
+ return fastapi_app