-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.ts
38 lines (32 loc) · 1.21 KB
/
index.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
import { Plugin } from "../base";
import { PluginManifest } from "../types";
import { BrowserAgent } from "./agent";
export class Browser extends Plugin {
static manifest: PluginManifest = {
schema_version: "1.0",
name_for_human: "Browsing",
name_for_model: "Browsing",
description_for_human: "Browsing",
description_for_model: `This plugin allows you to browse the web. To use it, you can use the following actions:
- \`start: [prompt: string]\`: Browse the web in search of an answer to the given prompt
If the user asks you for web content that you don't know, you should not hestitate to use this plugin to retrieve it. If you would ask the user whether they would like you to check the web for the answer, you should assume YES and use this plugin to do so.`,
auth: {
type: "none",
},
logo_url: "",
};
constructor() {
super(Browser.manifest);
}
async run(action: string, input: string) {
if (action !== "start") {
throw new Error("Unknown action " + action);
}
const browserAgent = new BrowserAgent();
await browserAgent.run(input);
return {
name: this.manifest.name_for_model,
output: browserAgent.messages[-1]?.content,
};
}
}