Huggingface.js documentation
@huggingface/tiny-agents
@huggingface/inference
使用 Inference ClientAPI 参考
类
HfInferenceInferenceClientInferenceClientEndpointInferenceClientErrorInferenceClientHubApiErrorInferenceClientInputErrorInferenceClientProviderApiErrorInferenceClientProviderOutputErrorInferenceClientRoutingError
接口
AudioToAudioOutputAudioToAudioOutputElemBaseArgsBodyParamsHeaderParamsInferenceProviderMappingEntryLogger选项TextGenerationInputTextGenerationOutputTextGenerationStreamBestOfSequenceTextGenerationStreamDetailsTextGenerationStreamOutputTextGenerationStreamPrefillTokenTextGenerationStreamTokenUrlParams
模块
@huggingface/hub
与 Hub 交互API 参考
类
接口
AuthInfoCachedFileInfoCachedRepoInfoCachedRevisionInfoCommitCopyFileCommitDataCommitDeletedEntryCommitEditFileCommitEditFileParamsCommitFileCommitInfoCommitOutputCopyDestinationCopyFilesEntryCopyProgressEventCopySource凭据DatasetEntryFileDownloadInfoOutputHFCacheInfoJobVolumeLfsPathInfoListFileEntryMlxQuantizationConfigModelConfigModelDerivedFieldsModelEntryOAuthResultParallelDownloadOptionsPathInfoQuantizationConfigRangeEditCacheEntryRepoIdSafetensorsIndexJsonSafetensorsShardFileInfoSecurityFileStatusSpaceEntrySpaceResourceConfigSpaceResourceRequirementSpaceRuntimeTensorInfoUserInfoWhoAmIAppWhoAmIOrgWhoAmIUserXetFileInfoXetReadToken
@huggingface/mcp-client
@huggingface/tiny-agents
@huggingface/space-header
@huggingface/gguf
@huggingface/lerobot
@huggingface/usd-web-viewer
@huggingface/tiny-agents

基于 Hugging Face 的 Inference Client 和 MCP 技术栈构建的一组轻量级可组合 AI 应用。
安装
npm install @huggingface/tiny-agents
# or
pnpm add @huggingface/tiny-agentsCLI 用法
npx @huggingface/tiny-agents [command] "agent/id"Usage:
tiny-agents [flags]
tiny-agents run "agent/id"
tiny-agents serve "agent/id"
Available Commands:
run Run the Agent in command-line
serve Run the Agent as an OpenAI-compatible HTTP server您可以直接从 Hugging Face Hub 的 tiny-agents 数据集加载智能体,也可以指定本地智能体配置文件的路径。
定义你自己的智能体
创建自己的智能体最简单的方法是创建一个包含 agent.json 文件的文件夹:
mkdir my-agent
touch my-agent/agent.json{
"model": "Qwen/Qwen2.5-72B-Instruct",
"provider": "novita",
"servers": [
{
"type": "stdio",
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
]
}或者使用本地或远程端点 URL:
{
"model": "Qwen/Qwen3-32B",
"endpointUrl": "http://localhost:1234/v1",
"servers": [
{
"type": "stdio",
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
]
}
其中 servers 是 MCP 服务器的列表(我们支持 Stdio、SSE 和 HTTP 服务器)。
可选地,您可以添加一个 AGENTS.md(或 PROMPT.md)文件来覆盖默认的 Agent 提示词。
然后只需将 tiny-agents 指向您的本地文件夹:
npx @huggingface/tiny-agents run ./my-agent
瞧!🔥
Tiny Agents 集合
浏览我们在 https://huggingface.co/datasets/tiny-agents/tiny-agents 上精心整理的 Tiny Agents 合集。每个 agent 都存储在其自己的子目录中,遵循上述结构。从 Hub 运行 agent 只需使用其 agent_id 即可。例如,要运行 julien-c/flux-schnell-generator agent:
npx @huggingface/tiny-agents run "julien-c/flux-schnell-generator"想要与社区分享你自己的 agent 吗?请向 Hub 上的 Tiny Agents 仓库提交 PR。你的提交必须包含一个
agent.json文件,并且可以选择性地添加一个PROMPT.md或AGENTS.md文件。为了帮助他人了解你的 agent 的功能,建议包含一个EXAMPLES.md文件,其中提供示例提示词和使用场景。
高级:编程式用法
import { Agent } from '@huggingface/tiny-agents';
const HF_TOKEN = "hf_...";
// Create an Agent
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();
// Use the Agent
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);
}
}
}许可证
MIT
Update on GitHub