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

فريق من تطبيقات الذكاء الاصطناعي الخفيفة الوزن والقابلة للتركيب، مبنية على عميل الاستدلال (Inference Client) ومكدس MCP من Hugging Face.

التثبيت

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

استخدام سطر الأوامر

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

يمكنك تحميل الوكلاء مباشرةً من مجموعة بيانات tiny-agents على Hugging Face Hub، أو تحديد مسارًا لإعداد وكيل محلي خاص بك.

تعريف وكيلك الخاص

أبسط طريقة لإنشاء وكيلك الخاص هي إنشاء مجلد يحتوي على ملف 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) لتجاوز موجه الوكيل الافتراضي.

ثم ما عليك سوى توجيه tiny-agents إلى مجلدك المحلي:

npx @huggingface/tiny-agents run ./my-agent

ها هو! 🔥

مجموعة Tiny Agents

تصفّح مجموعتنا المختارة من Tiny Agents على https://huggingface.co/datasets/tiny-agents/tiny-agents. يُخزَّن كل وكيل في مجلد فرعي خاص به، وفقاً للهيكلية الموضحة أعلاه. تشغيل وكيل من Hub بسيط للغاية، إذ يكفي استخدام agent_id الخاص به. على سبيل المثال، لتشغيل وكيل julien-c/flux-schnell-generator:

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

هل ترغب في مشاركة وكيلك الخاص مع المجتمع؟ قدّم طلب سحب (PR) إلى مستودع Tiny Agents على Hub. يجب أن يتضمن طلبك ملف 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