llama-index-postprocessor-needlepath 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: llama-index-postprocessor-needlepath
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: llama-index postprocessor needlepath context selection integration
5
5
  Project-URL: Homepage, https://nextmoca.com
6
6
  Author: Next Moca Global, Inc.
@@ -8,7 +8,7 @@ License-Expression: Apache-2.0
8
8
  License-File: LICENSE
9
9
  Requires-Python: <4.0,>=3.10
10
10
  Requires-Dist: llama-index-core<0.15,>=0.13.0
11
- Requires-Dist: needlepath<1.0.0,>=0.1.0
11
+ Requires-Dist: needlepath<1.0.0,>=0.2.3
12
12
  Provides-Extra: dev
13
13
  Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
14
14
  Requires-Dist: pytest>=7; extra == 'dev'
@@ -8,8 +8,8 @@ evaluated.
8
8
 
9
9
  What it does: given the retrieved nodes and the query, keep the nodes that carry
10
10
  the answer and replace each one's text with the part of it that does. What it
11
- never does: raise, or return fewer nodes than it was given when anything at all
12
- went wrong.
11
+ does on ordinary selection failure: return the original nodes. Mandatory
12
+ guardrail failures raise instead, so unfiltered nodes cannot reach the model.
13
13
 
14
14
  Two LlamaIndex-specific decisions worth reading before you deploy it:
15
15
 
@@ -39,6 +39,7 @@ from needlepath import (
39
39
  AsyncNeedlepathClient,
40
40
  ContextRecord,
41
41
  NeedlepathClient,
42
+ NeedlepathGuardrailError,
42
43
  Reason,
43
44
  RecordKind,
44
45
  SelectionResult,
@@ -172,8 +173,11 @@ class NeedlepathPostprocessor(BaseNodePostprocessor):
172
173
  shadow=True if self.shadow else None,
173
174
  )
174
175
  return self._apply(nodes, plan, result)
176
+ except NeedlepathGuardrailError:
177
+ # Mandatory protection failures must stop the framework call.
178
+ raise
175
179
  except Exception: # noqa: BLE001 - see the class docstring's fail-open rule
176
- # The core client never raises, so this catches OUR OWN defects — a
180
+ # Guardrail errors propagate above. This catches ordinary defects — a
177
181
  # node type nobody anticipated, an index slip, a framework minor that
178
182
  # changed a field's type. A postprocessor that raises fails the whole
179
183
  # query engine; returning the caller's nodes is byte-identical to not
@@ -195,6 +199,9 @@ class NeedlepathPostprocessor(BaseNodePostprocessor):
195
199
  """
196
200
  try:
197
201
  return await self._apostprocess(nodes, query_bundle)
202
+ except NeedlepathGuardrailError:
203
+ # Mandatory protection failures must stop the framework call.
204
+ raise
198
205
  except Exception: # noqa: BLE001 - see `_postprocess_nodes`
199
206
  self._note(Reason.UNEXPECTED_ERROR)
200
207
  return nodes
@@ -285,9 +292,20 @@ class NeedlepathPostprocessor(BaseNodePostprocessor):
285
292
  ) -> list[NodeWithScore]:
286
293
  self._stats.record(result)
287
294
  # `self.shadow` is belt and braces — the core client already declines a
288
- # shadow result — enforced here, at the point of mutation.
289
- if not result.applied or self.shadow or result.response is None:
295
+ # shadow result — enforced here, at the point of mutation. A blocked
296
+ # verdict is the one delivery shadow does not suppress: shadow never
297
+ # restores withheld nodes.
298
+ blocked = result.reason == Reason.BLOCKED
299
+ if not result.applied or result.response is None or (self.shadow and not blocked):
290
300
  return nodes
301
+ if blocked:
302
+ # Workspace policy withheld every record. The verdict is "deliver
303
+ # nothing", and it is installed as exactly that: the query engine
304
+ # gets no context from these nodes rather than the nodes
305
+ # themselves. This is the one applied result with nothing to
306
+ # show for it, which is why it is checked before the empty-`kept`
307
+ # guard below turns it back into a passthrough.
308
+ return []
291
309
 
292
310
  index_by_id: dict[str, int] = plan["index_by_id"]
293
311
  # (input index, node) pairs. The index is carried explicitly rather than
@@ -1,3 +1,3 @@
1
- __version__ = "0.1.1"
1
+ __version__ = "0.1.2"
2
2
 
3
3
  __all__ = ["__version__"]
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "llama-index-postprocessor-needlepath"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "llama-index postprocessor needlepath context selection integration"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10,<4.0"
@@ -17,7 +17,7 @@ license = "Apache-2.0"
17
17
  # `llama-index-postprocessor-*` is not discoverable at all.
18
18
  dependencies = [
19
19
  "llama-index-core>=0.13.0,<0.15",
20
- "needlepath>=0.1.0,<1.0.0",
20
+ "needlepath>=0.2.3,<1.0.0",
21
21
  ]
22
22
 
23
23
  [project.optional-dependencies]