Skip to main content

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

PortTypeDescription
promptstrThe user prompt (overrides the Prompt field) โ€” e.g. from Prompt Template. Overrides the Prompt field when connected.
systemstrSystem instructions (overrides the System field). Overrides the System field when connected.

Outputs

PortTypeDescription
replystrThe model's reply text.

Fields

FieldTypeDefaultChoices
Providerselectopenaiopenai, anthropic, gemini, ollama, openai_compatible
Model (blank = default)text
SystemtextareaYou are a helpful assistant.
Prompttextarea
Temperaturefloat0.2
Max output tokens (0 = default)int0

๐Ÿงฉ 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

PortTypeDescription
questionstrFills {question} (overrides the Question field). Overrides the Question field when connected.
contextstrFills {context} โ€” e.g. from Format Context.
valuesdictOptional dict: each key fills the {key} placeholder.

Outputs

PortTypeDescription
promptstrThe filled-in prompt.

Fields

FieldTypeDefaultChoices
TemplatetextareaAnswer the question using only the context beloโ€ฆ
Questiontext

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

PortTypeDescription
chunkslist[dict] | list[str]From Split Text (or a list of strings).

Outputs

PortTypeDescription
indexVectorIndexDict: method, model, chunks, matrix (+ the TF-IDF vectorizer).

Fields

FieldTypeDefaultChoices
Methodselecttfidftfidf, 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

PortTypeDescription
textslist[str] | list[dict]Strings, or chunks/documents (their 'text' is used).

Outputs

PortTypeDescription
embeddingsndarrayArray of shape (n_texts, dimensions).

Fields

FieldTypeDefaultChoices
Methodselecttfidftfidf, 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

PortTypeDescription
hitslist[dict] | list[str]From Retrieve.

Outputs

PortTypeDescription
contextstrThe formatted context text.

Fields

FieldTypeDefaultChoices
Label with sourcescheckboxtrue
Max characters (0 = no limit)int6000

๐Ÿ“š 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

PortTypeDescription
folderstrFolder path (overrides the Folder field). Overrides the Folder field when connected.

Outputs

PortTypeDescription
documentslist[dict]One {'source', 'text'} dict per file (source = path relative to the folder).

Fields

FieldTypeDefaultChoices
Foldertext
Patterntext**/*.md
Max filesint200

๐Ÿ”Ž 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

PortTypeDescription
indexVectorIndexFrom Build Vector Index.
querystrThe question to search for (overrides the Query field). Overrides the Query field when connected.

Outputs

PortTypeDescription
hitslist[dict]Best-first {'rank', 'score', 'source', 'chunk', 'text'} dicts.

Fields

FieldTypeDefaultChoices
Querytext
Resultsint4

โœ‚๏ธ 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

PortTypeDescription
documentslist[dict] | list[str] | strFrom Load Documents, or plain strings.

Outputs

PortTypeDescription
chunkslist[dict]One {'source', 'chunk', 'text'} dict per chunk.

Fields

FieldTypeDefaultChoices
Split byselectparagraphsparagraphs, markdown_sections, characters
Chunk size (characters)int800
Overlap (characters)int100