Download Game! Currently 72 players and visitors. Last logged in:CelbornKandaharIberiamsspGunk

Blitzer's Blog >> 72304

Back to blogs index
Posted: 12 Sep 2026 15:00 [ permalink ]
Buying DeepSeek a coffee is a great investment for this projecttheir
deepseek-coder model is exceptionally good at following strict instructions,
and their API is natively compatible with the OpenAI format, making it
incredibly easy to integrate.
Because their API uses standard /chat/completions, we will format your
hydrated prompt as a conversation array.
Here is exactly how to update your compiler.js to route online_llm nodes
straight to DeepSeek.
1. Update the AI Provider Factory
Replace the AI integration block in your compiler.js with this updated
version:
/ ==========================================
/ 7. AI PROVIDER FACTORY (DeepSeek + Local)
/ ==========================================

async function fetchLocalLLM(prompt, modelName = 'llama3') {
    const OLLAMA_URL = 'http://localhost:11434/api/generate';
    const response = await fetch(OLLAMA_URL, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ model: modelName, prompt: prompt, stream: false
})
    });

    if (!response.ok) throw new Error(`Local LLM Error: ${response.status}`);
    const data = await response.json();
    return cleanMarkdown(data.response);
}

async function fetchDeepSeek(prompt, modelName = 'deepseek-coder') {
    const apiKey = process.env.DEEPSEEK_API_KEY;
    
    if (!apiKey) {
        throw new Error("Missing DEEPSEEK_API_KEY environment variable. Cannot
route to online_llm.");
    }

    const response = await fetch('https://api.deepseek.com/chat/completions',
{
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${apiKey}`
        },
        body: JSON.stringify({
            model: modelName,
            messages: [
                { role: 'system', content: 'You are an autonomous code
generation engine. Output ONLY executable code. No pleasantries, no markdown
wrapping, no explanations.' },
                { role: 'user', content: prompt }
            ],
            temperature: 0.1 // Low temperature for deterministic, logical
code generation
        })
    });

    if (!response.ok) {
        const errBody = await response.text();
        throw new Error(`DeepSeek API Error (${response.status}):
${errBody}`);
    }

    const data = await response.json();
    const rawCode = data.choices[0].message.content;
    return cleanMarkdown(rawCode);
}

function cleanMarkdown(text) {
    let code = text.trim();
    // Strip ```javascript and ``` tags that LLMs love to add
    code = code.replace(/^```[a-z]*
/i, ''); 
    code = code.replace(/
```$/i, '');
    return code;
}

async function dispatchToAI(node, hydratedPrompt) {
    const provider = node.provider || 'local'; 
    console.log(`   [API] Routing payload for ${node.id} to provider:
[${provider.toUpperCase()}]`);

    switch (provider) {
        case 'local':
            return await fetchLocalLLM(hydratedPrompt, node.model ||
'llama3');
            
        case 'online_llm':
            // Route complex logic straight to DeepSeek Coder
            return await fetchDeepSeek(hydratedPrompt, node.model ||
'deepseek-coder');
            
        default:
            throw new Error(`Unknown provider: ${provider}`);
    }
}

2. How to Run It
To keep your API key secure, pass it directly into the execution command in
your terminal.
If you clear your ./build directory and run this command, the orchestrator
will build DATABASE_MODELS using your local machine, and then securely fire
the payload for BUSINESS_LOGIC across the internet to DeepSeek, retrieve the
code, strip the markdown, and save it to your disk.
DEEPSEEK_API_KEY="your_actual_api_key_here" node index.js

Why temperature: 0.1?
For chatbots, a high temperature (like 0.7) makes the text flow nicely. For
our compiler, a high temperature makes the AI "creative" with syntax, which
leads to crashes. Setting the temperature to 0.1 forces DeepSeek to pick the
most mathematically probable token every single time. It turns the AI into a
strict compiler rather than a conversationalist.