-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
32 lines (22 loc) · 802 Bytes
/
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
/* eslint no-use-before-define: 0 */
import * as functions from "firebase-functions";
import OpenAI from "openai";
// import {getStorage} from "firebase-admin/storage";
// import * as cors from "cors";
// const corsHandler = cors({origin: true});
const openai = new OpenAI({
organization: "org-1j559n72fko7IZSsTd5gtAAm",
apiKey: "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",
});
//
// eslint-disable-next-line max-len
export const openAIHttpFunctionSec = functions.https.onCall(async (data, response) => {
const quest = data.name;
const openAPIResponse = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{"role": "user", "content": `${quest}`}],
temperature: 0,
});
return {"data": openAPIResponse};
});
// params?.query?.toString()