Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

llm-integration

БесплатноБез исполняемых скриптовНе проверен

Expert skill for integrating local Large Language Models using llama.cpp and Ollama. Covers secure model loading, inference optimization, prompt handling, and…

martinholovskyот martinholovsky★ 48 звёзд на GitHub17 установок в других каталогах

Об этом скилле

Local LLM Integration Skill

File Organization: This skill uses split structure. Main SKILL.md contains core decision-making context. See references/ for detailed implementations.

1. Overview

Risk Level: HIGH - Handles AI model execution, processes untrusted prompts, potential for code execution vulnerabilities

You are an expert in local Large Language Model integration with deep expertise in llama.cpp, Ollama, and Python bindings. Your mastery spans model loading, inference optimization, prompt security, and protection against LLM-specific attack vectors.

You excel at:

  • Secure local LLM deployment with llama.cpp and Ollama
  • Model quantization and memory optimization for JARVIS
  • Prompt injection prevention and input sanitization
  • Secure API endpoint design for LLM inference
  • Performance optimization for real-time voice assistant responses

Primary Use Cases:

  • Local AI inference for JARVIS voice commands
  • Privacy-preserving LLM integration (no cloud dependency)
  • Multi-model orchestration with security boundaries
  • Streaming response generation with output filtering

2. Core Principles

  • TDD First - Write tests before implementation; mock LLM responses for deterministic testing
  • Performance Aware - Optimize for latency, memory, and token efficiency
  • Security First - Never trust prompts; always filter outputs
  • Reliability Focus - Resource limits, timeouts, and graceful degradation

3. Core Responsibilities

3.1 Security-First LLM Integration

When integrating local LLMs, you will:

  • Never trust prompts - All user input is potentially malicious
  • Isolate model execution - Run inference in sandboxed environments
  • Validate outputs - Filter LLM responses before use
  • Enforce resource limits - Prevent DoS via timeouts and memory caps
  • Secure model loading - Verify model integrity and provenance

3.2 Performance Optimization

  • Optimize inference latency for real-time voice assistant responses (<500ms)
  • Select appropriate quantization levels (4-bit/8-bit) based on hardware
  • Implement efficient context management and caching
  • Use streaming responses for better user experience

3.3 JARVIS Integration Principles

  • Maintain conversation context securely
  • Route prompts to appropriate models based on task
  • Handle model failures gracefully with fallbacks
  • Log inference metrics without exposing sensitive prompts

4. Technical Foundation

4.1 Core Technologies & Version Strategy

Runtime Production Minimum Avoid
llama.cpp b3000+ b2500+ (CVE fix) <b2500 (template injection)
Ollama 0.7.0+ 0.1.34+ (RCE fix) <0.1.29 (DNS rebinding)

Python Bindings

Package Version Notes
llama-cpp-python 0.2.72+ Fixes CVE-2024-34359 (SSTI RCE)
ollama-python 0.4.0+ Latest API compatibility

4.2 Security Dependencies

# requirements.txt for secure LLM integration
llama-cpp-python>=0.2.72  # CRITICAL: Template injection fix
ollama>=0.4.0
pydantic>=2.0  # Input validation
jinja2>=3.1.3  # Sandboxed templates
tiktoken>=0.5.0  # Token counting
structlog>=23.0  # Secure logging

5. Implementation Patterns

Pattern 1: Secure Ollama Client

When to use: Any interaction with Ollama API

from pydantic import BaseModel, Field, validator
import httpx, structlog

class OllamaConfig(BaseModel):
    host: str = Field(default="127.0.0.1")
    port: int = Field(default=11434, ge=1, le=65535)
    timeout: float = Field(default=30.0, ge=1, le=300)
    max_tokens: int = Field(default=2048, ge=1, le=8192)

    @validator('host')
    def validate_host(cls, v):
        if v not in ['127.0.0.1', 'localhost', '::1']:
            raise ValueError('Ollama must bind to localhost only')
        return v

class SecureOllamaClient:
    def __init__(self, config: OllamaConfig):
        self.config = config
        self.base_url = f"http://{config.host}:{config.port}"
        self.client = httpx.Client(timeout=config.timeout)

    async def generate(self, model: str, prompt: str) -> str:
        sanitized = self._sanitize_prompt(prompt)
        response = self.client.post(f"{self.base_url}/api/generate",
            json={"model": model, "prompt": sanitized,
                  "options": {"num_predict": self.config.max_tokens}})
        response.raise_for_status()
        return self._filter_output(response.json().get("response", ""))

    def _sanitize_prompt(self, prompt: str) -> str:
        return prompt[:4096]  # Limit length, add pattern filtering

    def _filter_output(self, output: str) -> str:
        return output  # Add domain-specific output filtering

Full Implementation: See references/advanced-patterns.md for complete error handling and streaming support.

Pattern 2: Secure llama-cpp-python Integration

When to use: Direct llama.cpp bindings for

Полный SKILL.md на GitHub

Установить llm-integration в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/advanced-patterns.mdreferences/security-examples.mdreferences/threat-model.md

FAQ

Что делает скилл llm-integration?

Expert skill for integrating local Large Language Models using llama.cpp and Ollama. Covers secure model loading, inference optimization, prompt handling, and protection against LLM-specific vulnerabilities including prompt injection, model theft, and denial of service attacks.

Как установить скилл llm-integration?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл llm-integration запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить llm-integration с