// What powers this chatbot
// Model: Cloudflare Workers AI
// Llama 3.1 8B Instruct — streaming SSE
// Rate limited: 4 msg/min, 30/h per IP
const SYSTEM_PROMPT = `
You are Claude, the AI that co-built
pixelium.win with Stéphane Ferreira.
Your job: answer questions about his
skills, experience, and projects.
Every fact is verifiable — git history,
ops journal, or public profiles.
30+ services in production
3 Proxmox nodes, 0€ cloud
HTB Hacker #967 global
14 Ansible playbooks, 34 hosts
Internal PKI, SSO, IPS, SIEM, VPN
...
`;
const stream = await env.AI.run(
'@cf/meta/llama-3.1-8b-instruct',
{
messages: [
{ role: 'system', content: SYSTEM_PROMPT },
...history,
],
stream: true,
max_tokens: 512,
}
); # wrangler.toml — Cloudflare Workers config
name = "pixelium-site"
compatibility_date = "2025-01-01"
[ai]
binding = "AI"
[[kv_namespaces]]
binding = "SESSION" # rate limiting
[[kv_namespaces]]
binding = "STATUS_KV" # live infra status
[[kv_namespaces]]
binding = "STATS_KV" # portfolio stats
[[d1_databases]]
binding = "HISTORY_DB" # uptime history
// POST /api/chat — unified AI endpoint
export const POST: APIRoute = async ({ request }) => {
// Rate limit per IP via KV
const ip = request.headers.get('cf-connecting-ip');
const rl = await checkRateLimit(ip);
if (!rl.allowed) return 429;
// mode: "cv" | "sysop" | "challenge"
const { mode, messages } = await request.json();
const prompt = PROMPTS[mode];
// Stream response via SSE
const stream = await env.AI.run(MODEL, {
messages: [
{ role: 'system', content: prompt },
...messages.slice(-10),
],
stream: true,
});
return new Response(stream, {
headers: { 'Content-Type': 'text/event-stream' }
});
};