AI and RAG
Language-model and retrieval nodes. See also the AI / LLM / RAG guide.
8 nodes. Right-click any node in the editor to read this documentation in the app.
AI / LLMโ
๐ฌ LLM Chatโ
id ai_llm_chat ยท AI / LLM ยท Python export: yes
Send a prompt to a large language model and output its reply. Providers: OpenAI, Anthropic Claude, Google Gemini, Ollama (local, no key) or any OpenAI-compatible server. Leave Model blank for the provider's default (Ollama: your first local model). API keys come from the project .env (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, OLLAMA_HOST, OPENAI_COMPATIBLE_BASE_URL/_API_KEY/_MODEL) โ never from the graph, and exported scripts read them from the environment too. Each run makes a real (possibly billed) API call.
Inputs
| Port | Type | Description |
|---|---|---|
prompt | str | The user prompt (overrides the Prompt field) โ e.g. from Prompt Template. Overrides the Prompt field when connected. |
system | str | System instructions (overrides the System field). Overrides the System field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
reply | str | The model's reply text. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Provider | select | openai | openai, anthropic, gemini, ollama, openai_compatible |
| Model (blank = default) | text | ||
| System | textarea | You are a helpful assistant. | |
| Prompt | textarea | ||
| Temperature | float | 0.2 | |
| Max output tokens (0 = default) | int | 0 |
๐งฉ Prompt Templateโ
id ai_prompt_template ยท AI / LLM ยท Python export: yes
Build a prompt from a template. {question} and {context} are filled from the matching inputs, and any other {name} from the keys of the 'values' dict input. Placeholders with no value are left as written, so literal braces (e.g. in code) are safe.
Inputs
| Port | Type | Description |
|---|---|---|
question | str | Fills {question} (overrides the Question field). Overrides the Question field when connected. |
context | str | Fills {context} โ e.g. from Format Context. |
values | dict | Optional dict: each key fills the {key} placeholder. |
Outputs
| Port | Type | Description |
|---|---|---|
prompt | str | The filled-in prompt. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Template | textarea | Answer the question using only the context beloโฆ | |
| Question | text |
AI / RAGโ
๐๏ธ Build Vector Indexโ
id ai_build_index ยท AI / RAG ยท Python export: yes
Index chunks for similarity search. tfidf (default) works offline with no key or download and matches on shared words; ollama / openai use embedding models that also match meaning (see Embed Text for the details); auto uses Ollama's nomic-embed-text when it is pulled, otherwise TF-IDF. The index is a plain dict, so it can be saved or exported like any other value.
Inputs
| Port | Type | Description |
|---|---|---|
chunks | list[dict] | list[str] | From Split Text (or a list of strings). |
Outputs
| Port | Type | Description |
|---|---|---|
index | VectorIndex | Dict: method, model, chunks, matrix (+ the TF-IDF vectorizer). |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Method | select | tfidf | tfidf, auto, ollama, openai |
| Model (blank = default) | text |
๐งฎ Embed Textโ
id ai_embed_text ยท AI / RAG ยท Python export: yes
Turn texts into vectors (one row per text, unit length) โ e.g. to cluster or plot them with the ML nodes. tfidf: offline, fitted on these texts. ollama: a local embedding model (default nomic-embed-text; run ollama pull nomic-embed-text). openai: text-embedding-3-small (needs OPENAI_API_KEY). auto: Ollama's model when it is pulled, otherwise TF-IDF.
Inputs
| Port | Type | Description |
|---|---|---|
texts | list[str] | list[dict] | Strings, or chunks/documents (their 'text' is used). |
Outputs
| Port | Type | Description |
|---|---|---|
embeddings | ndarray | Array of shape (n_texts, dimensions). |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Method | select | tfidf | tfidf, auto, ollama, openai |
| Model (blank = default) | text |
๐ Format Contextโ
id ai_format_context ยท AI / RAG ยท Python export: yes
Join retrieved chunks into one numbered context string for a prompt, optionally labelled with each chunk's source so the model can cite [1], [2]โฆ Stops adding chunks once the character limit is reached (0 = no limit).
Inputs
| Port | Type | Description |
|---|---|---|
hits | list[dict] | list[str] | From Retrieve. |
Outputs
| Port | Type | Description |
|---|---|---|
context | str | The formatted context text. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Label with sources | checkbox | true | |
| Max characters (0 = no limit) | int | 6000 |
๐ Load Documentsโ
id ai_load_documents ยท AI / RAG ยท Python export: yes
Read every text file in a folder that matches a glob pattern (comma-separate several, e.g. '**/.md, **/.txt'; ** searches subfolders). Relative folders are resolved from the EdgeWeave root, like other file nodes. Binary or non-UTF-8 files are skipped.
Inputs
| Port | Type | Description |
|---|---|---|
folder | str | Folder path (overrides the Folder field). Overrides the Folder field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
documents | list[dict] | One {'source', 'text'} dict per file (source = path relative to the folder). |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Folder | text | ||
| Pattern | text | **/*.md | |
| Max files | int | 200 |
๐ Retrieveโ
id ai_retrieve ยท AI / RAG ยท Python export: yes
Find the chunks most similar to a query (cosine similarity) โ the 'R' in RAG. Scores run from 0 (unrelated) to 1 (identical).
Inputs
| Port | Type | Description |
|---|---|---|
index | VectorIndex | From Build Vector Index. |
query | str | The question to search for (overrides the Query field). Overrides the Query field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
hits | list[dict] | Best-first {'rank', 'score', 'source', 'chunk', 'text'} dicts. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Query | text | ||
| Results | int | 4 |
โ๏ธ Split Textโ
id ai_split_text ยท AI / RAG ยท Python export: yes
Split documents into chunks small enough to retrieve and fit in a prompt. 'paragraphs' packs blank-line-separated paragraphs up to the chunk size; 'markdown_sections' starts a new chunk at every heading; 'characters' uses fixed windows. Overlap repeats the end of one chunk at the start of the next so sentences aren't lost at the seams.
Inputs
| Port | Type | Description |
|---|---|---|
documents | list[dict] | list[str] | str | From Load Documents, or plain strings. |
Outputs
| Port | Type | Description |
|---|---|---|
chunks | list[dict] | One {'source', 'chunk', 'text'} dict per chunk. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Split by | select | paragraphs | paragraphs, markdown_sections, characters |
| Chunk size (characters) | int | 800 | |
| Overlap (characters) | int | 100 |