Merge pull request #11 from fayland/patch-2

Update routes.js
This commit is contained in:
Pawan Osman
2023-03-28 10:21:07 +03:00
committed by GitHub
+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 };