-
Notifications
You must be signed in to change notification settings - Fork 2k
/
view.ts
50 lines (44 loc) 路 1.35 KB
/
view.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
import { CallbackManagerForToolRun } from "@langchain/core/callbacks/manager";
import { GoogleCalendarBase, GoogleCalendarAgentParams } from "./base.js";
import { VIEW_TOOL_DESCRIPTION } from "./descriptions.js";
import { runViewEvents } from "./commands/run-view-events.js";
/**
* @example
* ```typescript
* const googleCalendarViewTool = new GoogleCalendarViewTool({
* 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 viewInput = `What meetings do I have this week?`;
* const viewResult = await googleCalendarViewTool.invoke({ input: viewInput });
* console.log("View Result", viewResult);
* ```
*/
export class GoogleCalendarViewTool extends GoogleCalendarBase {
name = "google_calendar_view";
description = VIEW_TOOL_DESCRIPTION;
constructor(fields: GoogleCalendarAgentParams) {
super(fields);
}
async _call(query: string, runManager?: CallbackManagerForToolRun) {
const auth = await this.getAuth();
const model = this.getModel();
return runViewEvents(
query,
{
auth,
model,
calendarId: this.calendarId,
},
runManager
);
}
}