当前位置: 首页 > news >正文

langgraphjs-gen-ui-examples

langgraphjs-gen-ui-examples

https://github.com/langchain-ai/langgraphjs-gen-ui-examples

LangGraph Generative UI Examples

This repository contains a series of agents intended to be used with the Agent Chat UI (repo).

Generative UI Example

 

https://deepwiki.com/langchain-ai/langgraphjs-gen-ui-examples

 

图片

 

Agents

Key

  • Supervisor
    • Stockbroker
    • Trip Planner
    • Open Code
    • Order Pizza
  • Chat Agent
  • Email Agent

Supervisor

This is the default agent, which has access to a series of subgraphs it can call, depending on the context of the conversation. This includes the following agents:

  • Stockbroker
  • Trip Planner
  • Open Code
  • Order Pizza

This agent works by taking in the input, and passing it, along with the rest of the chat history to a router node. This node passes the entire chat history to Gemini 2.0 Flash, and forces it to call a tool, with the route to take based on the conversation.

If the context does not have a clear subgraph which should be called, it routes to the General Input node, which contains a single LLM call used to respond to the user's input.

Stockbroker

The stockbroker agent has a series of tools available to it which will render generative UI components in the Agent Chat UI. It should be accessed via the agent graph ID, which means you'll need to go through the Supervisor agent to access it. The following are the prompts you can use to test the stockbroker agent:

  • What's the current price of <insert company/stock ticker here> - Will trigger a generative UI stockbroker agent which renders the current price of the stock.
  • I want to buy <insert quantity here> shares of <insert company/stock ticker here>. - Will trigger a generative UI stockbroker agent which renders a UI to buy a stock at its current price.
  • Show me my portfolio - Will trigger a generative UI stockbroker agent which renders a UI to show the user's portfolio.

Trip Planner

The trip planner agent has tools available to it which can render generative UI components for planning/booking trips. It should be accessed via the agent graph ID, which means you'll need to go through the Supervisor agent to access it. The following prompts will trigger the trip planner agent:

  • Show me places to stay in <insert location here> - Will trigger a generative UI travel agent which renders a UI to select accommodations.
  • Recommend some restaurants for me in <insert location here> - Will trigger a generative UI travel agent which renders a UI to select restaurants.

The agent will first extract the following information from your input, if present:

  • location - Required field. This can be the city, state, or some other location for the trip.
  • startDate - Optional field. The start date of the trip. Defaults to 4 weeks from now.
  • endDate - Optional field. The end date of the trip. Defaults to 5 weeks from now.
  • numberOfGuests - Optional field. The number of guests attending the trip. Defaults to 2.

The only field, location, is required, and the rest are optional.

Open Code

This is a dummy code writing agent, used to demonstrate how you can implement generative UI components in agents. It should be accessed via the agent graph ID, which means you'll need to go through the Supervisor agent to access it. It is triggered by requesting the agent to write a React TODO app, like this:

  • Write a React TODO app for me

This will then render a plan (these steps are static, and will always be the same). After that, it'll "generate" code (each plan item has a corresponding "generated code output") for each item in the plan. It only does this one at a time, and will not suggest the next part of generated code until after the previous suggestion has been accepted, rejected, or accepted for all future requests in this session. If you select that button, it will resume the graph, and continue through the rest of the steps, and suggest code without pausing to wait for your approval.

Order Pizza

The order pizza agent is used to demonstrate how tool calls/results are rendered in the UI. It should be accessed via the agent graph ID, which means you'll need to go through the Supervisor agent to access it. You can trigger it via the following query:

  • Order me a pizza <include optional topping instructions> in <include location here>

It will then call two tools, once to extract the fields from your input for the pizza order (order details, and location). After that, it calls the tool to "order" the pizza. Each of these tool calls will have corresponding tool call/result UI components rendered in the Agent Chat UI. These are the default UI components rendered when your graph calls a tool/returns a tool result.

Chat Agent

The chat agent is a single LLM call, used to demonstrate the plain back and forth of a chat agent. It should be accessed via the chat graph ID. It does not have access to any tools, or generative UI components.

Email Agent

The email agent is a dummy implementation of how you'd implement an email assistant with the Agent Chat UI. It is accessed via the email_agent graph ID. You can trigger it via the following query:

  • Write me an email to <insert email here> about <insert email description here>

This will then call the graph which extracts fields from your input (or responds with a request for more information). Once it's extracted all of the required information it will interrupt, passing the standardized HumanInterrupt schema. The Agent Chat UI is able to detect when interrupts with this schema are thrown, and when it finds one it renders a UI component to handle actions by the user which are used to resume the graph.

The allowed actions are:

  • Accept - If you accept the email as is, without making changes to any fields, it will "send" the email (emails aren't actually sent, just a message is displayed indicating the email was sent).
  • Edit - If you edit any of the email fields and submit, it will "send" the email with the new values.
  • Respond - If you send a text response back, it will be used to rewrite the email in some way, then interrupt again and wait for you to take an action.
  • Ignore - This will send back an ignore response, and the graph will end without taking any actions.
  • Mark as resolved - If you select this, it will resume the graph, but starting at the __end__ node, causing the graph to end without taking any actions.

Writer Agent

This is a dummy agent used to demonstrate how you can stream generative UI components as an artifact. It should be accessed via the writer graph ID. It should be accessed via the agent graph ID, which means you'll need to go through the Supervisor agent to access it. The following prompts will trigger the writer agent:

  • Write me a short story about a <insert topic here>

This will render a generative UI component that contains the title and content of your short story. The generative UI component will be rendered in a side panel to the right of the chat and the contents of the story will be streamed to the UI as it is generated.

 

http://www.jsqmd.com/news/5513/

相关文章:

  • win 系统安装
  • 2025 年节能咨询公司最新权威推荐排行榜:覆盖工业 / 建筑 / 数据中心等领域 TOP5 优质企业综合测评与选型指南发电厂/燃气/全域增效/服务器节能公司推荐
  • 微算法科技(NASDAQ MLGO)探索全同态加密与安全多方计算融合,开启区块链隐私执行新时代
  • 国产SUB-1G芯片DP4363F支持119-1050mhz超低功耗 - 动能世纪
  • 2025 年棕刚玉源头厂家最新推荐排行榜:TOP 级生产厂家原料与烧结工艺权威解析,助力企业精准选购一级棕刚玉/棕刚玉磨料/优质棕刚玉/棕刚玉喷砂废料回收厂家推荐
  • 杀疯了!GitHub 发布 Copilot CLI!!!
  • 2025 年无尘金刚砂源头厂家最新推荐排行榜:权威精选企业产能与品质深度解析无尘金刚砂材料/无尘金刚砂批发/无尘金刚砂喷砂厂家推荐
  • PySide6 之简易音乐播放器
  • langgraph-genui
  • web服务器配置步骤有哪些?如何建立一个web服务器
  • 题解:P10005 [集训队互测 2023] 基础寄术练习题
  • 详细介绍:Linux----gcc、g++的使用以及一些问题
  • 同步和互斥的基本概念
  • Sep 28
  • 图像采集卡:连接镜头与机器的“视觉神经”,释放工业智能核心动力
  • 2025 年生态木厂商最新推荐榜单:TOP 前五企业实力解析及厂商选择指南生态木方通/户外地板/装饰线条/隔断/背景墙厂商推荐
  • 盲盒一番赏小应用用户需求分析:从行为动机到功能诉求的深度拆解
  • C++ IO 库全方位解析:从基础到实战 - 指南
  • 解题报告-泥路(muddyroad.*)
  • 洛谷P10112 [GESP202312 八级] 奖品分配
  • P10400 『STA - R5』消失的计算机
  • 2025 地坪研磨机厂家推荐权威推荐排行榜:品牌深度解析及格力 / 宁德时代合作案例速递水磨石/遥控式/座驾式/小型地坪研磨机厂家推荐
  • 2025 年最新推荐铝塑膜源头厂家权威排行榜:聚焦 3000㎡厂房与完整产业链的优质企业盘点复合/防锈防潮/木箱包装/设备包装铝塑膜厂家推荐
  • 2025 年真空袋生产厂家最新权威推荐排行榜:TOP 级企业工艺、服务及适配场景全景对比指南木箱/设备/海运防潮/铝塑/电柜真空袋厂家推荐
  • 《码界飞升传II:数据星辰异界问道》
  • Win FAQ
  • 结论(数学)
  • loki收集容器日志
  • Xcode 火焰图
  • 完整教程:Nginx反向代理与缓存功能