Loading...
Loading...
Connect to local LLM endpoints (Ollama, llama.cpp, vLLM) with automatic provider fallback. Use when: (1) you need to run LLM inference locally for privacy/cost, (2) you want to use models not available via cloud APIs, (3) you need offline capability, (4) you want automatic fallback to cloud providers when local fails.
npx skill4agent add winsorllc/upgraded-carnival local-llm-provider# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Pull a model
ollama pull llama3.2
# Start the server (default: http://localhost:11434)
ollama serve# Build llama-server
make llama-server
# Start the server
llama-server -hf ggml-org/gpt-oss-20b-GGUF -c 133000 --host 127.0.0.1 --port 8080# Install vLLM
pip install vllm
# Start the server
vllm serve meta-llama/Llama-3.1-8B-Instructnode /job/.pi/skills/local-llm-provider/query.js "What is 2+2?" --model llama3.2node /job/.pi/skills/local-llm-provider/query.js "Explain quantum computing" --model mixtral --temp 0.8 --max-tokens 500node /job/.pi/skills/local-llm-provider/list-models.jsnode /job/.pi/skills/local-llm-provider/health.jsnode /job/.pi/skills/local-llm-provider/query.js "Tell me a story" --streamconfig.json{
"providers": [
{
"name": "ollama",
"url": "http://localhost:11434",
"enabled": true,
"fallback_order": 1
},
{
"name": "llamacpp",
"url": "http://localhost:8080/v1",
"enabled": false,
"fallback_order": 2
},
{
"name": "vllm",
"url": "http://localhost:8000/v1",
"enabled": false,
"fallback_order": 3
}
],
"default_model": "llama3.2",
"fallback_to_cloud": true,
"cloud_provider": "anthropic",
"timeout_ms": 120000
}const { LocalLLMProvider } = require('./provider.js');
const provider = new LocalLLMProvider({
providers: [
{ name: 'ollama', url: 'http://localhost:11434', enabled: true },
{ name: 'anthropic', api_key: process.env.ANTHROPIC_API_KEY, enabled: false }
],
default_model: 'llama3.2',
fallback_to_cloud: true
});
const response = await provider.complete('Hello, how are you?');
console.log(response);{
"success": true,
"provider": "ollama",
"model": "llama3.2",
"response": "I'm doing well, thank you for asking!",
"tokens": 42,
"duration_ms": 1500,
"done": true
}{
"success": true,
"provider": "ollama",
"model": "llama3.2",
"response": "I",
"tokens": 1,
"done": false
}{
"success": false,
"error": "All providers failed",
"providers_tried": ["ollama", "llamacpp"],
"last_error": "Connection refused"
}| Variable | Description | Default |
|---|---|---|
| Ollama server URL | http://localhost:11434 |
| llama.cpp server URL | http://localhost:8080/v1 |
| vLLM server URL | http://localhost:8000/v1 |
| Default model to use | llama3.2 |
ollama pull mixtral