assistant-ui

news/2025/10/6 12:07:50/文章来源:https://www.cnblogs.com/lightsong/p/19127469

assistant-ui.

https://langgraph.com.cn/cloud/how-tos/use_stream_react/index.html

useStream() React hook 提供了一种将 LangGraph 无缝集成到 React 应用程序中的方式。它处理了流式传输、状态管理和分支逻辑的所有复杂性,让你专注于构建出色的聊天体验。

主要功能

  • 消息流:处理消息块流以形成完整消息
  • 消息、中断、加载状态和错误的自动状态管理
  • 对话分支:从聊天历史中的任何点创建备用对话路径
  • 与 UI 无关的设计:使用你自己的组件和样式

让我们探讨如何在你的 React 应用程序中使用 useStream()

useStream() 为创建定制聊天体验提供了坚实的基础。对于预构建的聊天组件和界面,我们还建议查看 CopilotKit 和 assistant-ui。

 

https://docs.langchain.com/langgraph-platform/use-stream-react

How to integrate LangGraph into your React application

 
 
Prerequisites
  • LangGraph Platform
  • LangGraph Server

The useStream() React hook provides a seamless way to integrate LangGraph into your React applications. It handles all the complexities of streaming, state management, and branching logic, letting you focus on building great chat experiences. Key features:

  • Messages streaming: Handle a stream of message chunks to form a complete message
  • Automatic state management for messages, interrupts, loading states, and errors
  • Conversation branching: Create alternate conversation paths from any point in the chat history
  • UI-agnostic design: bring your own components and styling

Let’s explore how to use useStream() in your React application. The useStream() provides a solid foundation for creating bespoke chat experiences. For pre-built chat components and interfaces, we also recommend checking out CopilotKit and assistant-ui.

 

https://www.npmjs.com/package/@langchain/langgraph-sdk

To get started with the JS/TS SDK, install the package

yarn add @langchain/langgraph-sdk

You will need a running LangGraph API server. If you're running a server locally using langgraph-cli, SDK will automatically point at http://localhost:8123, otherwise you would need to specify the server URL when creating a client.

import { Client } from "@langchain/langgraph-sdk";const client = new Client();// List all assistants
const assistants = await client.assistants.search({metadata: null,offset: 0,limit: 10,
});// We auto-create an assistant for each graph you register in config.
const agent = assistants[0];// Start a new thread
const thread = await client.threads.create();// Start a streaming run
const messages = [{ role: "human", content: "what's the weather in la" }];const streamResponse = client.runs.stream(thread["thread_id"],agent["assistant_id"],{input: { messages },}
);for await (const chunk of streamResponse) {console.log(chunk);
}

 

https://github.com/assistant-ui/assistant-ui

The UX of ChatGPT in your React app 💬🚀

assistant-ui is an open source TypeScript/React library to build production-grade AI chat experiences fast.

  • Handles streaming, auto-scrolling, accessibility, and real-time updates for you
  • Fully composable primitives inspired by shadcn/ui and cmdk — customize every pixel
  • Works with your stack: AI SDK, LangGraph, Mastra, or any custom backend
  • Broad model support out of the box (OpenAI, Anthropic, Mistral, Perplexity, AWS Bedrock, Azure, Google Gemini, Hugging Face, Fireworks, Cohere, Replicate, Ollama) with easy extension to custom APIs

Why assistant-ui

  • Fast to production: battle-tested primitives, built-in streaming and attachments
  • Designed for customization: composable pieces instead of a monolithic widget
  • Great DX: sensible defaults, keyboard shortcuts, a11y, and strong TypeScript
  • Enterprise-ready: optional chat history and analytics via Assistant Cloud

 

https://www.assistant-ui.com/docs/getting-started

UX of ChatGPT in your own app

assistant-ui is the TypeScript/React library for AI Chat.
Built on shadcn/ui and Tailwind.

About assistant-ui

assistant-ui helps you create beautiful, enterprise-grade AI chat interfaces in minutes. Whether you're building a chatGPT clone, a customer support chatbot, an AI assistant, or a complex multi agent application, assistant-ui provides the frontend primative components and state management layers to focus on what makes your application unique.

Key Features

 

Instant Chat UI

Pre-built beautiful, customizable chat interfaces out of the box. Easy to quickly iterate on your idea.

 

Chat State Management

Powerful state management for chat interactions, optimized for streaming responses and efficient rendering.

 

High Performance

Optimized for speed and efficiency with minimal bundle size, ensuring your AI chat interfaces remain responsive.

 

Framework Agnostic

Easily integrate with any backend system, whether using Vercel AI SDK, direct LLM connections, or custom solutions. Works with any React-based framework.

 

 

https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-langgraph

LangGraph Example

Hosted Demo

This example demonstrates how to use LangChain LangGraph with assistant-ui.

It is meant to be used with the backend found at LangGraph's Stockbroker example: https://github.com/bracesproul/langgraphjs-examples/tree/main/stockbroker

You need to set the following environment variables:

NEXT_PUBLIC_API_URL=https://stockbrokeragent-bracesprouls-projects.vercel.app/api
NEXT_PUBLIC_LANGGRAPH_ASSISTANT_ID=stockbroker
 

To run the example, run the following commands:

npm install
npm run dev
 

 

langgraph例子:

https://github.com/fanqingsong/assistant-ui-langgraph-fastapi

https://github.com/fanqingsong/assistant-ui-langgraph-interrupt/tree/main/backend

https://github.com/fanqingsong/assistant-ui-stockbroker

Stockbroker Human in the Loop

The code for the Stockbroker Human in the Loop video can be found in this directory. It's setup as a monorepo-style project, with frontend and backend directories. The frontend directory contains a Next.js application which allows you to interact with the Stockbroker agent via a chat interface. The backend contains a LangGraph agent which powers the core functionality of the stockbroker.

https://github.com/fanqingsong/open-canvas?tab=readme-ov-file

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/929289.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

婚纱网站怎么做临淄区最新招聘信息

grpc 与 protobuf grpc 使用的是 protobuf 协议,其是一个通用的 rpc 框架,基本支持主流的所有语言、其底层使用 http/2 进行网络通信,具有较高的效率 protobuf 是一种序列化格式,这种格式具有 序列化以及解码速度快(…

US$34.2 KEYDIY KD B10-4 Universal Flip Remote Key 3+1 Buttons for Honda Type 5pcs/lot

KEYDIY KD B10-4 Universal Flip Remote Key 3+1 Buttons for Honda Type 5pcs/lotProduct Specifications:Manufacturer: KEYDIY Condition: New Color: Black Buttons: 4 Panic: Yes Transponder: No Proximity / Sm…

福州全网网站建设揭阳企业网页制作公司

手里有块netduino的板子,一直闲置未用,netduino具体是什么不知道的就百度吧,我这也不是主要讲netduino开发的,简单说就是用.net开发硬件,了解到netduino也是原来学过C#,当然我主要的工作还是嵌入式硬件开发…

做网站一般要了解哪些广州手机网站建设公司哪家好

在调试RK3288 Android 8.1系统遇到一个问题:开机启动uboot logo过渡到kernel log的过程中会花掉直到没有显示,再出现kernel logo。分析:打印串口log时发现,uboot阶段显示一切正常,进入kernel以后就开始花掉了然后变成没…

投标网站怎么做新泰做网站

原文地址:http://blog.csdn.net/zuochanxiaoheshang/article/details/8769198 点击阅读原文 --------------------------------------------------- Hadoop 控制输出文件命名 在一般情况下,Hadoop 每一个 Reducer 产生一个输出文件,文件以 …

《无垠的太空(2)卡利班之战》电子书素材征集

《无垠的太空(2)卡利班之战》电子书素材征集《无垠的太空(2)卡利班之战》电子书素材征集 “太空无垠”(又叫“苍穹浩瀚”)系列的第二部《卡利班之战》中文版纸质书已经出了,我想制作成电子书,哪位有pdf可以发下。或…

20251006 之所思 - 人生如梦

20251006 之所思10月6日早上9点起来,一直计划刷牙洗脸后去学英语,但是沉迷于短视频,浪费两个小时,越刷越浮躁,越刷越焦虑。浮躁是因为即时满足之后的空虚感,焦虑是因为自己计划了很多事情,但是因为一直刷手机没…

C# Avalonia 16- Animation- RotateButton

C# Avalonia 16- Animation- RotateButtonRotateButton.axaml代码<Window xmlns="https://github.com/avaloniaui"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http…

US$78.85 KEYDIY KD ZB42-4 Universal Smart Remote Key 3+1 Buttons for Lexus Type 5pcs/lot

KEYDIY KD ZB42-4 Universal Smart Remote Key 3+1 Buttons for Lexus Type 5pcs/lotProduct Specifications:Manufacturer: KEYDIY Condition: New Color: Black Buttons: 4 Panic: Yes Transponder - ID: Without Tr…

2025 十一集训

/Day 1:\(2^{cn}(c<1)\) 专题选讲

详细介绍:python第31天打卡

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

US$78.85 KEYDIY KD ZB33-4 Universal Smart Remote Key 3+1 Buttons for Hyundai Type 5pcs/lot

KEYDIY KD ZB33-4 Universal Smart Remote Key 3+1 Buttons for Hyundai Type 5pcs/lotProduct Specifications:Manufacturer: KEYDIY Condition: New Color: Brown Buttons: 4 Panic: Yes Transponder - ID: Without …

Python 的 LEGB 作用域

Python 的 LEGB 作用域在 Python 的 LEGB 作用域规则中,整数(或其他变量)所处的位置取决于它的定义位置,LEGB 代表四种作用域类型,优先级从高到低为:L(Local,局部作用域) 函数内部定义的变量(包括函数参数)…

在Windows下使用lucky更新动态域名

在Windows下使用lucky更新动态域名2024.06.032.15版本之后DDNS配置进行了较大的更新 配置不再向后兼容 若进行降级 DDNS配置会丢失 配置方法详见新教程:链接关于本教程 lucky内置的DDNS功能 支持多家DDNS提供商 也允许…

20251005 模拟测 总结

\(\mathcal{Preface}\) 分数分布:\(100+100+100+100= 400\)。 AK 了,开心呀! \(\mathcal{Problem \space{} A}\) Tag:诈骗,排序,贪心。 赛时看到题,一下子没反应过来,以为是超难 DP 题。 过了 B & C 之后回…

chatjs.langchain

chatjs.langchain https://chatjs.langchain.com/ https://github.com/langchain-ai/chat-langchain Chat LangChain This repo is an implementation of a chatbot specifically focused on question answering over …

完整教程:Microsoft Word使用技巧分享(本科毕业论文版)

完整教程:Microsoft Word使用技巧分享(本科毕业论文版)pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consola…

旅游网站建设的参考文献稻壳ppt模板免费下载

文章目录 vite的proxy开发环境设置如果后端没有提供可以替换的/mis等可替换的后缀的处理办法接口如何区分.env.development开发和.env.production生产环境接口在生产环境下&#xff0c;还能使用proxy代理地址吗&#xff1f; vite的proxy开发环境设置 环境&#xff1a; vite 4…

(转)The Ten Commandments of Digital Cotrol(Part1)

(转)The Ten Commandments of Digital Cotrol(Part1)Dave Wilson, Motion Products Evangelist, Texas InstrumentsDespite the fact that I now work for the Microcontroller Division of Texas Instruments; de…

河南省大型项目建设办公室网站500页面 wordpress

说明&#xff1a; 面试题来源于网络书籍&#xff0c;公司题目以及博主原创或修改&#xff08;题目大部分来源于各种公司&#xff09;&#xff1b;文中很多题目&#xff0c;或许大家直接编译器写完&#xff0c;1分钟就出结果了。但在这里博主希望每一个题目&#xff0c;大家都要…