Commit Β·
7ad30ee
1
Parent(s): 301a758
Use writable /tmp paths for Hugging Face
Browse files- gateway.py +10 -9
gateway.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
# ============================================================
|
| 3 |
# DOLOR3V GATEWAY v6 β Claude Code features
|
| 4 |
# ============================================================
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
-
load_dotenv('/
|
| 7 |
import asyncio
|
| 8 |
import os, sys, json, time, re, math, subprocess, threading, hashlib, itertools
|
| 9 |
import urllib.request, urllib.parse, urllib.error
|
|
@@ -34,7 +35,7 @@ SURGE_EMAIL = os.environ.get("SURGE_EMAIL", "personaldolor@gmail.com")
|
|
| 34 |
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
| 35 |
if not HF_TOKEN:
|
| 36 |
try:
|
| 37 |
-
with open("/
|
| 38 |
for line in f:
|
| 39 |
if line.startswith("HF_TOKEN="):
|
| 40 |
HF_TOKEN = line.strip().split("=",1)[1].strip('\"')
|
|
@@ -44,7 +45,7 @@ if not HF_TOKEN:
|
|
| 44 |
print("HF token loaded:", bool(HF_TOKEN))
|
| 45 |
if not HF_TOKEN:
|
| 46 |
try:
|
| 47 |
-
with open('/
|
| 48 |
for line in f:
|
| 49 |
if line.startswith('HF_TOKEN='):
|
| 50 |
HF_TOKEN = line.strip().split('=',1)[1].strip('"').strip("'")
|
|
@@ -53,7 +54,7 @@ if not HF_TOKEN:
|
|
| 53 |
pass
|
| 54 |
if not HF_TOKEN:
|
| 55 |
try:
|
| 56 |
-
with open('/
|
| 57 |
for line in f:
|
| 58 |
if line.startswith('HF_TOKEN='):
|
| 59 |
HF_TOKEN = line.strip().split('=',1)[1].strip('"').strip("'")
|
|
@@ -64,15 +65,15 @@ HF_USER = os.environ.get("HF_USER", "Daviddolor")
|
|
| 64 |
OLLAMA_URL = "http://localhost:11434"
|
| 65 |
TABBY_URL = "http://localhost:9090"
|
| 66 |
EVENT_BUS_URL = "http://localhost:9091"
|
| 67 |
-
PROJECTS_DIR
|
| 68 |
-
MEMORY_DB
|
| 69 |
LOG_FILE = "/tmp/dolor3v/mcp.log"
|
| 70 |
SAFE_MODE = os.environ.get("DOLOR3V_SAFE_MODE", "true").lower() not in ("0","false","no")
|
| 71 |
MAX_CONTEXT_CHARS = 4000 # smaller limit to avoid 413 from Groq
|
| 72 |
|
| 73 |
os.makedirs(PROJECTS_DIR, exist_ok=True)
|
| 74 |
os.makedirs("/tmp/dolor3v", exist_ok=True)
|
| 75 |
-
os.makedirs("/
|
| 76 |
|
| 77 |
def log(msg):
|
| 78 |
ts = datetime.now().strftime("%H:%M:%S")
|
|
@@ -379,7 +380,7 @@ class GitHub:
|
|
| 379 |
return f"β GitHub error: {e}"
|
| 380 |
@staticmethod
|
| 381 |
def push_source():
|
| 382 |
-
return GitHub.push("/
|
| 383 |
|
| 384 |
class Surge:
|
| 385 |
@staticmethod
|
|
@@ -628,7 +629,7 @@ def execute_tool(tool, args):
|
|
| 628 |
return tabby_complete(args.get("prefix",""), args.get("suffix",""), args.get("lang","python"))
|
| 629 |
elif tool == "hf_deploy":
|
| 630 |
space = args.get("space", f"{HF_USER}/dolor3v")
|
| 631 |
-
src = args.get("src_path", "/
|
| 632 |
if not HF_TOKEN: return "β HF_TOKEN not set"
|
| 633 |
hf_url = f"https://user:{HF_TOKEN}@huggingface.co/spaces/{space}"
|
| 634 |
r = subprocess.run(f"cd {src} && git init && git add -A && git commit -m 'DOLOR3V deploy' && git remote add hf {hf_url} 2>/dev/null || git remote set-url hf {hf_url} && git push hf main --force",
|
|
|
|
| 1 |
+
import os
|
| 2 |
#!/usr/bin/env python3
|
| 3 |
# ============================================================
|
| 4 |
# DOLOR3V GATEWAY v6 β Claude Code features
|
| 5 |
# ============================================================
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
+
load_dotenv('/tmp/dolor3v/.env')
|
| 8 |
import asyncio
|
| 9 |
import os, sys, json, time, re, math, subprocess, threading, hashlib, itertools
|
| 10 |
import urllib.request, urllib.parse, urllib.error
|
|
|
|
| 35 |
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
| 36 |
if not HF_TOKEN:
|
| 37 |
try:
|
| 38 |
+
with open("/tmp/dolor3v/.env") as f:
|
| 39 |
for line in f:
|
| 40 |
if line.startswith("HF_TOKEN="):
|
| 41 |
HF_TOKEN = line.strip().split("=",1)[1].strip('\"')
|
|
|
|
| 45 |
print("HF token loaded:", bool(HF_TOKEN))
|
| 46 |
if not HF_TOKEN:
|
| 47 |
try:
|
| 48 |
+
with open('/tmp/dolor3v/.env') as f:
|
| 49 |
for line in f:
|
| 50 |
if line.startswith('HF_TOKEN='):
|
| 51 |
HF_TOKEN = line.strip().split('=',1)[1].strip('"').strip("'")
|
|
|
|
| 54 |
pass
|
| 55 |
if not HF_TOKEN:
|
| 56 |
try:
|
| 57 |
+
with open('/tmp/dolor3v/.env') as f:
|
| 58 |
for line in f:
|
| 59 |
if line.startswith('HF_TOKEN='):
|
| 60 |
HF_TOKEN = line.strip().split('=',1)[1].strip('"').strip("'")
|
|
|
|
| 65 |
OLLAMA_URL = "http://localhost:11434"
|
| 66 |
TABBY_URL = "http://localhost:9090"
|
| 67 |
EVENT_BUS_URL = "http://localhost:9091"
|
| 68 |
+
PROJECTS_DIR = os.getenv("PROJECTS_DIR", "/tmp/dolor3v/projects")
|
| 69 |
+
MEMORY_DB = "/tmp/dolor3v/memory.json"
|
| 70 |
LOG_FILE = "/tmp/dolor3v/mcp.log"
|
| 71 |
SAFE_MODE = os.environ.get("DOLOR3V_SAFE_MODE", "true").lower() not in ("0","false","no")
|
| 72 |
MAX_CONTEXT_CHARS = 4000 # smaller limit to avoid 413 from Groq
|
| 73 |
|
| 74 |
os.makedirs(PROJECTS_DIR, exist_ok=True)
|
| 75 |
os.makedirs("/tmp/dolor3v", exist_ok=True)
|
| 76 |
+
os.makedirs("/tmp/dolor3v/data", exist_ok=True)
|
| 77 |
|
| 78 |
def log(msg):
|
| 79 |
ts = datetime.now().strftime("%H:%M:%S")
|
|
|
|
| 380 |
return f"β GitHub error: {e}"
|
| 381 |
@staticmethod
|
| 382 |
def push_source():
|
| 383 |
+
return GitHub.push("/tmp/dolor3v", "dolor3v-engine", "DOLOR3V: engine update")
|
| 384 |
|
| 385 |
class Surge:
|
| 386 |
@staticmethod
|
|
|
|
| 629 |
return tabby_complete(args.get("prefix",""), args.get("suffix",""), args.get("lang","python"))
|
| 630 |
elif tool == "hf_deploy":
|
| 631 |
space = args.get("space", f"{HF_USER}/dolor3v")
|
| 632 |
+
src = args.get("src_path", "/tmp/dolor3v")
|
| 633 |
if not HF_TOKEN: return "β HF_TOKEN not set"
|
| 634 |
hf_url = f"https://user:{HF_TOKEN}@huggingface.co/spaces/{space}"
|
| 635 |
r = subprocess.run(f"cd {src} && git init && git add -A && git commit -m 'DOLOR3V deploy' && git remote add hf {hf_url} 2>/dev/null || git remote set-url hf {hf_url} && git push hf main --force",
|