百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-llm

> 前端框架
开源

使用易于使用的无头 React 钩子在浏览器中运行 LLM,只需使用 LLM()。

700 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

使用易于使用的无头 React 钩子在浏览器中运行 LLM,只需使用 LLM()。

@react-llm/headless

Easy-to-use headless React Hooks to run LLMs in the browser with WebGPU. As simple as useLLM().

Live Demo

Features:

  • Supports Vicuna 7B
  • Use custom system prompts and "user:"/"assistant:" role names
  • Completion options like max tokens and stop sequences
  • No data leaves the browser. Accelerated via WebGPU.
  • Hooks built to 'Bring your own UI'
  • Persistent storage for conversations in browser storage. Hooks for loading and saving conversations.
  • Model caching for faster subsequent loads

Installation

bash
npm install @react-llm/headless

Packages in this repository

  • @react-llm/model - The LLM model and tokenizer compiled for the browser
  • @react-llm/retro-ui - Retro-themed UI for the hooks
  • @react-llm/extension - Chrome Extension that uses the hooks
  • @react-llm/headless - Headless React Hooks for running LLMs in the browser

useLLM API

Types

…

Hooks

typescript
import useLLM from '@react-llm/headless';

const MyComponent = () => {
  const {
    conversation,
    allConversations,
    loadingStatus,
    isGenerating,
    createConversation,
    setConversationId,
    deleteConversation,
    deleteAllConversations,
    deleteMessages,
    setConversationTitle,
    onMessage,
    setOnMessage,
    userRoleName,
    setUserRoleName,
    assistantRoleName,
    setAssistantRoleName,
    gpuDevice,
    send,
    init,
  } = useLLM();

  // Component logic...

  return null;
};

Provider

typescript
import { ModelProvider } from "@react-llm/headless";

export default function Home() {
  return (
    
      
    
  );
}

Packages

  • @react-llm/headless - Headless React Hooks for running LLMs in the browser
  • @react-llm/retro-ui - Retro-themed UI for the hooks

How does it work?

This library is a set of React Hooks that provide a simple interface to run LLMs in the browser. It uses Vicuna 13B.

  • SentencePiece tokenizer (compiled for the browser via Emscripten)
  • Vicuna 7B (transformed to Apache TVM format)
  • Apache TVM and MLC Relax (compiled for the browser via Emscripten)
  • Off-the-main-thread WebWorker to run the model (bundled with the library)

The model, tokenizer, and TVM runtime are loaded from a CDN (huggingface). The model is cached in browser storage for faster subsequent loads.

Example

See packages/retro-ui for the full demo code. This is a simple example of how to use the hooks. To run it, after cloning the repo,

bash
cd packages/retro-ui
pnpm install
pnpm dev

License

MIT

The code under packages/headless/worker/lib/tvm is licensed under Apache 2.0.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptheadlessllmreactwebgpu

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架