diff --git a/bun.lockb b/bun.lockb index bab3c1d..96fa98e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/example/README.md b/example/README.md index 618dd1d..06c83f9 100644 --- a/example/README.md +++ b/example/README.md @@ -8,17 +8,22 @@ These examples use OpenAI and FireCrawl APIs. You need to have the following env - `OPENAI_API_KEY` - Your OpenAI API key - `FIRECRAWL_API_KEY` - Your FireCrawl API key for GitHub and NPM data access +In order to run Slack example, you need to have `SLACK_API_TOKEN` and `SLACK_CHANNEL_ID` environment variables set. + +> [!NOTE] +> FireCrawl requests are throttled to 10 requests per minute, as per the Free Plan, to avoid rate limiting. + ## Structure - `flows.ts` - All flows are defined here - `agents.ts` - All agents are defined here +> [!NOTE] +> We're using [`Agentic`](https://github.com/agentic/agentic) to create agents. + ## Running the examples - `bun run-organization-analysis.ts callstackincubator` - Analyzing an entire GitHub organization - `bun run-project-analysis.ts facebook/react-native` - Analyzing a single GitHub project - `bun run-organization-analysis-with-slack-message.ts callstackincubator` - Analyzing an entire GitHub organization and sending the report to Slack -> [!NOTE] -> In order to run Slack example, you need to have `SLACK_API_TOKEN` environment variable set. -> You will also need to have `SLACK_CHANNEL_ID` environment variable set. diff --git a/example/agents.ts b/example/agents.ts index 3d20860..fa0b17d 100644 --- a/example/agents.ts +++ b/example/agents.ts @@ -1,10 +1,27 @@ import { createAISDKTools } from '@agentic/ai-sdk' +import { throttleKy } from '@agentic/core' import { FirecrawlClient } from '@agentic/firecrawl' import { SlackClient } from '@agentic/slack' import { openai } from '@ai-sdk/openai' import { agent } from 'flows-ai' +import ky from 'ky' +import pThrottle from 'p-throttle' + +/** + * Let's throttle the Firecrawl client to 10 requests per minute, + * as per the Firecrawl Free Plan. + */ +const firecrawl = new FirecrawlClient({ + ky: throttleKy( + ky, + pThrottle({ + limit: 1, + interval: 6000, + strict: true, + }) + ), +}) -const firecrawl = new FirecrawlClient() const slack = new SlackClient() export const githubAgent = agent({ diff --git a/example/package.json b/example/package.json index e2693cd..114f67b 100644 --- a/example/package.json +++ b/example/package.json @@ -14,7 +14,10 @@ }, "dependencies": { "@agentic/ai-sdk": "^7.2.0", + "@agentic/core": "^7.2.0", "@agentic/firecrawl": "^7.2.0", - "@agentic/slack": "^7.2.0" + "@agentic/slack": "^7.2.0", + "ky": "^1.7.4", + "p-throttle": "^6.2.0" } } diff --git a/example/run-organization-analysis.ts b/example/run-organization-analysis.ts index 3d69ab3..f9d8781 100644 --- a/example/run-organization-analysis.ts +++ b/example/run-organization-analysis.ts @@ -24,9 +24,6 @@ const response = await execute(organizationAnalysisFlow, { onFlowStart: (flow) => { console.log('Executing', flow.agent.name) }, - onFlowFinish: (flow, response) => { - console.log('Flow finished', flow.agent.name, response) - }, }) console.log(response)