-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
38 lines (30 loc) · 1.36 KB
/
config.py
File metadata and controls
38 lines (30 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import annotations
import os
from pathlib import Path
from dataclasses import dataclass
from dotenv import load_dotenv
load_dotenv()
BASE_DIR = Path(__file__).resolve().parent
PROJECTS_DIR = BASE_DIR / os.getenv("PIFORGE_PROJECTS_DIR", "projects")
DATA_DIR = BASE_DIR / os.getenv("PIFORGE_DATA_DIR", "data")
SESSIONS_PATH = DATA_DIR / "sessions.json"
HOST = os.getenv("PIFORGE_HOST", "0.0.0.0")
PORT = int(os.getenv("PIFORGE_PORT", "8080"))
DEBUG = os.getenv("PIFORGE_DEBUG", "false").lower() == "true"
MODEL_BACKEND = os.getenv("PIFORGE_MODEL_BACKEND", "mock").strip().lower()
OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://127.0.0.1:11434")
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL", "qwen2.5-coder:7b")
OPENAI_COMPAT_BASE_URL = os.getenv("OPENAI_COMPAT_BASE_URL", "").strip()
OPENAI_COMPAT_API_KEY = os.getenv("OPENAI_COMPAT_API_KEY", "").strip()
OPENAI_COMPAT_MODEL = os.getenv("OPENAI_COMPAT_MODEL", "").strip()
SAFE_COMMAND_PREFIXES = [
"python", "python3", "pip", "pip3", "pytest", "git", "mkdir", "touch",
"ls", "pwd", "cat", "echo", "cp", "mv", "npm", "node"
]
BLOCKED_SUBSTRINGS = [
" rm ", " rm-", "sudo", "mkfs", "dd ", ":(){", "shutdown", "reboot", "poweroff", "> /dev/"
]
for path in (PROJECTS_DIR, DATA_DIR):
path.mkdir(parents=True, exist_ok=True)
if not SESSIONS_PATH.exists():
SESSIONS_PATH.write_text("[]", encoding="utf-8")