-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
create.ts
51 lines (46 loc) · 1.44 KB
/
create.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { CallbackManagerForToolRun } from "../../callbacks/manager.js";
import { GoogleCalendarBase, GoogleCalendarAgentParams } from "./base.js";
import { runCreateEvent } from "./commands/run-create-events.js";
import { CREATE_TOOL_DESCRIPTION } from "./descriptions.js";
/**
* @example
* ```typescript
* const googleCalendarCreateTool = new GoogleCalendarCreateTool({
* credentials: {
* clientEmail: process.env.GOOGLE_CALENDAR_CLIENT_EMAIL,
* privateKey: process.env.GOOGLE_CALENDAR_PRIVATE_KEY,
* calendarId: process.env.GOOGLE_CALENDAR_CALENDAR_ID,
* },
* scopes: [
* "https:
* "https:
* ],
* model: new ChatOpenAI({}),
* });
* const createInput = `Create a meeting with John Doe next Friday at 4pm - adding to the agenda of it the result of 99 + 99`;
* const createResult = await googleCalendarCreateTool.invoke({
* input: createInput,
* });
* console.log("Create Result", createResult);
* ```
*/
export class GoogleCalendarCreateTool extends GoogleCalendarBase {
name = "google_calendar_create";
description = CREATE_TOOL_DESCRIPTION;
constructor(fields: GoogleCalendarAgentParams) {
super(fields);
}
async _call(query: string, runManager?: CallbackManagerForToolRun) {
const auth = await this.getAuth();
const model = this.getModel();
return runCreateEvent(
query,
{
auth,
model,
calendarId: this.calendarId,
},
runManager
);
}
}