Skip to main content

AI / LLM and RAG nodes

Call large language models from a graph and build retrieval-augmented generation (RAG) pipelines — answering questions from your own documents. Source: backend/core/nodes/ai/ai_nodes.py. Demo: projects/demo_project/ai/rag_demo.weave.

Load Documents ─▶ Split Text ─▶ Build Vector Index ─▶ Retrieve ─▶ Format Context ─┐
▲ ▼
question ───────────▶ Prompt Template ─▶ LLM Chat

Nodes​

NodeCategoryWhat it does
LLM ChatAI / LLMSends a prompt (+ optional system text) to OpenAI, Anthropic Claude, Google Gemini, Ollama or an OpenAI-compatible server; outputs the reply. Model blank = the provider's default.
Prompt TemplateAI / LLMFills {question}, {context} and any {key} from a values dict. Unknown placeholders are left as written.
Load DocumentsAI / RAGReads text files in a folder matching a glob (**/*.md, **/*.txt).
Split TextAI / RAGChunks documents by paragraphs, markdown sections or fixed character windows, with overlap.
Embed TextAI / RAGTexts → an (n, d) array of unit vectors (for clustering / plotting with the ML nodes).
Build Vector IndexAI / RAGIndexes chunks for similarity search; a plain dict (method, model, chunks, matrix, vectorizer).
RetrieveAI / RAGTop-k chunks for a query by cosine similarity.
Format ContextAI / RAGNumbers and labels retrieved chunks ([1] source) into one context string, up to a character limit.

Providers and keys​

LLM Chat uses the same providers and .env keys as the chat assistant: OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, OLLAMA_HOST (optional) and OPENAI_COMPATIBLE_BASE_URL / _API_KEY / _MODEL. Keys are never stored in the graph, and exported scripts read them from the environment (or a .env found from the working directory). Every run of an LLM Chat node is a real, possibly billed, API call.

The node uses a small self-contained client rather than the chat panel's provider classes because exported scripts must run without EdgeWeave; the environment variables and default models are the same.

Embedding methods​

MethodNeedsMatches on
tfidf (default)nothing — scikit-learn, offline, deterministicshared words
ollamaOllama running + ollama pull nomic-embed-text (~270 MB)meaning
openaiOPENAI_API_KEY (text-embedding-3-small)meaning
auto—Ollama's nomic-embed-text if it is pulled, otherwise TF-IDF

Chat-only Ollama models (e.g. gemma3) can't produce embeddings; the node says so and suggests an embedding model.

Python export​

Every node exports: the same ai_* functions that run in the app are copied into the script, so export and runtime can't drift. Relative folders in Load Documents resolve from the working directory when the script runs (in the app they also fall back to the EdgeWeave root and the active project).

While building this family we fixed an exporter bug: {tokens} in a node's expr were filled by chained str.replace, so a field value that itself contained {name} text (a Prompt Template's {context}) was rewritten by a later substitution. PythonGenerator._expand_expr now substitutes all tokens in a single pass.