Skip to content

Commit 2758a02

Browse files
docs(prompt-template): align step-by-step with current spec assertions
- Drop "records initial count / asserts increase" wording from tests 2, 3, and 5 — the spec now asserts exact dynamic-handle counts via the dynamicHandlesLocator and the specific per-variable handles, not before/after comparisons (the count comparison was removed when waitForTimeout was dropped from the helper). - Fix External dependencies: api_utils.py lives under src/lfx/, the extractor uses Python's string.Formatter (not a regex), and the PromptComponent path now points at the real prompt.py location.
1 parent d8ef9e4 commit 2758a02

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

docs/core-components/prompt-template-component-regression.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,24 @@ Tests 2–6 use the helper `setPromptTemplate(page, value)` which:
4848
- Asserts exactly one node on the canvas (`react-flow__node` count === 1).
4949

5050
### 2. `variables in curly braces generate dynamic input handles`
51-
- Records the initial count of `handle-prompt template` testids.
5251
- Calls `setPromptTemplate` with `Hello {name}, your job is {profession}.`.
53-
- Asserts the new handle count is strictly greater than the initial count.
5452
- Asserts both `handle-prompt template-shownode-name-left` and `handle-prompt template-shownode-profession-left` are visible.
53+
- Asserts the dynamic-handle locator (`-shownode-*-left` only) has count exactly 2 — sanity check that no extra handles leaked in.
5554

5655
### 3. `removing a variable removes its input handle`
57-
- Sets the template to `Hello {name}!` and asserts the `name` handle is visible.
58-
- Records the current handle count.
59-
- Sets the template to `Hello world!` and asserts the `name` handle has zero matches.
60-
- Asserts the new handle count is strictly less than the recorded count.
56+
- Sets the template to `Hello {name}!` and asserts the `name` handle is visible and the dynamic-handle count is exactly 1.
57+
- Sets the template to `Hello world!`.
58+
- Asserts the `name` handle has zero matches and the dynamic-handle count is exactly 0.
6159

6260
### 4. `replacing a variable updates handles accordingly`
6361
- Sets the template to `Hello {name}, you are {role}.` and asserts both `name` and `role` handles are visible.
6462
- Sets the template to `Hello {name}, you are {title}.`.
6563
- Asserts `name` is still visible, `role` has zero matches, and `title` is visible.
6664

6765
### 5. `clearing the template removes all dynamic handles`
68-
- Sets the template to `{a} and {b} and {c}` and asserts the count of left-side dynamic handles is > 0.
66+
- Sets the template to `{a} and {b} and {c}` and asserts the dynamic-handle count is exactly 3.
6967
- Sets the template to `No variables here.`.
70-
- Asserts the count of left-side dynamic handles equals 0.
68+
- Asserts the dynamic-handle count is exactly 0.
7169

7270
### 6. `modal edits persist in UI and in saved flow`
7371
- Sets the template to `Persisted prompt text {topic}.` via `setPromptTemplate`.
@@ -93,9 +91,10 @@ Tests 2–6 use the helper `setPromptTemplate(page, value)` which:
9391

9492
- `src/frontend/src/modals/promptModal/``genericModalBtnSave` button, `edit-prompt-sanitized` preview, and the textarea that holds the editable template; changes here break tests 2–6
9593
- `src/frontend/src/CustomNodes/GenericNode/components/parameterRenderComponent/components/promptAreaComponent/``button_open_prompt_modal` trigger on the node inspector; breaks tests 2–6
96-
- `src/backend/base/langflow/base/prompts/api_utils.py``extract_input_variables_from_prompt()` regex that derives the variable list from the template string; breaks tests 2–5
94+
- `src/lfx/src/lfx/interface/utils.py``extract_input_variables_from_prompt()`: derives the variable list from the template string using Python's `string.Formatter().parse()` (not a regex); breaks tests 2–5
95+
- `src/lfx/src/lfx/base/prompts/api_utils.py``validate_prompt()` and `_check_input_variables()`: validation layer around the extracted variables; breaks tests 2–5
96+
- `src/lfx/src/lfx/components/models_and_agents/prompt.py``PromptComponent` definition (`display_name="Prompt Template"`, template field) and `update_build_config()` that synchronizes template ↔ input fields; breaks tests 2–6 and the backend assertion in test 6
9797
- `src/frontend/src/CustomNodes/GenericNode/` — dynamic handle rendering for `handle-{component}-shownode-{var}-left`; breaks tests 1–5
98-
- `src/backend/base/langflow/base/prompts/``PromptComponent` template-to-input-fields synchronization; breaks tests 2–5
9998
- `GET /api/v1/flows/{id}` — flow read endpoint backing the autosave round-trip; the response shape `data.nodes[].data.node.template.template.value` is what test 6 asserts. A rename of the inner `template.template` nesting, or a change to `node.data.type` away from `"Prompt Template"`, breaks the backend assertion.
10099

101100
---

0 commit comments

Comments
 (0)