This commit is contained in:
nai-degen
2023-05-13 00:58:15 +00:00
parent 5238aff378
commit 977247d7a2
14 changed files with 642 additions and 35 deletions
+4
View File
@@ -9,6 +9,7 @@ import { keyPool } from "../../../key-management";
import { buildFakeSseMessage, enqueue, trackWaitTime } from "../../queue";
import { handleStreamedResponse } from "./handle-streamed-response";
import { logPrompt } from "./log-prompt";
import { incrementPromptCount } from "../../auth/user-store";
export const QUOTA_ROUTES = ["/v1/chat/completions"];
const DECODER_MAP = {
@@ -369,6 +370,9 @@ export const handleInternalError: httpProxy.ErrorCallback = (
const incrementKeyUsage: ProxyResHandlerWithBody = async (_proxyRes, req) => {
if (QUOTA_ROUTES.includes(req.path)) {
keyPool.incrementPrompt(req.key?.hash);
if (req.user) {
incrementPromptCount(req.user.token);
}
}
};