{% extends "base.html" %} {% block title %}Vaults & Documents - Talkpipe Vault{% endblock %} {% block content %} {# In folder mode the open "vault" is a folder's own index; the named-vault form below must not offer it as the vault to index into. #} {% set vault_path = "" if folder_mode else vault_path %} {# The retrieval filter belongs to one index, so the panel sits with what it applies to: the Folders box for the one open folder, the vault panel for a named vault. #} {% macro filter_panel(retrieval_filter) %}
Retrieval filter for this {{ retrieval_filter.kind }} (advanced) {% if retrieval_filter.error %} not compiling {% elif retrieval_filter.active %} active {% elif retrieval_filter.script %} saved, not enabled {% endif %}

A ChatterLang script that filters or transforms the results retrieved from the open {{ retrieval_filter.kind }} — {{ retrieval_filter.target }} — before they reach the Ask answer. It applies to this {{ retrieval_filter.kind }} only. The script is stored with its index and travels with it; whether it runs is decided here, on this machine.

{% if retrieval_filter.message %}
{{ retrieval_filter.message }}
{% endif %} {% if retrieval_filter.error %}
{{ retrieval_filter.error }}
{% endif %}
How to write a filter

Each retrieved result flows through your script one at a time; emit it to keep it, drop it to filter it, modify it to transform it. Every result is a dictionary shaped like:

{"doc_id": "…", "score": 0.87,
 "document": {"content": "…", "source": "…", "title": "…"}}

In lambdaFilter/lambda expressions the result is item, as everywhere in TalkPipe — item['document'], item['score'], item['doc_id']. (Because the result is a dictionary, TalkPipe also exposes its top-level keys as bare names, so document and score work too.) Starter recipes:

For the common case — is this text inside that field? — isIn and isNotIn say the same thing without an expression. Name the field with a dotted path (document.content, document.source) and the text to look for:

isIn/isNotIn match exactly, so they are case-sensitive, and the named field has to exist on every result — a result missing it makes the script fail, which means unfiltered results (or, with Strict checked, a failed question). Reach for lambdaFilter when the field may be absent (.get('source', '')), when the match should ignore case (.lower()), or when the test is anything more than containment.

Any registered ChatterLang segment works — including LLM transforms — but the script must be a single pipeline of segments: no INPUT FROM source, loops, or forks. When active, the filter runs on Ask retrieval for this vault (keyword and semantic streams are filtered independently, then merged) and can be applied on the search pages with their “Apply custom transform” checkbox.

{% endmacro %} {# Closed unless a named vault is open or one of its steps is pending: showing both modes at once confuses, so the advanced one takes a click. #}
Named vaults (advanced): index documents into a separate vault folder {% if confirm_vault_path %} {% endif %}
{% if vault_path and vault_source_folder %}
{% endif %} {% include "_dir_picker.html" %} {% endblock %}