feat(examples): add LangGraph multi-agent chat example (#293)#644
Open
NandishwarSingh wants to merge 1 commit into
Open
feat(examples): add LangGraph multi-agent chat example (#293)#644NandishwarSingh wants to merge 1 commit into
NandishwarSingh wants to merge 1 commit into
Conversation
Add `examples/langgraph-chat`, a Next.js app that renders OpenUI generative UI streamed from a multi-agent LangGraph graph. - Supervisor router dispatches to weather/finance/research specialists, each a streaming ReAct loop sharing the generated OpenUI system prompt. - `/api/chat` proxies a stateless run via `@langchain/langgraph-sdk`, forwarding native LangGraph SSE to `langGraphAdapter()` and filtering internal-node tokens. - README documents both local (`langgraphjs dev`) and LangGraph Cloud setups.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
examples/langgraph-chat— a Next.js app that renders OpenUI generative UI streamed from a multi-agent LangGraph graph. Resolves #293.Built in TypeScript, per the approach approved in the issue.
How it works
src/agent/graph.ts) — a supervisorrouterdispatches each message to aweather,finance, orresearchspecialist. Each specialist is a streaming ReAct loop that shares the generated OpenUI system prompt, so its output renders as generative UI (cards, tables, charts). Exposed vialanggraph.json, so it runs withlanggraphjs devlocally and deploys to LangGraph Platform unchanged.src/app/api/chat/route.ts) — opens a stateless run with@langchain/langgraph-sdkand forwards the native LangGraph SSE to the client. Normalizes the token event tomessagesforlangGraphAdapter()and drops the supervisor's internal routing tokens so only specialist output renders.src/app/page.tsx) —<FullScreen streamProtocol={langGraphAdapter()}>withlangGraphMessageFormat.toApi, mirroringexamples/openui-chat.langgraphjs dev→LANGGRAPH_API_URL=http://localhost:2024) and LangGraph Cloud (LANGGRAPH_ASSISTANT_ID+LANGSMITH_API_KEY) setups. Mock weather / stock / web-search tools mean it runs with no third-party keys.Notes
Verification
pnpm build(typecheck + compile) andpnpm lintpass.langgraphjs devregisters the graph; the stateless/runs/streamSSE contract was verified against a running server.