-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchatgpt.ts
37 lines (33 loc) · 977 Bytes
/
chatgpt.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
/*
import { Handler, Context, Callback } from "aws-lambda";
import ChatGPTplugin from "./src/chatgpt/plugin";
const CHATGPT_TOKEN = process.env.CHATGPT_TOKEN!;
const CHATGPTPLUGINAUTH = process.env.CHATGPTPLUGINAUTH!;
const plugin: Handler = async (
event: any,
context: Context,
callback: Callback,
) => {
try {
console.log("event", event);
//const body = JSON.parse(event.body);
console.log("ChatGPT request to plugin:", event);
let result: string = "Authentification failed";
if (event && event.auth && event.auth === CHATGPTPLUGINAUTH) {
const plugin = new ChatGPTplugin(CHATGPT_TOKEN);
result = await plugin.activate(event);
}
callback(null, {
statusCode: 200,
body: result,
});
} catch (error) {
console.error("catch", (<any>error).toString());
callback(null, {
statusCode: 200,
body: "Nulla osta ChatGPT plugin error, please try again later",
});
}
};
export { plugin };
*/