maybe fixes openai sk-svcacct keys

This commit is contained in:
nai-degen 2024-09-12 23:05:43 -05:00
parent 6a908b09cb
commit f1cfa644c5
3 changed files with 3 additions and 2 deletions

View File

@ -71,7 +71,7 @@ export const addKey: HPMRequestCallback = (proxyReq, req) => {
break; break;
case "openai": case "openai":
const key: OpenAIKey = assignedKey as OpenAIKey; const key: OpenAIKey = assignedKey as OpenAIKey;
if (key.organizationId) { if (key.organizationId && !key.key.includes("svcacct")) {
proxyReq.setHeader("OpenAI-Organization", key.organizationId); proxyReq.setHeader("OpenAI-Organization", key.organizationId);
} }
proxyReq.setHeader("Authorization", `Bearer ${assignedKey.key}`); proxyReq.setHeader("Authorization", `Bearer ${assignedKey.key}`);

View File

@ -26,7 +26,7 @@ const handleModelRequest: RequestHandler = (_req, res) => {
if (new Date().getTime() - modelListValid < 1000 * 60) { if (new Date().getTime() - modelListValid < 1000 * 60) {
return res.status(200).json(modelListCache); return res.status(200).json(modelListCache);
} }
const result = generateModelList().filter((m: { id: string }) => const result = generateModelList("openai").filter((m: { id: string }) =>
KNOWN_MODELS.includes(m.id) KNOWN_MODELS.includes(m.id)
); );
modelListCache = { object: "list", data: result }; modelListCache = { object: "list", data: result };

View File

@ -343,6 +343,7 @@ export class OpenAIKeyProvider implements KeyProvider<OpenAIKey> {
key.rateLimitedAt = Date.now(); key.rateLimitedAt = Date.now();
key.rateLimitRequestsReset = KEY_REUSE_DELAY; key.rateLimitRequestsReset = KEY_REUSE_DELAY;
key.rateLimitedUntil = Date.now() + KEY_REUSE_DELAY;
} }
} }