Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,23 @@
|
|
| 1 |
-
import os
|
| 2 |
import subprocess
|
| 3 |
import time
|
| 4 |
-
from fastapi import FastAPI
|
| 5 |
import uvicorn
|
|
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
@app.get("/")
|
| 10 |
-
def
|
| 11 |
-
return {"
|
| 12 |
|
| 13 |
if __name__ == "__main__":
|
| 14 |
-
# Start Ollama in the background
|
| 15 |
subprocess.Popen(["ollama", "serve"])
|
| 16 |
|
| 17 |
-
# Wait for
|
| 18 |
time.sleep(5)
|
| 19 |
|
| 20 |
-
# Ensure
|
| 21 |
subprocess.run(["ollama", "pull", "qwen2.5-coder:7b"])
|
| 22 |
|
| 23 |
-
# Start the web server
|
| 24 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
| 1 |
import subprocess
|
| 2 |
import time
|
|
|
|
| 3 |
import uvicorn
|
| 4 |
+
from fastapi import FastAPI
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
@app.get("/")
|
| 9 |
+
def read_root():
|
| 10 |
+
return {"message": "Ollama Server is Live"}
|
| 11 |
|
| 12 |
if __name__ == "__main__":
|
| 13 |
+
# Start the Ollama engine in the background
|
| 14 |
subprocess.Popen(["ollama", "serve"])
|
| 15 |
|
| 16 |
+
# Wait for the engine to initialize
|
| 17 |
time.sleep(5)
|
| 18 |
|
| 19 |
+
# Ensure your specific model is pulled
|
| 20 |
subprocess.run(["ollama", "pull", "qwen2.5-coder:7b"])
|
| 21 |
|
| 22 |
+
# Start the web server that Hugging Face expects
|
| 23 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|