Spaces:
Runtime error
Runtime error
Merge pull request #70 from EnvisionMindCa/codex/make-backend-production-ready
Browse files- README.md +8 -0
- src/config.py +1 -0
- src/db.py +3 -1
- src/log.py +11 -2
README.md
CHANGED
@@ -8,6 +8,14 @@
|
|
8 |
- **Tool execution** β a built-in `execute_terminal` tool runs commands inside a Docker-based VM. Network access is enabled and both stdout and stderr are captured (up to 10,000 characters). The VM is reused across chats when `PERSIST_VMS=1` so installed packages remain available.
|
9 |
- **System prompts** β every request includes a system prompt that guides the assistant to plan tool usage, verify results and avoid unnecessary jargon.
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
## Quick Start
|
12 |
|
13 |
```bash
|
|
|
8 |
- **Tool execution** β a built-in `execute_terminal` tool runs commands inside a Docker-based VM. Network access is enabled and both stdout and stderr are captured (up to 10,000 characters). The VM is reused across chats when `PERSIST_VMS=1` so installed packages remain available.
|
9 |
- **System prompts** β every request includes a system prompt that guides the assistant to plan tool usage, verify results and avoid unnecessary jargon.
|
10 |
|
11 |
+
## Environment Variables
|
12 |
+
|
13 |
+
Several settings can be customised via environment variables:
|
14 |
+
|
15 |
+
- `DB_PATH` β location of the SQLite database (default `chat.db` in the project directory).
|
16 |
+
- `LOG_LEVEL` β logging verbosity (`DEBUG`, `INFO`, etc.).
|
17 |
+
- `VM_IMAGE` and `VM_STATE_DIR` control the Docker-based VM.
|
18 |
+
|
19 |
## Quick Start
|
20 |
|
21 |
```bash
|
src/config.py
CHANGED
@@ -16,6 +16,7 @@ PERSIST_VMS: Final[bool] = os.getenv("PERSIST_VMS", "1") == "1"
|
|
16 |
VM_STATE_DIR: Final[str] = os.getenv(
|
17 |
"VM_STATE_DIR", str(Path.cwd() / "vm_state")
|
18 |
)
|
|
|
19 |
|
20 |
SYSTEM_PROMPT: Final[str] = (
|
21 |
"You are Starlette, the senior agent leading a two-agent team. "
|
|
|
16 |
VM_STATE_DIR: Final[str] = os.getenv(
|
17 |
"VM_STATE_DIR", str(Path.cwd() / "vm_state")
|
18 |
)
|
19 |
+
DB_PATH: Final[str] = os.getenv("DB_PATH", str(Path.cwd() / "chat.db"))
|
20 |
|
21 |
SYSTEM_PROMPT: Final[str] = (
|
22 |
"You are Starlette, the senior agent leading a two-agent team. "
|
src/db.py
CHANGED
@@ -3,6 +3,8 @@ from __future__ import annotations
|
|
3 |
from datetime import datetime
|
4 |
from pathlib import Path
|
5 |
|
|
|
|
|
6 |
from peewee import (
|
7 |
AutoField,
|
8 |
CharField,
|
@@ -14,7 +16,7 @@ from peewee import (
|
|
14 |
)
|
15 |
|
16 |
|
17 |
-
_DB_PATH = Path(
|
18 |
_db = SqliteDatabase(_DB_PATH)
|
19 |
|
20 |
|
|
|
3 |
from datetime import datetime
|
4 |
from pathlib import Path
|
5 |
|
6 |
+
from .config import DB_PATH
|
7 |
+
|
8 |
from peewee import (
|
9 |
AutoField,
|
10 |
CharField,
|
|
|
16 |
)
|
17 |
|
18 |
|
19 |
+
_DB_PATH = Path(DB_PATH)
|
20 |
_db = SqliteDatabase(_DB_PATH)
|
21 |
|
22 |
|
src/log.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from __future__ import annotations
|
2 |
|
3 |
import logging
|
|
|
4 |
from typing import Final
|
5 |
|
6 |
from colorama import Fore, Style, init as colorama_init
|
@@ -22,10 +23,18 @@ class _ColourFormatter(logging.Formatter):
|
|
22 |
return f"{colour}{super().format(record)}{Style.RESET_ALL}"
|
23 |
|
24 |
|
25 |
-
def get_logger(name: str | None = None, level: int =
|
|
|
|
|
26 |
colorama_init()
|
|
|
|
|
|
|
|
|
27 |
handler = logging.StreamHandler()
|
28 |
-
handler.setFormatter(
|
|
|
|
|
29 |
|
30 |
logger = logging.getLogger(name)
|
31 |
logger.setLevel(level)
|
|
|
1 |
from __future__ import annotations
|
2 |
|
3 |
import logging
|
4 |
+
import os
|
5 |
from typing import Final
|
6 |
|
7 |
from colorama import Fore, Style, init as colorama_init
|
|
|
23 |
return f"{colour}{super().format(record)}{Style.RESET_ALL}"
|
24 |
|
25 |
|
26 |
+
def get_logger(name: str | None = None, level: int | None = None) -> logging.Logger:
|
27 |
+
"""Return a configured logger instance."""
|
28 |
+
|
29 |
colorama_init()
|
30 |
+
env_level = os.getenv("LOG_LEVEL", "INFO").upper()
|
31 |
+
if level is None:
|
32 |
+
level = getattr(logging, env_level, logging.INFO)
|
33 |
+
|
34 |
handler = logging.StreamHandler()
|
35 |
+
handler.setFormatter(
|
36 |
+
_ColourFormatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")
|
37 |
+
)
|
38 |
|
39 |
logger = logging.getLogger(name)
|
40 |
logger.setLevel(level)
|