Skip to content

Commit 10d9c2e

Browse files
committed
fix(business-anchor): skip filtering grouped prompts
1 parent 6b55ce6 commit 10d9c2e

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed
96 Bytes
Binary file not shown.

api/nodes/new_pipeline/business_anchor_guard.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ def BusinessAnchorGuard(prompts, keyphrases: list[str]):
66
Keep prompts that mention at least one scraped key-phrase.
77
If no key-phrases were extracted, return an empty list.
88
"""
9+
# Skip anchoring for grouped prompts (dict input)
10+
if isinstance(prompts, dict):
11+
logging.getLogger(__name__).info(
12+
"BusinessAnchorGuard: grouped prompts detected, skipping filter")
13+
return prompts
914
if not keyphrases:
10-
# No keyphrases: do not filter; return original prompts
15+
# No keyphrases: return original prompts
1116
return prompts
12-
# If grouped dict, apply per category
13-
if isinstance(prompts, dict):
14-
return {cat: BusinessAnchorGuard(items, keyphrases) for cat, items in prompts.items()}
1517

1618
lowered_phrases = [kp.lower() for kp in keyphrases]
1719
anchored = [

api/nodes/new_pipeline/deduplicate_node.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
from api.nodes.fetch_summary_node import Node
22

33
@Node(retries=1)
4-
def DeduplicateNode(prompts: list[str]) -> list[str]:
4+
def DeduplicateNode(prompts):
5+
"""
6+
Remove duplicate prompts based on cosine similarity (>85%).
7+
Accepts either a list of prompts or a dict mapping categories to lists.
8+
Returns deduplicated list or dict of deduplicated lists.
9+
"""
10+
# If grouped dict, apply dedupe per category
11+
if isinstance(prompts, dict):
12+
return {cat: DeduplicateNode(items) for cat, items in prompts.items()}
513
"""
614
Remove duplicate prompts based on cosine similarity (>85%).
715
Returns a list of unique prompts.

pytest-of-arthurlee/pytest-current

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/Users/arthurlee/src/prompt-bootstrapper/pytest-of-arthurlee/pytest-8
1+
/Users/arthurlee/src/prompt-bootstrapper/pytest-of-arthurlee/pytest-15

tests/test_business_anchor_guard.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def test_business_anchor_case_insensitive():
2525
def test_business_anchor_no_phrases():
2626
prompts = ["Some prompt"]
2727
result = BusinessAnchorGuard(prompts, [])
28-
assert result == []
28+
# No keyphrases: prompts should pass through unchanged
29+
assert result == prompts
2930

3031
def test_business_anchor_empty_prompts():
3132
result = BusinessAnchorGuard([], ["term"])

0 commit comments

Comments
 (0)