fixes info page display for gemini flash/ultra

This commit is contained in:
nai-degen 2024-08-03 22:18:05 -05:00
parent 2f7315379c
commit 29ed07492e
3 changed files with 10 additions and 13 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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": {