Command Palette

Search for a command to run...

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

offline-ai-toolkit

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

Build offline-capable AI systems with local models, embedded knowledge bases, and no internet dependency. Use when: building AI tools for offline use…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

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

Offline AI Toolkit — Self-Contained AI Systems

Overview

Build AI systems that work completely offline — local LLMs via Ollama, embedded vector search with SQLite, knowledge bases from pre-downloaded content, and a PWA interface that runs without connectivity. Ideal for field work, air-gapped environments, or privacy-first deployments.

Instructions

Step 1: Install Ollama for Local LLMs

brew install ollama            # macOS (Linux: tarball below; Windows: winget install Ollama.Ollama)
ollama serve &                 # skip if the desktop app or systemd service already runs it
ollama pull llama3.1:8b        # General purpose (about 5GB)
ollama pull nomic-embed-text   # Embeddings (274MB, 2K context)
ollama list                    # confirm both are on disk

On Linux, download ollama-linux-amd64.tar.zst (or the arm64 build) from the Ollama GitHub releases page, check it against the sha256sum.txt published there, then extract it under /usr. For an air-gapped target, do the downloads and ollama pull on a connected machine and copy the ~/.ollama/models directory (or the whole Docker volume of the ollama/ollama image) to the offline machine. Set OLLAMA_HOST=127.0.0.1:11434 so the API is not exposed on the network.

Use Case Model RAM Needed
General Q&A llama3.1:8b 8GB
Quick answers phi3:mini 4GB
Code help qwen2.5-coder:7b 8GB
Embeddings nomic-embed-text 2GB

Step 2: Build the Offline Knowledge Base

import os
import sqlite3
from urllib.parse import quote

import requests

HEADERS = {'User-Agent': 'offline-kb-builder (https://terminalskills.io)'}  # Wikipedia requires one

def init_knowledge_db(db_path='knowledge.db'):
    """Initialize SQLite database for knowledge storage."""
    conn = sqlite3.connect(db_path)
    conn.execute('''CREATE TABLE IF NOT EXISTS documents (
        id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT,
        source TEXT, content TEXT, category TEXT,
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )''')
    conn.execute('''CREATE TABLE IF NOT EXISTS embeddings (
        id INTEGER PRIMARY KEY, doc_id INTEGER REFERENCES documents(id),
        chunk_text TEXT, embedding BLOB, chunk_index INTEGER
    )''')
    # External-content FTS index; run the 'rebuild' command after loading documents
    conn.execute('''CREATE VIRTUAL TABLE IF NOT EXISTS fts_documents
        USING fts5(title, content, category, content='documents', content_rowid='id')''')
    return conn

def download_wikipedia_articles(topics, conn):
    """Download Wikipedia articles for offline knowledge."""
    for topic in topics:
        url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{quote(topic)}"
        try:
            r = requests.get(url, headers=HEADERS, timeout=10)
            r.raise_for_status()
            data = r.json()
            content = data.get('extract', '')
            if content:
                conn.execute(
                    'INSERT INTO documents (title, source, content, category) VALUES (?, ?, ?, ?)',
                    (data.get('title', topic), f'wikipedia:{topic}', content, 'encyclopedia'))
        except Exception as e:
            print(f"Failed to download {topic}: {e}")
    conn.commit()
    conn.execute("INSERT INTO fts_documents(fts_documents) VALUES ('rebuild')")
    conn.commit()

Wikipedia summaries are only a paragraph each. For full articles bundle a Kiwix ZIM file and serve it with kiwix-serve, or ingest your own Markdown/PDF text.

Step 3: Generate Embeddings with Ollama

import struct

def get_embedding(text, model='nomic-embed-text'):
    """Get embedding vector from Ollama (/api/embed; /api/embeddings is the legacy endpoint)."""
    response = requests.post('http://localhost:11434/api/embed',
                             json={'model': model, 'input': text}, timeout=60)
    response.raise_for_status()
    return response.json()['embeddings'][0]

def embedding_to_blob(embedding):
    return struct.pack(f'{len(embedding)}f', *embedding)

def blob_to_embedding(blob):
    n = len(blob) // 4
    return list(struct.unpack(f'{n}f', blob))

def embed_all_documents(conn, chunk_size=500):
    """Generate embeddings for all documents in the database."""
    cursor = conn.execute('SELECT id, content FROM documents')
    for doc_id, content in cursor.fetchall():
        words = content.split()
        for i in range(0, len(words), chunk_size):
            chunk = ' '.join(words[i:i + chunk_size])
            if len(chunk.strip()) < 20:
                continue
            emb = get_embedding(chunk)
            conn.execute(
                'INSERT INTO embeddings (doc_id, chunk_text, embedding, chunk_index) VALUES (?, ?, ?, ?)',
                (doc_id, chunk, embedding_to_blob(emb), i // chunk_size))
    conn.commit()

Step 4: Offline Vector Search

import math

def cosine_similarity(a, b):
    dot = sum(x
Полный SKILL.md на GitHub

Установить offline-ai-toolkit в Claude Code и Claude Desktop

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

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

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

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

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

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

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

_scores.json

FAQ

Что делает скилл offline-ai-toolkit?

Build offline-capable AI systems with local models, embedded knowledge bases, and no internet dependency. Use when: building AI tools for offline use, creating self-contained knowledge systems, deploying AI in air-gapped environments.

Как установить скилл offline-ai-toolkit?

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

Скилл offline-ai-toolkit запускает скрипты?

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

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

Сравнить offline-ai-toolkit с