Skip to content

Commit 61ef178

Browse files
committed
some LLM scaffolding + some human edit πŸ™„
1 parent 29150f4 commit 61ef178

File tree

6 files changed

+194
-1
lines changed

6 files changed

+194
-1
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ const agent = new Agent({
241241
],
242242
});
243243

244-
245244
await agent.loadTools();
245+
246246
for await (const chunk of agent.run("What are the top 5 trending models on Hugging Face?")) {
247247
if ("choices" in chunk) {
248248
const delta = chunk.choices[0]?.delta;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# @huggingface/tiny-agents
2+
3+
A lightweight, composable agent framework for AI applications built on Hugging Face's JS stack.
4+
5+
## Installation
6+
7+
```bash
8+
npm install @huggingface/tiny-agents
9+
# or
10+
yarn add @huggingface/tiny-agents
11+
# or
12+
pnpm add @huggingface/tiny-agents
13+
```
14+
15+
## Usage
16+
17+
```typescript
18+
import { Agent } from '@huggingface/tiny-agents';
19+
20+
const HF_TOKEN = "hf_...";
21+
22+
// Create an Agent
23+
const agent = new Agent({
24+
provider: "auto",
25+
model: "Qwen/Qwen2.5-72B-Instruct",
26+
apiKey: HF_TOKEN,
27+
servers: [
28+
{
29+
// Playwright MCP
30+
command: "npx",
31+
args: ["@playwright/mcp@latest"],
32+
},
33+
],
34+
});
35+
36+
await agent.loadTools();
37+
38+
// Use the Agent
39+
for await (const chunk of agent.run("What are the top 5 trending models on Hugging Face?")) {
40+
if ("choices" in chunk) {
41+
const delta = chunk.choices[0]?.delta;
42+
if (delta.content) {
43+
console.log(delta.content);
44+
}
45+
}
46+
}
47+
```
48+
49+
## CLI Usage
50+
51+
```bash
52+
npx @huggingface/tiny-agents
53+
```
54+
55+
## License
56+
57+
MIT
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@huggingface/tiny-agents",
3+
"packageManager": "[email protected]",
4+
"version": "0.1.0",
5+
"description": "Lightweight, composable agents for AI applications",
6+
"repository": "https://github.com/huggingface/huggingface.js.git",
7+
"publishConfig": {
8+
"access": "public"
9+
},
10+
"main": "./dist/index.js",
11+
"module": "./dist/index.mjs",
12+
"types": "./dist/index.d.ts",
13+
"bin": {
14+
"tiny-agents": "./dist/cli.js"
15+
},
16+
"exports": {
17+
".": {
18+
"types": "./dist/index.d.ts",
19+
"require": "./dist/index.js",
20+
"import": "./dist/index.mjs"
21+
}
22+
},
23+
"engines": {
24+
"node": ">=18"
25+
},
26+
"source": "index.ts",
27+
"scripts": {
28+
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
29+
"lint:check": "eslint --ext .cjs,.ts .",
30+
"format": "prettier --write .",
31+
"format:check": "prettier --check .",
32+
"prepublishOnly": "pnpm run build",
33+
"build": "tsup src/index.ts --format cjs,esm --clean && tsc --emitDeclarationOnly --declaration",
34+
"prepare": "pnpm run build",
35+
"test": "vitest run",
36+
"check": "tsc",
37+
"cli": "tsx cli.ts"
38+
},
39+
"files": [
40+
"src",
41+
"dist",
42+
"tsconfig.json"
43+
],
44+
"keywords": [
45+
"huggingface",
46+
"agent",
47+
"ai",
48+
"llm",
49+
"tiny-agent"
50+
],
51+
"author": "Hugging Face",
52+
"license": "MIT",
53+
"dependencies": {
54+
"@huggingface/inference": "workspace:^",
55+
"@huggingface/mcp-client": "workspace:^"
56+
}
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env node
2+
import * as readline from "node:readline/promises";
3+
import { stdin, stdout } from "node:process";
4+
import { join } from "node:path";
5+
import { homedir } from "node:os";
6+
import { parseArgs } from "node:util";
7+
import type { InferenceProviderOrPolicy } from "@huggingface/inference";
8+
import { version as packageVersion } from "../package.json";
9+
10+
const SERVERS: ServerConfig[] = [
11+
{
12+
// Filesystem "official" mcp-server with access to your Desktop
13+
command: "npx",
14+
args: [
15+
"-y",
16+
"@modelcontextprotocol/server-filesystem",
17+
process.platform === "darwin" ? join(homedir(), "Desktop") : homedir(),
18+
],
19+
},
20+
{
21+
// Playwright MCP
22+
command: "npx",
23+
args: ["@playwright/mcp@latest"],
24+
},
25+
];
26+
27+
async function main() {
28+
const {
29+
values: { url: urls },
30+
} = parseArgs({
31+
options: {
32+
url: {
33+
type: "string",
34+
multiple: true,
35+
},
36+
},
37+
});
38+
if (urls?.length) {
39+
while (SERVERS.length) {
40+
SERVERS.pop();
41+
}
42+
for (const url of urls) {
43+
try {
44+
SERVERS.push(urlToServerConfig(url, process.env.HF_TOKEN));
45+
} catch (error) {
46+
console.error(`Error adding server from URL "${url}": ${error.message}`);
47+
}
48+
}
49+
}
50+
51+
if (process.argv.includes("--version")) {
52+
console.log(packageVersion);
53+
process.exit(0);
54+
}
55+
}
56+
57+
main();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"lib": ["ES2022", "DOM"],
5+
"module": "CommonJS",
6+
"moduleResolution": "node",
7+
"target": "ES2022",
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"noImplicitAny": true,
11+
"strictNullChecks": true,
12+
"skipLibCheck": true,
13+
"noImplicitOverride": true,
14+
"outDir": "./dist",
15+
"declaration": true,
16+
"declarationMap": true,
17+
"resolveJsonModule": true
18+
},
19+
"include": ["src", "test"],
20+
"exclude": ["dist"]
21+
}

0 commit comments

Comments
Β (0)