Spaces:
Running
Running
log free requests
Browse files- app/api/ask-ai/route.ts +5 -3
app/api/ask-ai/route.ts
CHANGED
|
@@ -64,8 +64,6 @@ export async function POST(request: NextRequest) {
|
|
| 64 |
token = process.env.HF_TOKEN;
|
| 65 |
}
|
| 66 |
|
| 67 |
-
console.log(request.headers);
|
| 68 |
-
|
| 69 |
const ip = authHeaders.get("x-forwarded-for")?.includes(",")
|
| 70 |
? authHeaders.get("x-forwarded-for")?.split(",")[1].trim()
|
| 71 |
: authHeaders.get("x-forwarded-for");
|
|
@@ -87,6 +85,8 @@ export async function POST(request: NextRequest) {
|
|
| 87 |
billTo = "huggingface";
|
| 88 |
}
|
| 89 |
|
|
|
|
|
|
|
| 90 |
const DEFAULT_PROVIDER = PROVIDERS.novita;
|
| 91 |
const selectedProvider =
|
| 92 |
provider === "auto"
|
|
@@ -202,7 +202,7 @@ export async function POST(request: NextRequest) {
|
|
| 202 |
);
|
| 203 |
}
|
| 204 |
} finally {
|
| 205 |
-
await writer
|
| 206 |
}
|
| 207 |
})();
|
| 208 |
|
|
@@ -252,6 +252,8 @@ export async function PUT(request: NextRequest) {
|
|
| 252 |
? authHeaders.get("x-forwarded-for")?.split(",")[1].trim()
|
| 253 |
: authHeaders.get("x-forwarded-for");
|
| 254 |
|
|
|
|
|
|
|
| 255 |
if (!token) {
|
| 256 |
ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
|
| 257 |
if (ipAddresses.get(ip) > MAX_REQUESTS_PER_IP) {
|
|
|
|
| 64 |
token = process.env.HF_TOKEN;
|
| 65 |
}
|
| 66 |
|
|
|
|
|
|
|
| 67 |
const ip = authHeaders.get("x-forwarded-for")?.includes(",")
|
| 68 |
? authHeaders.get("x-forwarded-for")?.split(",")[1].trim()
|
| 69 |
: authHeaders.get("x-forwarded-for");
|
|
|
|
| 85 |
billTo = "huggingface";
|
| 86 |
}
|
| 87 |
|
| 88 |
+
console.log(ipAddresses);
|
| 89 |
+
|
| 90 |
const DEFAULT_PROVIDER = PROVIDERS.novita;
|
| 91 |
const selectedProvider =
|
| 92 |
provider === "auto"
|
|
|
|
| 202 |
);
|
| 203 |
}
|
| 204 |
} finally {
|
| 205 |
+
await writer?.close();
|
| 206 |
}
|
| 207 |
})();
|
| 208 |
|
|
|
|
| 252 |
? authHeaders.get("x-forwarded-for")?.split(",")[1].trim()
|
| 253 |
: authHeaders.get("x-forwarded-for");
|
| 254 |
|
| 255 |
+
console.log(ipAddresses);
|
| 256 |
+
|
| 257 |
if (!token) {
|
| 258 |
ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
|
| 259 |
if (ipAddresses.get(ip) > MAX_REQUESTS_PER_IP) {
|