Update routes.js

you set API_KEYS = ["a", "b"]; so here it should be just key. hmm, did you really test your code? I have it running but so many bugs?
This commit is contained in:
Fayland Lam
2023-03-28 09:50:58 +08:00
committed by GitHub
parent 9669484fe0
commit ecd80f741c
+7 -7
View File
@@ -19,7 +19,7 @@ async function completions(req, res) {
if (MODERATION) {
try {
let openAi = new OpenAIApi(new Configuration({ apiKey: key.apikey }));
let openAi = new OpenAIApi(new Configuration({ apiKey: key }));
let response = await openAi.createModeration({
input: req.body.prompt,
});
@@ -48,7 +48,7 @@ async function completions(req, res) {
headers: {
Accept: "text/event-stream",
"Content-Type": "application/json",
Authorization: `Bearer ${key.apikey}`,
Authorization: `Bearer ${key}`,
},
},
);
@@ -106,7 +106,7 @@ async function completions(req, res) {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${key.apikey}`,
Authorization: `Bearer ${key}`,
},
},
);
@@ -152,7 +152,7 @@ async function chatCompletions(req, res) {
});
}
let openAi = new OpenAIApi(new Configuration({ apiKey: key.apikey }));
let openAi = new OpenAIApi(new Configuration({ apiKey: key }));
let response = await openAi.createModeration({
input: prompt,
});
@@ -181,7 +181,7 @@ async function chatCompletions(req, res) {
headers: {
Accept: "text/event-stream",
"Content-Type": "application/json",
Authorization: `Bearer ${key.apikey}`,
Authorization: `Bearer ${key}`,
},
},
);
@@ -242,7 +242,7 @@ async function chatCompletions(req, res) {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${key.apikey}`,
Authorization: `Bearer ${key}`,
},
},
);
@@ -267,4 +267,4 @@ async function chatCompletions(req, res) {
}
}
export { completions, chatCompletions };
export { completions, chatCompletions };