aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / scripts / allen / allen-chat.service
| 1 | # /etc/systemd/system/allen-chat.service |
| 2 | # System unit with a dedicated system user (no login shell, no sudoers entry). |
| 3 | # Not a --user unit: on this Spark the user manager silently skips mount |
| 4 | # namespacing (AppArmor restricts unprivileged user namespaces), and not |
| 5 | # drakestapleton, whose account has sudo: the sandbox is not the only layer. |
| 6 | [Unit] |
| 7 | Description=allen-chat: public gateway for www.aienos.com/allen/ (tailnet only, no credentials) |
| 8 | After=network-online.target tailscaled.service |
| 9 | Wants=network-online.target |
| 10 | |
| 11 | [Service] |
| 12 | Type=simple |
| 13 | User=allen-chat |
| 14 | Group=allen-chat |
| 15 | SupplementaryGroups=allen-spool allen-drop allen-relaydrop |
| 16 | EnvironmentFile=-/etc/allen-chat/env |
| 17 | ExecStart=/usr/bin/python3 -I /opt/allen-chat/allen_chat.py \ |
| 18 | --listen 100.64.0.2:18110 \ |
| 19 | --trusted-proxy 100.64.0.3 \ |
| 20 | --upstream 127.0.0.1:18091 \ |
| 21 | --system-prompt /opt/allen-chat/system-prompt.txt \ |
| 22 | --catalog /var/lib/allen-catalog/catalog.txt \ |
| 23 | --areas-file /var/lib/allen-catalog/areas.txt \ |
| 24 | --catalog-detail /var/lib/allen-catalog/catalog-detail.jsonl \ |
| 25 | --catalog-retrieve /opt/allen-catalog/retrieve.py \ |
| 26 | --learn-dir /opt/allen-chat/learn \ |
| 27 | --answers /opt/allen-chat/answers.json \ |
| 28 | --answers-state /var/lib/allen-chat/answers \ |
| 29 | --omc /opt/allen-chat/omc \ |
| 30 | --irwasm /opt/allen-chat/irwasm \ |
| 31 | --spool-in /var/lib/allen-chat/spool-in \ |
| 32 | --spool-status /var/lib/allen-chat/spool-status \ |
| 33 | --contacts-drop /var/lib/allen-chat/contacts-drop \ |
| 34 | --memory-url http://127.0.0.1:18096 \ |
| 35 | --relay-drop /var/lib/allen-chat/relay-drop \ |
| 36 | --console-listen 100.64.0.2:18112 \ |
| 37 | --console-state /var/lib/allen-chat/console \ |
| 38 | --whisper-cli /opt/allen-chat/whisper-cli \ |
| 39 | --whisper-model /opt/allen-chat/ggml-base.en.bin \ |
| 40 | --transcribe-threads 4 |
| 41 | Environment=PATH=/usr/bin:/bin |
| 42 | Restart=on-failure |
| 43 | RestartSec=5 |
| 44 | UMask=0027 |
| 45 | Nice=5 |
| 46 | |
| 47 | # What public Allen cannot do (README): no credentials, no home, writes only into the drop dirs |
| 48 | # (spool, contacts, relay) and the console's presence.json. The console listener (18112) is |
| 49 | # tailnet only; nft admits it only from Drake's devices 100.64.0.1/100.64.0.4 and the Spark. |
| 50 | NoNewPrivileges=yes |
| 51 | CapabilityBoundingSet= |
| 52 | AmbientCapabilities= |
| 53 | PrivateUsers=yes |
| 54 | ProtectProc=invisible |
| 55 | ProtectSystem=strict |
| 56 | ProtectHome=yes |
| 57 | ReadWritePaths=/var/lib/allen-chat/spool-in /var/lib/allen-chat/contacts-drop /var/lib/allen-chat/relay-drop /var/lib/allen-chat/console /var/lib/allen-chat/answers |
| 58 | InaccessiblePaths=-/var/lib/allen-contacts -/var/lib/omega-pusher -/var/lib/allen-relay |
| 59 | PrivateTmp=yes |
| 60 | PrivateDevices=yes |
| 61 | ProtectKernelTunables=yes |
| 62 | ProtectKernelModules=yes |
| 63 | ProtectKernelLogs=yes |
| 64 | ProtectControlGroups=yes |
| 65 | ProtectClock=yes |
| 66 | ProtectHostname=yes |
| 67 | RestrictSUIDSGID=yes |
| 68 | RestrictRealtime=yes |
| 69 | LockPersonality=yes |
| 70 | MemoryDenyWriteExecute=yes |
| 71 | # AF_NETLINK only because bwrap configures the loopback of the compile sandbox's |
| 72 | # empty network namespace over NETLINK_ROUTE; without CAP_NET_ADMIN it can change nothing. |
| 73 | RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK |
| 74 | IPAddressDeny=any |
| 75 | IPAddressAllow=127.0.0.1 100.64.0.1 100.64.0.2 100.64.0.3 100.64.0.4 |
| 76 | SystemCallFilter=@system-service @mount unshare setns |
| 77 | SystemCallArchitectures=native |
| 78 | MemoryMax=1G |
| 79 | TasksMax=128 |
| 80 | # 600%: one push-to-talk transcription (base.en, 4 threads) uses about 3.9 CPU-s per 5 s clip, so |
| 81 | # 200% would stretch it to at least ~1.9 s (2 threads measured 1.95 s p50). One at a time (cap 1). |
| 82 | CPUQuota=600% |
| 83 | LimitNOFILE=1024 |
| 84 | StandardOutput=journal |
| 85 | StandardError=journal |
| 86 | |
| 87 | [Install] |
| 88 | WantedBy=multi-user.target |