AI Open Source · SDK 与开发工具

assistant-ui/assistant-ui

React 组件库,专门给 AI 聊天界面用。基于 Radix UI 和 shadcn 风格,提供消息流、 thread、工具调用展示等开箱即用的组件。前端要快速搭一个 ChatGPT 样式的对话界面、 接入自家模型时,省掉从零写 UI 的工作。

Typescript/React Library for AI Chat💬🚀

Stars
10k
Language
TypeScript
License
MIT
Last push
today
Created
2023-11-22
Topics
ai-chatbotchatbotconversational-aicopilotradix-uireact-chatbot

README

<a href="https://www.assistant-ui.com"> <img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/header.svg" alt="assistant-ui Header" width="100%" /> </a> <p align="center"> <a href="https://www.assistant-ui.com">Product</a> · <a href="https://www.assistant-ui.com/docs">Documentation</a> · <a href="https://www.assistant-ui.com/examples">Examples</a> · <a href="https://discord.gg/S9dwgCNEFs">Discord</a> · <a href="https://cal.com/simon-farshid/assistant-ui">Contact Sales</a> </p>

npm version npm downloads Ask DeepWiki Weave Badge GitHub License GitHub stars Backed by Y Combinator

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.

Installation

The fastest path is the CLI, which scaffolds a Next.js app or adds the styled components to an existing project:

npx assistant-ui@latest create   # new project
npx assistant-ui@latest init     # add to existing project

Or install the packages directly:

npm install @assistant-ui/react @assistant-ui/react-ai-sdk

Usage

"use client";

import { AssistantRuntimeProvider } from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
import { Thread } from "@/components/assistant-ui/thread";

export function Chat() {
  const runtime = useChatRuntime();
  return (
    <AssistantRuntimeProvider runtime={runtime}>
      <Thread />
    </AssistantRuntimeProvider>
  );
}

useChatRuntime connects to the Vercel AI SDK out of the box. Swap it for useLangGraphRuntime, useDataStreamRuntime, or any custom runtime to integrate with your own backend.

assistant-ui starter template

What you get

  • Composable primitives: build any chat UX from Thread, Message, Composer, ThreadList, ActionBar, and friends. Style every pixel yourself, or start from a polished shadcn/ui theme that the CLI copies into your project.
  • Production UX out of the box: streaming, auto-scroll, retries, attachments, markdown, code highlighting, voice dictation, keyboard shortcuts, and accessibility.
  • Generative UI: render tool calls and JSON as React components, collect inline human approvals, and expose safe frontend actions to the model.
  • Strong TypeScript: typed runtime APIs, tool schemas, message parts, and adapters end to end.

Backends

IntegrationPackage
Vercel AI SDK@assistant-ui/react-ai-sdk
LangGraph / LangChain@assistant-ui/react-langgraph, @assistant-ui/react-langchain
AG-UI / A2A protocols@assistant-ui/react-ag-ui, @assistant-ui/react-a2a
Google ADK / OpenCode@assistant-ui/react-google-adk, @assistant-ui/react-opencode
Custom data-stream backend@assistant-ui/react-data-stream
Managed thread history, telemetry, and file storageassistant-cloud

Broad model support out of the box (OpenAI, Anthropic, Google Gemini, Mistral, Perplexity, AWS Bedrock, Azure, Fireworks, Ollama) plus community providers via the AI SDK, and easy extension to any custom HTTP backend.

Customization

Radix-style: instead of a single monolithic chat component, you compose primitives and bring your own styles. The CLI ships a great starter; you control everything else.

Overview of components

Sample customization to make a Perplexity lookalike:

Perplexity clone created with assistant-ui

Used in producti

同一分类的其他项