From ecd80f741c488e7fc35ca76870f3be321563ec7c Mon Sep 17 00:00:00 2001 From: Fayland Lam Date: Tue, 28 Mar 2023 09:50:58 +0800 Subject: [PATCH] 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? --- routes.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/routes.js b/routes.js index 15d93c9..6671989 100644 --- a/routes.js +++ b/routes.js @@ -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 }; \ No newline at end of file +export { completions, chatCompletions };