Skip to content

Commit ce00b4c

Browse files
committed
Added LangGraph
1 parent 6b20725 commit ce00b4c

File tree

9 files changed

+4140
-39
lines changed

9 files changed

+4140
-39
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
# OpenReason
2+
13
![OpenReason](https://img.shields.io/npm/v/openreason)
24
![License](https://img.shields.io/badge/license-Apache--2.0-blue)
35

4-
# OpenReason
5-
66
OpenReason is a reasoning engine that sits on top of any LLM provider.
77
You control the provider, models, and configuration through a single call: `openreason.init()`.
88

@@ -38,6 +38,7 @@ It handles math, logic, philosophy, ethics, and general reasoning without hiding
3838
- [18. Troubleshooting](#18-troubleshooting)
3939
- [19. FAQ](#19-faq)
4040
- [20. Roadmap](#20-roadmap)
41+
- [21. LangGraph mode](#21-langgraph-mode)
4142

4243
</details>
4344

@@ -182,6 +183,12 @@ openreason.init({
182183
compliance: 0.3,
183184
reflection: 0.2,
184185
},
186+
187+
graph: {
188+
enabled: true, // route through LangGraph orchestration
189+
checkpoint: false,
190+
threadPrefix: "bench", // optional namespace for checkpointer
191+
},
185192
});
186193
```
187194

@@ -190,6 +197,7 @@ Notes:
190197
- You don’t need .env files
191198
- You can mix providers
192199
- You can switch models without changing any code
200+
- Enable `graph.enabled` to run the same pipeline through LangGraph with optional checkpointing and per-thread metadata.
193201

194202
---
195203

@@ -542,6 +550,34 @@ Yes. Look inside `public/prompt.json`.
542550

543551
---
544552

553+
# 21. LangGraph mode
554+
555+
OpenReason can run the exact same classifier → skeleton → solver → verifier → finalizer flow through a LangGraph `StateGraph`. This mode is optional and opt-in via `graph.enabled`.
556+
557+
```ts
558+
openreason.init({
559+
provider: "openai",
560+
apiKey: process.env.OPENAI_API_KEY!,
561+
model: "gpt-4o",
562+
graph: {
563+
enabled: true,
564+
checkpoint: true, // uses MemorySaver from @langchain/langgraph-checkpoint
565+
threadPrefix: "demo", // helps group runs when checkpointing is on
566+
},
567+
});
568+
```
569+
570+
What changes:
571+
572+
- Nodes mirror the standard pipeline (classify, cache, quick reflex, structure, solve, evaluate) but execute as a compiled LangGraph.
573+
- When `checkpoint` is true, the built-in `MemorySaver` tracks progress per `threadPrefix`, letting you resume or inspect state.
574+
- If anything fails or graph execution is disabled, OpenReason falls back to the linear pipeline automatically.
575+
- All existing telemetry (memory cache, prompt evolution, verification metadata) remains intact, so no code changes are required when toggling the mode.
576+
577+
Use this when you want more explicit control over graph execution, need checkpointing, or plan to extend the LangGraph with additional nodes.
578+
579+
---
580+
545581
# License
546582

547583
Apache-2.0

0 commit comments

Comments
 (0)