npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@oakkles/llm-ui-react

v0.1.1

Published

React components for building AI and LLM chat interfaces.

Readme

@oakkles/llm-ui-react

面向 AI / LLM 产品的 React 组件库,用一套可组合组件快速搭建 Chat、Agent、知识库问答和流式生成界面。

npm React TypeScript Storybook Package License

特性

| 能力 | 说明 | | ---------- | ------------------------------------------------------------------------ | | 对话界面 | BubbleMessageListConversationList 组合出完整 Chat UI | | 输入体验 | Sender 支持受控输入、发送、取消、前缀操作和模型切换入口 | | 流式生成 | useStreammockStream 和 Markdown streaming 状态适配流式回复 | | 富文本输出 | MarkCodeHighlighter 支持 Markdown、GFM、代码块和语法高亮 | | Agent 过程 | ThinkThoughtCitation 展示思考过程、步骤和引用来源 | | 主题系统 | 基于 data-theme 和 CSS Variables,内置 light / dark 主题和柔和切换动画 | | AI Ready | Demo 可接入 /api/chat 这类后端接口,安全使用真实模型能力 |

安装

pnpm add @oakkles/llm-ui-react

也可以使用 npm:

npm install @oakkles/llm-ui-react

快速开始

导入组件和样式:

import { ConfigProvider, MessageList, Sender } from '@oakkles/llm-ui-react'
import '@oakkles/llm-ui-react/style.css'

const messages = [
  {
    id: 'hello-user',
    role: 'user',
    content: '帮我总结今天的发布风险。',
  },
  {
    id: 'hello-assistant',
    role: 'assistant',
    content: '可以从接口稳定性、文档一致性和回归覆盖三个方向拆分。',
  },
] as const

export function Chat() {
  return (
    <ConfigProvider theme={{ mode: 'light' }} locale="zh-CN">
      <MessageList messages={messages} />
      <Sender onSend={(message) => console.log(message)} />
    </ConfigProvider>
  )
}

真实 AI Demo 接入

组件库可以发布静态 Demo,也可以在部署到 Vercel 后接入真实 AI 能力。推荐结构是:

浏览器 Demo
  -> fetch('/api/chat')
  -> Vercel Serverless Function
  -> OpenAI-compatible 模型服务

不要把模型 API Key 放进前端代码、Storybook stories 或任何 VITE_* 环境变量。Key 应该只存在于 Vercel 服务端环境变量中,例如:

DEEPSEEK_API_KEY=your-server-side-key
DEEPSEEK_MODEL=deepseek-chat

前端 Demo 只调用自己的后端接口:

async function* requestAI(message: string) {
  const response = await fetch('/api/chat', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ message }),
  })

  const reader = response.body?.getReader()
  const decoder = new TextDecoder()

  if (!reader) return

  while (true) {
    const { done, value } = await reader.read()
    if (done) break
    yield decoder.decode(value)
  }
}

这样 npm 包保持安全、可复用,Vercel 上的在线 Demo 仍然可以拥有真实 AI 回复。

组件矩阵

| 分类 | 组件 | | --------------- | -------------------------------------- | | 基础上下文 | ConfigProvider | | 消息展示 | BubbleMessageList | | 输入与发送 | Sender | | Markdown 与代码 | MarkCodeHighlighter | | 会话管理 | ConversationListConversationItem | | 快捷操作 | PromptsActions | | 推理与引用 | ThinkThoughtCitation | | 通知反馈 | NotificationNotificationStack |

Hooks 与工具

| API | 用途 | | ------------------- | ---------------------------------- | | useConfig | 读取全局配置 | | useLocale | 读取当前语言包 | | useTheme | 读取和切换主题 | | useStream | 管理流式文本状态 | | useVirtualList | 虚拟列表能力 | | mockStream | 本地模拟流式输出 | | streamToGenerator | 将 Web Stream 转为 async generator | | generatorToStream | 将 async generator 转为 Web Stream | | sanitizeMarkdown | 修复 streaming 阶段不完整 Markdown |

主题

主题通过 data-theme 属性和 CSS Variables 驱动:

document.documentElement.setAttribute('data-theme', 'dark')

也可以通过 ConfigProvideruseTheme 控制:

<ConfigProvider theme={{ mode: 'dark' }} locale="zh-CN">
  <App />
</ConfigProvider>

内置主题文件:

src/styles/themes/light.css
src/styles/themes/dark.css
src/styles/tokens.css

所有变量都使用 --llm- 前缀,便于外部覆盖。

本地开发

pnpm install
pnpm storybook

常用命令:

pnpm lint              # ESLint 检查
pnpm build             # 构建库代码、类型声明和 CSS
pnpm test:storybook    # 运行 Storybook browser tests
pnpm build-storybook   # 构建 Storybook 静态站点

发布产物

库构建输出到 dist/

dist/index.js      # ESM
dist/index.cjs     # CommonJS
dist/index.d.ts    # 类型声明
dist/style.css     # 组件样式

用户应同时导入组件入口和样式入口:

import { Bubble } from '@oakkles/llm-ui-react'
import '@oakkles/llm-ui-react/style.css'

在线文档

Storybook / Vercel Demo:Coming soon