chat

command
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

chat — Basic RAG chat (CLI)

Interactive RAG chat with in-memory storage. Loads a set of documents, then accepts questions via stdin and answers with inline citations [1], [2].

The store lives in memory — data is not persisted between runs.

Quick start

EMBEDDER_API_KEY=sk-... \
LLM_API_KEY=sk-... \
go run ./examples/chat/

Environment variables

Variable Default Description
EMBEDDER_API_KEY Required. API key for the embedder
EMBEDDER_BASE_URL https://api.openai.com Embedder API base URL
EMBEDDER_MODEL text-embedding-ada-002 Embedding model
LLM_API_KEY Required. API key for the LLM
LLM_BASE_URL https://api.openai.com LLM API base URL
LLM_MODEL gpt-4o-mini Language model

Local mode (Ollama)

# Start Ollama and pull the required models:
ollama pull nomic-embed-text
ollama pull llama3.2

EMBEDDER_BASE_URL=http://localhost:11434 \
EMBEDDER_API_KEY=ollama \
EMBEDDER_MODEL=nomic-embed-text \
LLM_BASE_URL=http://localhost:11434 \
LLM_API_KEY=ollama \
LLM_MODEL=llama3.2 \
go run ./examples/chat/

Example session

Indexing knowledge base...
Indexed 8 documents.

RAG chat ready. Enter your question (Ctrl+C to exit):
────────────────────────────────────────────────────────────

> How do I add a Zigbee device?

To add a Zigbee device, open the SmartHome application,
select "Add Device" -> "Zigbee" and put the device
into pairing mode [1]. The hub will detect it within 30 seconds [1].

Sources:
  [1] smarthome-zigbee (score=0.921)
────────────────────────────────────────────────────────────

Knowledge base

The example uses a built-in knowledge base about the SmartHome Hub product (8 documents). To use your own documents, replace the knowledgeBase slice in main.go.

Documentation

Overview

Базовый RAG-чат (CLI) — пример использования draftRAG.

Загружает набор документов в in-memory store, затем запускает интерактивный цикл вопрос-ответ с inline-цитатами.

Переменные окружения:

EMBEDDER_BASE_URL   — базовый URL embedder API (по умолчанию: https://api.openai.com)
EMBEDDER_API_KEY    — ключ API для embedder (обязательно)
EMBEDDER_MODEL      — модель embeddings (по умолчанию: text-embedding-ada-002)
LLM_BASE_URL        — базовый URL LLM API (по умолчанию: https://api.openai.com)
LLM_API_KEY         — ключ API для LLM (обязательно)
LLM_MODEL           — модель LLM (по умолчанию: gpt-4o-mini)

Ollama (локальный режим):

Установите EMBEDDER_BASE_URL=http://localhost:11434 и EMBEDDER_MODEL=nomic-embed-text,
LLM_BASE_URL=http://localhost:11434 и LLM_MODEL=llama3.2.

Запуск:

EMBEDDER_API_KEY=sk-... LLM_API_KEY=sk-... go run ./examples/chat/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL