Huggingface.js documentation

@huggingface/tiny-agents

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

@huggingface/tiny-agents

meme

Hugging Face์˜ Inference Client์™€ MCP ์Šคํƒ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ตฌ์ถ•๋œ ๊ฒฝ๋Ÿ‰ํ˜• ์กฐํ•ฉ ๊ฐ€๋Šฅํ•œ AI ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ทธ๋ฃน์ž…๋‹ˆ๋‹ค.

์„ค์น˜

npm install @huggingface/tiny-agents
# or
pnpm add @huggingface/tiny-agents

CLI ์‚ฌ์šฉ

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 Dataset์—์„œ ์—์ด์ „ํŠธ๋ฅผ ์ง์ ‘ ๋กœ๋“œํ•˜๊ฑฐ๋‚˜, ์ž์ฒด ๋กœ์ปฌ ์—์ด์ „ํŠธ ๊ตฌ์„ฑ ํŒŒ์ผ์˜ ๊ฒฝ๋กœ๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ง์ ‘ ์—์ด์ „ํŠธ ์ •์˜ํ•˜๊ธฐ

์ž์ฒด ์—์ด์ „ํŠธ๋ฅผ ๋งŒ๋“œ๋Š” ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ 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

Voilร ! ๐Ÿ”ฅ

Tiny Agents ์ปฌ๋ ‰์…˜

https://huggingface.co/datasets/tiny-agents/tiny-agents์—์„œ ํ๋ ˆ์ด์…˜๋œ Tiny Agents ์ปฌ๋ ‰์…˜์„ ๋‘˜๋Ÿฌ๋ณด์„ธ์š”. ๊ฐ ์—์ด์ „ํŠธ๋Š” ์œ„์—์„œ ์„ค๋ช…ํ•œ ๊ตฌ์กฐ๋ฅผ ๋”ฐ๋ฅด๋ฉฐ ์ž์ฒด ํ•˜์œ„ ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. Hub์—์„œ ์—์ด์ „ํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์€ ํ•ด๋‹น agent_id๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋งŒํผ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, julien-c/flux-schnell-generator ์—์ด์ „ํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด:

npx @huggingface/tiny-agents run "julien-c/flux-schnell-generator"

์ปค๋ฎค๋‹ˆํ‹ฐ์— ์ž์ฒด ์—์ด์ „ํŠธ๋ฅผ ๊ณต์œ ํ•˜๊ณ  ์‹ถ์œผ์‹ ๊ฐ€์š”? Hub์˜ Tiny Agents ์ €์žฅ์†Œ์— PR์„ ์ œ์ถœํ•˜์„ธ์š”. ์ œ์ถœ๋ฌผ์—๋Š” agent.json ํŒŒ์ผ์ด ํฌํ•จ๋˜์–ด์•ผ ํ•˜๋ฉฐ, ์„ ํƒ์ ์œผ๋กœ PROMPT.md ๋˜๋Š” AGENTS.md ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๊ฐ€ ์—์ด์ „ํŠธ์˜ ๊ธฐ๋Šฅ์„ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก, ์ƒ˜ํ”Œ ํ”„๋กฌํ”„ํŠธ์™€ ์‚ฌ์šฉ ์‚ฌ๋ก€๊ฐ€ ํฌํ•จ๋œ 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