使用易于使用的无头 React 钩子在浏览器中运行 LLM,只需使用 LLM()。
Easy-to-use headless React Hooks to run LLMs in the browser with WebGPU. As simple as useLLM().
Features:
max tokens and stop sequencesnpm install @react-llm/headless…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;
};import { ModelProvider } from "@react-llm/headless";
export default function Home() {
return (
);
}@react-llm/headless - Headless React Hooks for running LLMs in the browser@react-llm/retro-ui - Retro-themed UI for the hooksThis library is a set of React Hooks that provide a simple interface to run LLMs in the browser. It uses Vicuna 13B.
The model, tokenizer, and TVM runtime are loaded from a CDN (huggingface). The model is cached in browser storage for faster subsequent loads.
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,
cd packages/retro-ui
pnpm install
pnpm devMIT
The code under packages/headless/worker/lib/tvm is licensed under Apache 2.0.
暂无开放 Issues,或尚未同步最近议题。