Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,12 +7,15 @@ import time
|
|
7 |
import json
|
8 |
|
9 |
app = Flask(__name__)
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
12 |
REPO_URL = "https://github.com/NitinBot001/Audio-url-new-js.git"
|
13 |
|
14 |
def download_model():
|
15 |
-
os.makedirs(
|
16 |
if not os.path.exists(MODEL_PATH):
|
17 |
print("Downloading model...")
|
18 |
r = requests.get(
|
@@ -48,18 +51,18 @@ def start_tunnel():
|
|
48 |
def push_tunnel_url_to_repo(tunnel_url):
|
49 |
# Create instance.json
|
50 |
instance_data = {"tunnel_url": tunnel_url}
|
51 |
-
with open("instance.json", "w") as f:
|
52 |
json.dump(instance_data, f)
|
53 |
|
54 |
# Clone the repository
|
55 |
subprocess.run(
|
56 |
-
["git", "clone", f"https://x-access-token:{GH_PAT}@{REPO_URL.split('https://')[1]}", "repo"],
|
57 |
check=True,
|
58 |
)
|
59 |
-
os.chdir("repo")
|
60 |
|
61 |
# Move instance.json to the repository
|
62 |
-
subprocess.run(["mv", "
|
63 |
|
64 |
# Commit and push changes
|
65 |
subprocess.run(["git", "config", "--global", "user.email", "[email protected]"], check=True)
|
|
|
7 |
import json
|
8 |
|
9 |
app = Flask(__name__)
|
10 |
+
|
11 |
+
# Use /tmp directory for storing the model
|
12 |
+
MODEL_DIR = "/tmp/model"
|
13 |
+
MODEL_PATH = os.path.join(MODEL_DIR, "calme-3.3-llamaloi-3b.Q4_K_M.gguf")
|
14 |
+
GH_PAT = os.getenv("GH_PAT", "ghp_TGVMURDWG3HkLIfWUa4hyJUGYOYgXH1EljIi") # GitHub Personal Access Token
|
15 |
REPO_URL = "https://github.com/NitinBot001/Audio-url-new-js.git"
|
16 |
|
17 |
def download_model():
|
18 |
+
os.makedirs(MODEL_DIR, exist_ok=True) # Create the /tmp/model directory
|
19 |
if not os.path.exists(MODEL_PATH):
|
20 |
print("Downloading model...")
|
21 |
r = requests.get(
|
|
|
51 |
def push_tunnel_url_to_repo(tunnel_url):
|
52 |
# Create instance.json
|
53 |
instance_data = {"tunnel_url": tunnel_url}
|
54 |
+
with open("/tmp/instance.json", "w") as f:
|
55 |
json.dump(instance_data, f)
|
56 |
|
57 |
# Clone the repository
|
58 |
subprocess.run(
|
59 |
+
["git", "clone", f"https://x-access-token:{GH_PAT}@{REPO_URL.split('https://')[1]}", "/tmp/repo"],
|
60 |
check=True,
|
61 |
)
|
62 |
+
os.chdir("/tmp/repo")
|
63 |
|
64 |
# Move instance.json to the repository
|
65 |
+
subprocess.run(["mv", "/tmp/instance.json", "."], check=True)
|
66 |
|
67 |
# Commit and push changes
|
68 |
subprocess.run(["git", "config", "--global", "user.email", "[email protected]"], check=True)
|