graphsight-langgraph 0.1.4__tar.gz → 0.3.0__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.
Files changed (21) hide show
  1. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/LICENSE +21 -21
  2. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/PKG-INFO +38 -10
  3. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/README.md +259 -231
  4. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph/__init__.py +34 -30
  5. graphsight_langgraph-0.3.0/graphsight_langgraph/_text.py +17 -0
  6. graphsight_langgraph-0.3.0/graphsight_langgraph/capture.py +43 -0
  7. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph/github_ingest.py +310 -309
  8. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph/mapper.py +158 -139
  9. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph/schema.py +79 -76
  10. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph/tracer.py +271 -242
  11. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph.egg-info/PKG-INFO +38 -10
  12. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph.egg-info/SOURCES.txt +6 -1
  13. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/pyproject.toml +41 -41
  14. graphsight_langgraph-0.3.0/tests/test_capture.py +32 -0
  15. graphsight_langgraph-0.3.0/tests/test_mapper.py +81 -0
  16. graphsight_langgraph-0.3.0/tests/test_tracer.py +138 -0
  17. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph.egg-info/dependency_links.txt +0 -0
  18. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph.egg-info/entry_points.txt +0 -0
  19. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph.egg-info/requires.txt +0 -0
  20. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/graphsight_langgraph.egg-info/top_level.txt +0 -0
  21. {graphsight_langgraph-0.1.4 → graphsight_langgraph-0.3.0}/setup.cfg +0 -0
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Arush Karnatak
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arush Karnatak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graphsight-langgraph
3
- Version: 0.1.4
3
+ Version: 0.3.0
4
4
  Summary: X-ray for LangGraph retrieval: one callback handler captures every retriever call, score, and relational path — rendered as an interactive graph.
5
5
  Author: Arush Karnatak
6
6
  License: MIT
@@ -64,8 +64,8 @@ pip install graphsight # the local viewer (recommended)
64
64
  | Python | ≥ 3.10 |
65
65
  | `langchain-core` | ≥ 0.3 (verified against 1.5.0) |
66
66
  | `langgraph` | any recent version; only needed for the `[example]` extra |
67
- | Sync (`invoke` / `stream`) | verified |
68
- | Async (`ainvoke` / `astream`) | same callback events; not yet covered by the verification run |
67
+ | Sync (`invoke` / `stream`) | verified, covered by the test suite |
68
+ | Async (`ainvoke` / `astream`) | verified, covered by the test suite |
69
69
 
70
70
  ## Quickstart: trace a GitHub repo in 60 seconds
71
71
 
@@ -114,15 +114,38 @@ which this deliberately simple demo does not pretend to do.
114
114
  The complete integration:
115
115
 
116
116
  ```python
117
- from graphsight_langgraph import LangGraphTracer, to_tracestate
117
+ from graphsight_langgraph import LangGraphTracer, capture
118
118
 
119
119
  tracer = LangGraphTracer()
120
120
  result = graph.invoke(inputs, config={"callbacks": [tracer]})
121
121
 
122
- trace = tracer.finish(query="why is checkout failing?", answer=result["answer"])
123
- to_tracestate(trace) # viewer-ready dict — json.dump it, then: graphsight trace.json
122
+ capture(tracer, query="why is checkout failing?", answer=result["answer"])
123
+ # -> .graphsight/20260725T071558_why-is-checkout-failing.json
124
124
  ```
125
125
 
126
+ `capture()` finishes the trace and appends it to a local history directory
127
+ (`./.graphsight/` by default, `$GRAPHSIGHT_DIR` to override) — browse every
128
+ run with `graphsight .graphsight/`. For manual control use
129
+ `tracer.finish()` + `to_tracestate()` / `save_trace()`; `trace.to_dict()`
130
+ gives the framework-neutral `AgentTrace` for your own tooling.
131
+
132
+ ### Retrieved vs. used
133
+
134
+ When you pass `answer=`, each retrieved item gets an `answer_overlap`
135
+ score — the lexical overlap between the item's content and the final
136
+ answer. In the viewer, items that surfaced in the answer render
137
+ highlighted; items retrieved but unused render dimmed with the label
138
+ *"retrieved, unused."* That splits the two classic retrieval failures at a
139
+ glance:
140
+
141
+ - **right doc retrieved, ignored by the model** → dimmed node with a high
142
+ retrieval score
143
+ - **wrong doc trusted** → highlighted node that shouldn't be
144
+
145
+ The overlap is a lexical heuristic (labeled as such, threshold 0.2) — it is
146
+ never presented as a model-computed relevance judgment. No `answer=` → no
147
+ usage claims; everything renders plain.
148
+
126
149
  ### Configuration propagation (read this once)
127
150
 
128
151
  LangChain only propagates callbacks into runnables that receive the run's
@@ -144,7 +167,9 @@ retrievals.
144
167
  | Name | Description |
145
168
  |---|---|
146
169
  | `LangGraphTracer()` | `BaseCallbackHandler` subclass. Pass via `config={"callbacks": [tracer]}` to `invoke` / `stream`. Reusable within a single run; create a fresh instance per run. |
147
- | `tracer.finish(query=None, answer=None) -> AgentTrace` | Assembles the trace after the run: closes dangling spans, computes total latency. `query` falls back to the first retriever query seen. |
170
+ | `tracer.finish(query=None, answer=None) -> AgentTrace` | Assembles the trace after the run: closes dangling spans, computes total latency and per-item `answer_overlap`. `query` falls back to the first retriever query seen. |
171
+ | `capture(tracer, query=None, answer=None, dir=None) -> Path` | `finish()` + save to the history directory in one call. |
172
+ | `save_trace(trace, dir=None) -> Path` | Writes a finished trace to the history directory (`./.graphsight/` or `$GRAPHSIGHT_DIR`). |
148
173
  | `to_tracestate(trace) -> dict` | Maps an `AgentTrace` to the viewer's JSON contract. Serialize with `json.dump`. |
149
174
  | `trace.to_dict() -> dict` | The framework-neutral `AgentTrace` (schema v0.1) for your own tooling. |
150
175
  | `AgentTrace`, `Span`, `Retrieval`, `RetrievedItem`, `TraceEdge` | Plain dataclasses defining the schema; importable for custom emitters. |
@@ -160,6 +185,7 @@ retrievals.
160
185
  | `Document.metadata["edges"]` | relational edges, deduplicated per retrieval |
161
186
  | LLM / tool calls | plain spans in the execution timeline |
162
187
  | Edges present in a retrieval | `arm = "graph"`, else `"vector"` — detected automatically |
188
+ | The final answer (when passed to `finish`/`capture`) | per-item `answer_overlap` — the retrieved-vs-used signal |
163
189
 
164
190
  ### Making your retriever graph-aware
165
191
 
@@ -198,14 +224,15 @@ else renders as `Document`).
198
224
  retriever and were not recomputed — an imported trace never masquerades
199
225
  as an engine-computed one.
200
226
 
201
- ## Schema (v0.1)
227
+ ## Schema (v0.2)
202
228
 
203
229
  `AgentTrace` is the stable contract. Future adapters (LlamaIndex, raw
204
- OpenTelemetry) emit the same shape and render in the same viewer.
230
+ OpenTelemetry) emit the same shape and render in the same viewer. v0.2 adds
231
+ `RetrievedItem.answer_overlap` (additive — v0.1 traces stay valid).
205
232
 
206
233
  ```jsonc
207
234
  {
208
- "schema_version": "0.1",
235
+ "schema_version": "0.2",
209
236
  "framework": "langgraph",
210
237
  "query": "…",
211
238
  "spans": [
@@ -219,6 +246,7 @@ OpenTelemetry) emit the same shape and render in the same viewer.
219
246
  "items": [
220
247
  { "id": "pr_4821", "label": "PR #4821", "kind": "pull_request",
221
248
  "score": 0.94, "vector_score": null, "graph_score": null,
249
+ "answer_overlap": 0.41, // null when no answer given
222
250
  "content": "…", "source_uri": "https://…", "metadata": {} }
223
251
  ],
224
252
  "edges": [ // optional — the relational view