Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/tiny-agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Or using a local or remote endpoint URL:

Where `servers` is a list of MCP servers (we support Stdio, SSE, and HTTP servers).

Optionally, you can add a `PROMPT.md` file to override the default Agent prompt.
Optionally, you can add a `PROMPT.md` or [`AGENTS.md`](https://agents.md/) file to override the default Agent prompt.

Then just point tiny-agents to your local folder:

Expand All @@ -93,7 +93,7 @@ npx @huggingface/tiny-agents run "julien-c/flux-schnell-generator"
```

> [!NOTE]
> Want to share your own agent with the community? Submit a PR to the [Tiny Agents](https://huggingface.co/datasets/tiny-agents/tiny-agents/discussions) repository on the Hub. Your submission must include an `agent.json` file, and you can optionally add a `PROMPT.md` file. To help others understand your agent's capabilities, consider including an `EXAMPLES.md` file with sample prompts and use cases.
> Want to share your own agent with the community? Submit a PR to the [Tiny Agents](https://huggingface.co/datasets/tiny-agents/tiny-agents/discussions) repository on the Hub. Your submission must include an `agent.json` file, and you can optionally add a `PROMPT.md` or [`AGENTS.md`](https://agents.md/) file. To help others understand your agent's capabilities, consider including an `EXAMPLES.md` file with sample prompts and use cases.

## Advanced: Programmatic Usage

Expand Down
38 changes: 22 additions & 16 deletions packages/tiny-agents/src/lib/loadConfigFrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { TinyAgentConfig } from "./types";
import { debug, error } from "./utils";

const FILENAME_CONFIG = "agent.json";
const FILENAME_PROMPT = "PROMPT.md";
const PROMPT_FILENAMES = ["PROMPT.md", "AGENTS.md"] as const;

const TINY_AGENTS_HUB_REPO: RepoDesignation = {
name: "tiny-agents/tiny-agents",
Expand All @@ -29,10 +29,13 @@ async function tryLoadFromDirectory(dirPath: string): Promise<TinyAgentConfig |
}

let prompt: string | undefined;
try {
prompt = await readFile(join(dirPath, FILENAME_PROMPT), { encoding: "utf8" });
} catch {
debug(`PROMPT.md not found in ${dirPath}, continuing without prompt template`);
for (const filename of PROMPT_FILENAMES) {
try {
prompt = await readFile(join(dirPath, filename), { encoding: "utf8" });
break;
} catch {
debug(`${filename} not found in ${dirPath}, continuing without prompt template`);
}
}

try {
Expand Down Expand Up @@ -60,17 +63,20 @@ async function tryLoadFromHub(agentId: string): Promise<TinyAgentConfig | undefi
}

let prompt: string | undefined;
try {
const promptPath = await downloadFileToCacheDir({
repo: TINY_AGENTS_HUB_REPO,
path: `${agentId}/${FILENAME_PROMPT}`,
accessToken: process.env.HF_TOKEN,
});
prompt = await readFile(promptPath, { encoding: "utf8" });
} catch {
debug(
`PROMPT.md not found in https://huggingface.co/datasets/tiny-agents/tiny-agents/tree/main/${agentId}, continuing without prompt template`
);
for (const filename of PROMPT_FILENAMES) {
try {
const promptPath = await downloadFileToCacheDir({
repo: TINY_AGENTS_HUB_REPO,
path: `${agentId}/${filename}`,
accessToken: process.env.HF_TOKEN,
});
prompt = await readFile(promptPath, { encoding: "utf8" });
break;
} catch {
debug(
`${filename} not found in https://huggingface.co/datasets/tiny-agents/tiny-agents/tree/main/${agentId}, continuing without prompt template`
);
}
}

return {
Expand Down