Auto-deploy: 2026-05-17 01:43:14
This commit is contained in:
@@ -24,14 +24,6 @@ async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText
|
||||
throw new Error('Daily limit reached (1,000 requests). Resets at midnight PT.');
|
||||
}
|
||||
|
||||
// Check cache (keyed by tab + prompt hash)
|
||||
const cacheStr = prompt || jobDescription;
|
||||
const cacheKey = `cache_${tab}_${action}_${hashString(cacheStr)}`;
|
||||
const cached = await getCached(cacheKey);
|
||||
if (cached) {
|
||||
return cached; // returns either text object or pdf object
|
||||
}
|
||||
|
||||
// Truncate text
|
||||
const maxChars = 6000;
|
||||
const trimmedPrompt = prompt && prompt.length > maxChars
|
||||
@@ -63,9 +55,7 @@ async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText
|
||||
if (action === 'generatePdf') {
|
||||
if (!data.pdf) throw new Error('Empty PDF response from server.');
|
||||
await incrementUsage();
|
||||
const result = { pdf: data.pdf, filename: data.filename, fromCache: false };
|
||||
await setCached(cacheKey, result);
|
||||
return result;
|
||||
return { pdf: data.pdf, filename: data.filename, fromCache: false };
|
||||
} else {
|
||||
const text = data.candidates?.[0]?.content?.parts?.[0]?.text;
|
||||
if (!text) {
|
||||
@@ -73,9 +63,7 @@ async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText
|
||||
continue;
|
||||
}
|
||||
await incrementUsage();
|
||||
const result = { text, fromCache: false };
|
||||
await setCached(cacheKey, result);
|
||||
return result;
|
||||
return { text, fromCache: false };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user