feat(examples): replace langgraph-chat with deepagents-based langchain-chat#689
Open
christian-bromann wants to merge 1 commit into
Open
Conversation
…n-chat Rewrite the example agent on top of deepagents and stream OpenUI Lang to the browser via a custom transformer, so the UI no longer needs bespoke message/stream-protocol handling. The transformer is kept local to the example until the OpenUI team decides where it should live.
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
Updating the LangChain example to use stream transformer to simplify user code. I would love to see OpenUI maintain some of these primitives, e.g.
examples/langchain-chat/src/libas well as the stream transformer, in so users wouldn't need to maintain the code themselves. Ideally all the user needs to do to use LangChain with OpenUI is:Define an agent, e.g.:
Define the custom API endpoint in Next.js:
The stream transformer transforms the agent stream to be AGUI compatible so that in the frontend code, no LangChain specific adapter is needed.
Changes
examples/langgraph-chattoexamples/langchain-chat, swapping the hand-built supervisor graph for a singlecreateDeepAgentagent (src/agent/agent.ts) that loads the generated OpenUI system prompt viareadFileSync(the LangGraph dev server's tsx/CJS loader can't handlewith { type: "text" }import attributes).openUIStreamTransformer(src/agent/openui-transformer.ts) that consumes@langchain/protocolMessagesDataevents and emits AG-UI events on aStreamChannel.remote("openui")channel, with no namespace filtering so nestedmodel_request:*/tools:*messages are forwarded.src/lib/stream-openui.ts, a framework-agnostic helper that drives an agent-protocol-v2 run, subscribes tocustom:openui(no namespace/depth filter), unwraps the forwarded AG-UI events, and relays them as SSE — fully TSDoc-documented.Responseglue intocreateLangChainStreamResponse(src/lib/langchain-stream-response.ts) so OpenUI can later export it as a reusable helper; the route handler (src/app/api/chat/route.ts) is now a thin delegator.src/app/page.tsx) to use OpenUI's defaultapiUrladapter (removed the customprocessMessage/streamProtocolwiring) and dropped the localLANGSMITH_API_KEYread since this is a local demo (theapiKeyoption remains optional on the helpers).crypto.randomUUID()instead of importing fromnode:crypto.package.json(deepagents/langchain deps,devscript that runs the UI and LangGraph server together),README.md, and.env.exampleto match the new architecture; refreshedpnpm-lock.yaml.Test Plan
Describe how you validated this change.
Checklist