Download Game! Currently 70 players and visitors. Last logged in:BlitzerSirdaDeinoGoatze

Blitzer's Blog >> 72305

Back to blogs index
Posted: 12 Sep 2026 16:53 [ permalink ]
This is a fantastic infrastructure setup. Running Mozilla's Llamafile inside
an LXC container and routing it over a Tailscale mesh network is the gold
standard for a lightweight, secure, private AI cloud.
Because Llamafile natively exposes an OpenAI-compatible API endpoint (as
proven by your Python AsyncOpenAI script), integrating your new Gemma-2-9b
node into our AST-MD Compiler is incredibly simple.
We can treat your Tailscale LXC node exactly like DeepSeek or OpenAI, just
pointing to your internal IP instead.
Here is how to update your compiler.js to add your new mesh_gemma provider.
Update the AI Provider Factory in compiler.js
Replace the provider section with this code. It adds a fetchMeshLLM function
that perfectly matches the payload structure your Llamafile expects:
/ ==========================================
/ 7. AI PROVIDER FACTORY (DeepSeek + Mesh LXC)
/ ==========================================

async function fetchMeshLLM(prompt, modelName = 'gemma-2-9b-it') {
    // Your Tailscale LXC IP and Llamafile port
    const MESH_URL = 'http://100.111.184.107:8080/v1/chat/completions';
    
    const response = await fetch(MESH_URL, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer sk-local-no-key' // Dummy key for
Llamafile
        },
        body: JSON.stringify({
            model: modelName,
            messages: [
                { role: 'system', content: 'You are an autonomous code
generation engine. Output ONLY executable JavaScript code. No markdown
wrapping, no explanations.' },
                { role: 'user', content: prompt }
            ],
            temperature: 0.1
        })
    });

    if (!response.ok) {
        throw new Error(`Mesh LLM Error (${response.status}): ${await
response.text()}`);
    }

    const data = await response.json();
    let code = data.choices[0].message.content.trim();
    
    // Gemma sometimes adds <end_of_turn> or markdown blocks, so we clean it
    code = code.replace(/<end_of_turn>/g, '');
    code = code.replace(/^```[a-z]*
/i, ''); 
    code = code.replace(/
```$/i, '');
    
    return code;
}

/ ... (Keep the fetchDeepSeek function here if you still want to use it) ...

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

    switch (provider) {
        case 'mesh_gemma':
            // Routes to your Tailscale LXC container
            return await fetchMeshLLM(hydratedPrompt, 'gemma-2-9b-it');
            
        case 'deepseek':
            // Routes to external DeepSeek API
            return await fetchDeepSeek(hydratedPrompt, 'deepseek-coder');
            
        default:
            throw new Error(`Unknown provider: ${provider}`);
    }
}

How to use this in your AST-MD Specs
Now, your compiler acts as a true Load Balancer/Router for your code
generation. You can dictate exactly which brain handles which task.
For standard boilerplate, you can rely on your free local Gemma mesh. For
complex algorithms, you can route to DeepSeek:
## CONFIG_PARSER
> description: A simple script to read a JSON config file.
> type: logic
> provider: mesh_gemma

## ADVANCED_ROUTING_ALGORITHM
> description: Implements a highly complex Dijkstra pathfinding algorithm.
> type: algorithm
> provider: deepseek
> depends_on: [CONFIG_PARSER]
> checkpoint: true

If you run node index.js with this updated script, the orchestrator will fire
the CONFIG_PARSER prompt over your Tailscale network to the LXC container.
Gemma will generate the code and return it. Then, the orchestrator will embed
Gemma's code into the context prompt and send the whole package out to
DeepSeek.
It perfectly marries the economics of your local hardware with the raw power
of frontier models!