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

huggingface.js

> 开发工具
开源

将 Hugging Face 与 JavaScript 结合使用

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

工具介绍

将 Hugging Face 与 JavaScript 结合使用




``` … ``` # Hugging Face JS libraries This is a collection of JS libraries to interact with the Hugging Face API, with TS types included. - [@huggingface/hub](packages/hub/README.md): Interact with huggingface.co to create or delete repos and commit / download files - [@huggingface/inference](packages/inference/README.md): Use all supported (serverless) Inference Providers or switch to Inference Endpoints (dedicated) to make calls to 100,000+ Machine Learning models - [@huggingface/mcp-client](packages/mcp-client/README.md): A Model Context Protocol (MCP) client, and a tiny Agent library, built on top of InferenceClient. - [@huggingface/gguf](packages/gguf/README.md): A GGUF parser that works on remotely hosted files. - [@huggingface/dduf](packages/dduf/README.md): Similar package for DDUF (DDUF Diffusers Unified Format) - [@huggingface/tasks](packages/tasks/README.md): The definition files and source-of-truth for the Hub's main primitives like pipeline tasks, model libraries, etc. - [@huggingface/jinja](packages/jinja/README.md): A minimalistic JS implementation of the Jinja templating engine, to be used for ML chat templates. - [@huggingface/space-header](packages/space-header/README.md): Use the Space `mini_header` outside Hugging Face - [@huggingface/ollama-utils](packages/ollama-utils/README.md): Various utilities for maintaining Ollama compatibility with models on the Hugging Face Hub. - [@huggingface/tiny-agents](packages/tiny-agents/README.md): A tiny, model-agnostic library for building AI agents that can use tools. We use modern features to avoid polyfills and dependencies, so the libraries will only work on modern browsers / Node.js >= 18 / Bun / Deno. The libraries are still very young, please help us by opening issues! ## Installation ### From NPM To install via NPM, you can download the libraries as needed: ```bash npm install @huggingface/hub npm install @huggingface/inference npm install @huggingface/mcp-client ``` Then import the libraries in your code: ```ts import { createRepo, commit, deleteRepo, listFiles } from "@huggingface/hub"; import { InferenceClient } from "@huggingface/inference"; import { McpClient } from "@huggingface/mcp-client"; import type { RepoId } from "@huggingface/hub"; ``` ### From CDN or Static hosting You can run our packages with vanilla JS, without any bundler, by using a CDN or static hosting. Using [ES modules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/), i.e. ` ``` ### Deno ```ts // esm.sh import { InferenceClient } from "https://esm.sh/@huggingface/inference" import { createRepo, commit, deleteRepo, listFiles } from "https://esm.sh/@huggingface/hub" // or npm: import { InferenceClient } from "npm:@huggingface/inference" import { createRepo, commit, deleteRepo, listFiles } from "npm:@huggingface/hub" ``` ## Usage examples Get your HF access token in your [account settings](https://huggingface.co/settings/tokens). ### @huggingface/inference examples ``` … ``` ### @huggingface/hub examples ``` … ``` ### @huggingface/mcp-client example ```ts import { Agent } from '@huggingface/mcp-client'; const HF_TOKEN = "hf_..."; const agent = new Agent({ provider: "auto", model: "Qwen/Qwen2.5-72B-Instruct", apiKey: HF_TOKEN, servers: [ { // Playwright MCP command: "npx", args: ["@playwright/mcp@latest"], }, ], }); await agent.loadTools(); for await (const chunk of agent.run("What are the top 5 trending models on Hugging Face?")) { if ("choices" in chunk) { const delta = chunk.choices[0]?.delta; if (delta.content) { console.log(delta.content); } } } ``` There are more features of course, check each library's README! ## Formatting & testing ```console sudo corepack enable pnpm install pnpm -r format:check pnpm -r lint:check pnpm -r test ``` ## Building ``` pnpm -r build ``` This will generate ESM and CJS javascript files in `packages/*/dist`, eg `packages/inference/dist/index.mjs`.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

TypeScriptapi-clienthubhuggingfaceinference

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

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具