diff --git a/src/proxy/middleware/request/preprocessors/validate-context-size.ts b/src/proxy/middleware/request/preprocessors/validate-context-size.ts index c1003a2..602b439 100644 --- a/src/proxy/middleware/request/preprocessors/validate-context-size.ts +++ b/src/proxy/middleware/request/preprocessors/validate-context-size.ts @@ -81,7 +81,7 @@ export const validateContextSize: RequestPreprocessor = async (req) => { modelMax = 200000; } else if (model.match(/^claude-3/)) { modelMax = 200000; - } else if (model.match(/^gemini-\d{3}$/)) { + } else if (model.match(/^gemini-$/)) { modelMax = 1024000; } else if (model.match(/^anthropic\.claude-3/)) { modelMax = 200000; diff --git a/src/proxy/middleware/response/error-generator.ts b/src/proxy/middleware/response/error-generator.ts index f7af930..4c39445 100644 --- a/src/proxy/middleware/response/error-generator.ts +++ b/src/proxy/middleware/response/error-generator.ts @@ -143,8 +143,6 @@ export function sendErrorToClient({ res.setHeader("x-oai-proxy-error-status", redactedOpts.statusCode || 500); } - req.log.info({ statusCode: res.statusCode, isStreaming, format, redactedOpts, event }, "Sending error response"); - if (isStreaming) { if (!res.headersSent) { initializeSseStream(res); @@ -222,19 +220,16 @@ export function buildSpoofedCompletion({ stop_sequence: null, }; case "google-ai": - // TODO: Native Google AI non-streaming responses are not supported, this - // is an untested guess at what the response should look like. return { candidates: [ { - content: { parts: [{ text: content }], role: "assistant" }, + content: { parts: [{ text: content }], role: "model" }, finishReason: title, index: 0, tokenCount: null, safetyRatings: [], }, ], - usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }, }; case "openai-image": return obj; diff --git a/src/service-info.ts b/src/service-info.ts index a159eca..ea62d58 100644 --- a/src/service-info.ts +++ b/src/service-info.ts @@ -363,12 +363,14 @@ function addKeyToAggregates(k: KeyPoolKey) { } case "google-ai": { if (!keyIsGoogleAIKey(k)) throw new Error("Invalid key type"); - const family = "gemini-pro"; - sumTokens += k["gemini-proTokens"]; - sumCost += getTokenCostUsd(family, k["gemini-proTokens"]); - increment(modelStats, `${family}__active`, k.isDisabled ? 0 : 1); - increment(modelStats, `${family}__revoked`, k.isRevoked ? 1 : 0); - increment(modelStats, `${family}__tokens`, k["gemini-proTokens"]); + k.modelFamilies.forEach((family) => { + const tokens = k[`${family}Tokens`]; + sumTokens += tokens; + sumCost += getTokenCostUsd(family, tokens); + increment(modelStats, `${family}__tokens`, tokens); + increment(modelStats, `${family}__active`, k.isDisabled ? 0 : 1); + increment(modelStats, `${family}__revoked`, k.isRevoked ? 1 : 0); + }); break; } case "mistral-ai": {