exempt 'special' token type from context size limits

This commit is contained in:
nai-degen
2024-03-19 11:14:51 -05:00
parent e068edcf48
commit 3f9fd25004
5 changed files with 23 additions and 5 deletions
@@ -31,7 +31,10 @@ export const countPromptTokens: RequestPreprocessor = async (req) => {
}
case "anthropic-chat": {
req.outputTokens = req.body.max_tokens;
const prompt: AnthropicChatMessage[] = req.body.messages;
const prompt = {
system: req.body.system ?? "",
messages: req.body.messages,
};
result = await countTokens({ req, prompt, service });
break;
}
@@ -46,6 +46,11 @@ export const validateContextSize: RequestPreprocessor = async (req) => {
}
proxyMax ||= Number.MAX_SAFE_INTEGER;
if (req.user?.type === "special") {
req.log.debug("Special user, not enforcing proxy context limit.");
proxyMax = Number.MAX_SAFE_INTEGER;
}
let modelMax: number;
if (model.match(/gpt-3.5-turbo-16k/)) {
modelMax = 16384;
+1 -1
View File
@@ -370,7 +370,7 @@ async function handleAnthropicBadRequestError(
"Anthropic key has been disabled."
);
keyPool.disable(req.key!, "revoked");
errorPayload.proxy_note = `Assigned key has been disabled. ${error?.message}`;
errorPayload.proxy_note = `Assigned key has been disabled. (${error?.message})`;
return;
}