Spaces:
No application file
No application file
remove modal
Browse files- main.py +2 -49
- pyproject.toml +0 -1
main.py
CHANGED
|
@@ -1,35 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import modal
|
| 3 |
-
import sys
|
| 4 |
-
import subprocess
|
| 5 |
-
import time
|
| 6 |
from tools.meta_yml_tools import get_meta_yml_file, extract_tools_from_meta_json, extract_information_from_meta_json, extract_module_name_description, get_biotools_response
|
| 7 |
from agents.query_ontology_db import agent
|
| 8 |
-
# Define the custom image
|
| 9 |
-
ollama_image = (
|
| 10 |
-
modal.Image.debian_slim()
|
| 11 |
-
.apt_install("curl", "gnupg", "software-properties-common", "procps")
|
| 12 |
-
.run_commands("curl -fsSL https://ollama.com/install.sh | sh")
|
| 13 |
-
.run_commands(
|
| 14 |
-
"bash -c 'ollama serve >/dev/null 2>&1 & "
|
| 15 |
-
"PID=$!; "
|
| 16 |
-
"sleep 10 && "
|
| 17 |
-
"ollama pull devstral:latest && "
|
| 18 |
-
"ollama pull qwen3:0.6b && "
|
| 19 |
-
"kill $PID'"
|
| 20 |
-
)
|
| 21 |
-
.pip_install(
|
| 22 |
-
"fastmcp>=2.6.1",
|
| 23 |
-
"gradio[mcp]>=5.0.0",
|
| 24 |
-
"huggingface_hub[mcp]>=0.32.2",
|
| 25 |
-
"mcp>=1.9.2",
|
| 26 |
-
"smolagents[litellm,mcp]>=1.17.0",
|
| 27 |
-
"textblob>=0.19.0",
|
| 28 |
-
)
|
| 29 |
-
)
|
| 30 |
|
| 31 |
-
# Initialize the Modal app with the custom image
|
| 32 |
-
app = modal.App("agent-ontology", image=ollama_image)
|
| 33 |
|
| 34 |
def run_multi_agent(module_name):
|
| 35 |
meta_yml = get_meta_yml_file(module_name=module_name)
|
|
@@ -79,29 +51,10 @@ def run_interface():
|
|
| 79 |
fetch_btn.click(
|
| 80 |
fn=run_multi_agent, # TODO: change to final function
|
| 81 |
inputs=module_input,
|
| 82 |
-
outputs=[meta_output]
|
| 83 |
)
|
| 84 |
|
| 85 |
demo.launch(share=True)
|
| 86 |
|
| 87 |
-
@app.function(keep_warm=1, gpu="A10G", timeout=2400)
|
| 88 |
-
def main_remote():
|
| 89 |
-
# spin up Ollama daemon in the background
|
| 90 |
-
server = subprocess.Popen(["ollama", "serve"])
|
| 91 |
-
time.sleep(6) # give it a moment to bind :11434
|
| 92 |
-
try:
|
| 93 |
-
run_interface()
|
| 94 |
-
finally:
|
| 95 |
-
server.terminate()
|
| 96 |
-
|
| 97 |
-
def main_local():
|
| 98 |
-
run_interface()
|
| 99 |
-
|
| 100 |
if __name__ == "__main__":
|
| 101 |
-
|
| 102 |
-
# if it is modal, run the remote function
|
| 103 |
-
# if it is python, run the local function
|
| 104 |
-
if "modal" in sys.modules:
|
| 105 |
-
main_remote().remote()
|
| 106 |
-
else:
|
| 107 |
-
main_local()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from tools.meta_yml_tools import get_meta_yml_file, extract_tools_from_meta_json, extract_information_from_meta_json, extract_module_name_description, get_biotools_response
|
| 3 |
from agents.query_ontology_db import agent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def run_multi_agent(module_name):
|
| 7 |
meta_yml = get_meta_yml_file(module_name=module_name)
|
|
|
|
| 51 |
fetch_btn.click(
|
| 52 |
fn=run_multi_agent, # TODO: change to final function
|
| 53 |
inputs=module_input,
|
| 54 |
+
outputs=[meta_output, download_button]
|
| 55 |
)
|
| 56 |
|
| 57 |
demo.launch(share=True)
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
if __name__ == "__main__":
|
| 60 |
+
run_interface()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyproject.toml
CHANGED
|
@@ -15,5 +15,4 @@ dependencies = [
|
|
| 15 |
"smolagents[litellm,mcp]>=1.17.0",
|
| 16 |
"textblob>=0.19.0",
|
| 17 |
"aiohttp>=3.8.0",
|
| 18 |
-
"modal>=0.57.0",
|
| 19 |
]
|
|
|
|
| 15 |
"smolagents[litellm,mcp]>=1.17.0",
|
| 16 |
"textblob>=0.19.0",
|
| 17 |
"aiohttp>=3.8.0",
|
|
|
|
| 18 |
]
|