File size: 1,088 Bytes
074e8ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Modal deployment configuration for Explainor.

Deploy with: modal deploy modal_app.py
Run locally: modal serve modal_app.py
"""

import os
import modal

# Define the Modal app
app = modal.App("explainor")

# Create image with dependencies
image = (
    modal.Image.debian_slim(python_version="3.11")
    .pip_install(
        "gradio>=5.0.0",
        "elevenlabs>=1.0.0",
        "httpx>=0.25.0",
        "python-dotenv>=1.0.0",
    )
    .copy_local_dir("src", "/app/src")
    .copy_local_file("app.py", "/app/app.py")
)


@app.function(
    image=image,
    secrets=[
        modal.Secret.from_name("nebius-api-key"),
        modal.Secret.from_name("elevenlabs-api-key"),
    ],
    timeout=600,
    allow_concurrent_inputs=10,
)
@modal.asgi_app()
def serve():
    """Serve the Gradio app."""
    import sys
    sys.path.insert(0, "/app")

    from app import app as gradio_app
    return gradio_app


# For local testing
if __name__ == "__main__":
    # Run with: python modal_app.py
    print("Run with: modal serve modal_app.py")
    print("Or deploy: modal deploy modal_app.py")