App plugged to modal
Browse files- .gitignore +41 -0
- .python-version +1 -0
- app.py +16 -4
- main.py +6 -0
- modal_app.py +16 -0
- pyproject.toml +7 -0
.gitignore
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
*.so
|
| 6 |
+
.Python
|
| 7 |
+
build/
|
| 8 |
+
develop-eggs/
|
| 9 |
+
dist/
|
| 10 |
+
downloads/
|
| 11 |
+
eggs/
|
| 12 |
+
.eggs/
|
| 13 |
+
lib/
|
| 14 |
+
lib64/
|
| 15 |
+
parts/
|
| 16 |
+
sdist/
|
| 17 |
+
var/
|
| 18 |
+
wheels/
|
| 19 |
+
*.egg-info/
|
| 20 |
+
.installed.cfg
|
| 21 |
+
*.egg
|
| 22 |
+
|
| 23 |
+
# Virtual Environment
|
| 24 |
+
.env
|
| 25 |
+
.venv
|
| 26 |
+
env/
|
| 27 |
+
venv/
|
| 28 |
+
ENV/
|
| 29 |
+
|
| 30 |
+
# VS Code
|
| 31 |
+
.vscode/
|
| 32 |
+
|
| 33 |
+
# Gradio
|
| 34 |
+
.gradio/
|
| 35 |
+
|
| 36 |
+
# Modal
|
| 37 |
+
.modal/
|
| 38 |
+
|
| 39 |
+
# Misc
|
| 40 |
+
.DS_Store
|
| 41 |
+
*.log
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.12
|
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
demo.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from modal_app import app, square
|
| 3 |
|
| 4 |
+
def compute_square(x):
|
| 5 |
+
with app.run():
|
| 6 |
+
return square.remote(float(x))
|
| 7 |
|
| 8 |
+
# Create a standard Gradio interface
|
| 9 |
+
demo = gr.Interface(
|
| 10 |
+
fn=compute_square,
|
| 11 |
+
inputs=gr.Number(label="Enter a number"),
|
| 12 |
+
outputs=gr.Number(label="Square of the number"),
|
| 13 |
+
title="Compute Square using Modal",
|
| 14 |
+
description="Enter a number to compute its square using a remote Modal function."
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
# Launch both the Gradio web interface and the MCP server
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
demo.launch(mcp_server=True)
|
main.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def main():
|
| 2 |
+
print("Hello from mcp-chai1-modal!")
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
if __name__ == "__main__":
|
| 6 |
+
main()
|
modal_app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import modal
|
| 2 |
+
|
| 3 |
+
app = modal.App("example-get-started")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
@app.function()
|
| 7 |
+
def square(x):
|
| 8 |
+
print("This code is running on a remote worker!")
|
| 9 |
+
return x**2
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
if __name__ == "__main__":
|
| 13 |
+
# For local testing
|
| 14 |
+
with app.run():
|
| 15 |
+
result = square.remote(42)
|
| 16 |
+
print("the square is", result)
|
pyproject.toml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "mcp-chai1-modal"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Add your description here"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.12"
|
| 7 |
+
dependencies = []
|