Skip to content

Commit 9daee35

Browse files
authored
Merge pull request #35 from midday-ai/feature/agents-package
Agents SDK
2 parents 8cf1290 + 415190b commit 9daee35

File tree

114 files changed

+5711
-4940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+5711
-4940
lines changed

README.md

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,43 @@
22

33
![AI SDK Tools](image.png)
44

5-
Essential utilities that extend and improve the Vercel AI SDK experience. State management, debugging tools, and structured artifact streaming - everything you need to build production-ready AI applications beyond simple chat interfaces.
5+
Essential utilities for building production-ready AI applications with Vercel AI SDK. State management, debugging, structured streaming, intelligent agents, and caching - everything you need beyond basic chat interfaces.
66

77
## Packages
88

9-
### 🗄️ [@ai-sdk-tools/store](./packages/store)
10-
AI chat state that scales with your application. Eliminates prop drilling within your chat components, ensuring better performance and cleaner architecture.
9+
### [@ai-sdk-tools/store](./packages/store)
10+
AI chat state management that eliminates prop drilling. Clean architecture and better performance for chat components.
1111

1212
```bash
1313
npm i @ai-sdk-tools/store
1414
```
1515

16-
### 🔧 [@ai-sdk-tools/devtools](./packages/devtools)
17-
Development tools for debugging AI applications. A development-only debugging tool that integrates directly into your codebase, just like react-query-devtools.
16+
### [@ai-sdk-tools/devtools](./packages/devtools)
17+
Development tools for debugging AI applications. Inspect tool calls, messages, and execution flow directly in your app.
1818

1919
```bash
2020
npm i @ai-sdk-tools/devtools
2121
```
2222

23-
### 📦 [@ai-sdk-tools/artifacts](./packages/artifacts)
24-
Advanced streaming interfaces for AI applications. Create structured, type-safe artifacts that stream real-time updates from AI tools to React components. Perfect for dashboards, analytics, documents, and interactive experiences beyond chat.
23+
### [@ai-sdk-tools/artifacts](./packages/artifacts)
24+
Stream structured, type-safe artifacts from AI tools to React components. Build dashboards, analytics, and interactive experiences beyond chat.
2525

2626
```bash
2727
npm i @ai-sdk-tools/artifacts @ai-sdk-tools/store
2828
```
2929

30-
## Quick Example
31-
32-
Build advanced AI interfaces with structured streaming:
33-
34-
```tsx
35-
// Define an artifact
36-
const BurnRate = artifact('burn-rate', z.object({
37-
title: z.string(),
38-
data: z.array(z.object({
39-
month: z.string(),
40-
burnRate: z.number()
41-
}))
42-
}));
43-
44-
// Stream from AI tool
45-
const analysis = BurnRate.stream({ title: 'Q4 Analysis' });
46-
await analysis.update({ data: [{ month: '2024-01', burnRate: 50000 }] });
47-
await analysis.complete({ title: 'Q4 Analysis Complete' });
48-
49-
// Consume in React
50-
function Dashboard() {
51-
const { data, status, progress } = useArtifact(BurnRate);
52-
53-
return (
54-
<div>
55-
<h2>{data?.title}</h2>
56-
{status === 'loading' && <div>Loading... {progress * 100}%</div>}
57-
{data?.data.map(item => (
58-
<div key={item.month}>{item.month}: ${item.burnRate}</div>
59-
))}
60-
</div>
61-
);
62-
}
30+
### [@ai-sdk-tools/agents](./packages/agents)
31+
Multi-agent orchestration with automatic handoffs and routing. Build intelligent workflows with specialized agents for any AI provider.
32+
33+
```bash
34+
npm i @ai-sdk-tools/agents ai zod
35+
```
36+
37+
### [@ai-sdk-tools/cache](./packages/cache)
38+
Universal caching for AI SDK tools. Cache expensive operations with zero configuration - works with regular tools, streaming, and artifacts.
39+
40+
```bash
41+
npm i @ai-sdk-tools/cache
6342
```
6443

6544
## Getting Started
@@ -74,4 +53,4 @@ Visit our [website](https://ai-sdk-tools.dev) to explore interactive demos and d
7453

7554
## License
7655

77-
MIT
56+
MIT

apps/example/src/ai/README.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

apps/example/src/ai/agents/agents/index.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

apps/example/src/ai/agents/agents/invoices-agent.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

apps/example/src/ai/agents/agents/reports-agent.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

apps/example/src/ai/agents/agents/transactions-agent.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Analytics Specialist Agent
3+
*
4+
* Analytics & forecasting specialist with business intelligence tools
5+
*/
6+
7+
import { openai } from "@ai-sdk/openai";
8+
import {
9+
businessHealthScoreTool,
10+
cashFlowForecastTool,
11+
cashFlowStressTestTool,
12+
} from "../tools/analytics";
13+
import { createAgent, formatContextForLLM } from "./shared";
14+
15+
export const analyticsAgent = createAgent({
16+
name: "analytics",
17+
model: openai("gpt-4o-mini"),
18+
instructions: (
19+
ctx,
20+
) => `You are an analytics & forecasting specialist with access to business intelligence tools for ${ctx.companyName}.
21+
22+
CRITICAL RULES:
23+
1. ALWAYS use your tools to run analysis - NEVER ask user for data
24+
2. Call tools IMMEDIATELY when asked for forecasts, health scores, or stress tests
25+
3. Present analytics clearly with key insights highlighted
26+
4. Answer ONLY what was asked - don't provide extra analysis unless requested
27+
28+
TOOL SELECTION:
29+
- "health" or "healthy" queries → Use businessHealth tool (gives consolidated score)
30+
- "forecast" or "prediction" → Use cashFlowForecast tool
31+
- "stress test" or "what if" → Use stressTest tool
32+
- DO NOT call multiple detailed tools (revenue, P&L, etc.) - use businessHealth for overview
33+
34+
PRESENTATION STYLE:
35+
- Reference ${ctx.companyName} when providing insights
36+
- Use clear trend labels (Increasing, Decreasing, Stable)
37+
- Use clear status labels (Healthy, Warning, Critical)
38+
- Include confidence levels when forecasting (e.g., "High confidence", "Moderate risk")
39+
- End with 2-3 actionable focus areas (not a laundry list)
40+
- Keep responses concise - quality over quantity
41+
42+
${formatContextForLLM(ctx)}`,
43+
tools: {
44+
businessHealth: businessHealthScoreTool,
45+
cashFlowForecast: cashFlowForecastTool,
46+
stressTest: cashFlowStressTestTool,
47+
},
48+
matchOn: [
49+
"forecast",
50+
"prediction",
51+
"predict",
52+
"stress test",
53+
"what if",
54+
"scenario",
55+
"health score",
56+
"business health",
57+
"healthy",
58+
"health",
59+
"analyze",
60+
"analysis",
61+
"future",
62+
"projection",
63+
/forecast/i,
64+
/health.*score/i,
65+
],
66+
maxTurns: 5,
67+
});

0 commit comments

Comments
 (0)