Skip to content

Commit

Permalink
Update routes.js
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
fayland authored Mar 28, 2023
1 parent 9669484 commit ecd80f7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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}`,
},
},
);
Expand Down Expand Up @@ -106,7 +106,7 @@ async function completions(req, res) {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${key.apikey}`,
Authorization: `Bearer ${key}`,
},
},
);
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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}`,
},
},
);
Expand Down Expand Up @@ -242,7 +242,7 @@ async function chatCompletions(req, res) {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${key.apikey}`,
Authorization: `Bearer ${key}`,
},
},
);
Expand All @@ -267,4 +267,4 @@ async function chatCompletions(req, res) {
}
}

export { completions, chatCompletions };
export { completions, chatCompletions };

0 comments on commit ecd80f7

Please sign in to comment.