Skip to content

Commit 431d8c7

Browse files
committed
Plot Activity intents now take an object that can include examples
1 parent 628ff3f commit 431d8c7

5 files changed

Lines changed: 41 additions & 10 deletions

File tree

.changeset/cool-candles-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/agent": minor
3+
---
4+
5+
Changed: BREAKING: Plot Activity intents now take an object that can include examples

agents/chat/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"private": true,
1111
"scripts": {
1212
"deploy": "plot deploy",
13-
"lint": "plot lint"
13+
"lint": "plot lint",
14+
"logs": "plot logs"
1415
},
1516
"dependencies": {
1617
"@plotday/agent": "workspace:^",

agents/chat/src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ export default class ChatAgent extends Agent<ChatAgent> {
1818
plot: build(Plot, {
1919
activity: {
2020
access: ActivityAccess.Respond,
21-
intents: {
22-
"Respond to general questions and requests": this.responsd,
23-
},
21+
intents: [{
22+
description: "Respond to general questions and requests",
23+
examples: [
24+
"What's the weather like?",
25+
"Can you help me plan my day?",
26+
"Write me a summary of this article"
27+
],
28+
handler: this.responsd,
29+
}],
2430
},
2531
}),
2632
};

builder/src/plot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ export type Activity = {
319319
*/
320320
export type NewActivity = Pick<Activity, "type"> &
321321
Partial<
322-
Omit<Activity, "id" | "author" | "type" | "parent"> & {
322+
Omit<Activity, "id" | "author" | "type" | "parent" | "priority"> & {
323323
parent?: Pick<Activity, "id"> | null;
324+
priority?: Pick<Priority, "id">;
324325
}
325326
>;
326327

builder/src/tools/plot.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ export enum ContactAccess {
4545
Write,
4646
}
4747

48+
/**
49+
* Intent handler for activity mentions.
50+
* Defines how the agent should respond when mentioned in an activity.
51+
*/
52+
export type ActivityIntentHandler = {
53+
/** Human-readable description of what this intent handles */
54+
description: string;
55+
/** Example phrases or activity content that would match this intent */
56+
examples: string[];
57+
/** The function to call when this intent is matched */
58+
handler: (activity: Activity) => Promise<void>;
59+
};
60+
4861
/**
4962
* Built-in tool for interacting with the core Plot data layer.
5063
*
@@ -107,13 +120,18 @@ export abstract class Plot extends ITool {
107120
*
108121
* @example
109122
* ```typescript
110-
* intents: {
111-
* "Schedule or reschedule calendar events": this.onSchedulingRequest,
112-
* "Find available meeting times": this.onAvailabilityRequest
113-
* }
123+
* intents: [{
124+
* description: "Schedule or reschedule calendar events",
125+
* examples: ["Schedule a meeting tomorrow at 2pm", "Move my 3pm meeting to 4pm"],
126+
* handler: this.onSchedulingRequest
127+
* }, {
128+
* description: "Find available meeting times",
129+
* examples: ["When am I free this week?", "Find time for a 1 hour meeting"],
130+
* handler: this.onAvailabilityRequest
131+
* }]
114132
* ```
115133
*/
116-
intents?: Record<string, (activity: Activity) => Promise<void>>;
134+
intents?: ActivityIntentHandler[];
117135
};
118136
priority?: {
119137
access?: PriorityAccess;

0 commit comments

Comments
 (0)