Auto-deploy: 2026-05-18 00:18:20
This commit is contained in:
@@ -24,18 +24,18 @@ async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText
|
|||||||
throw new Error('Daily limit reached (1,000 requests). Resets at midnight PT.');
|
throw new Error('Daily limit reached (1,000 requests). Resets at midnight PT.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate text
|
// Truncate text — 12k chars to fit list_analysis prompts
|
||||||
const maxChars = 6000;
|
const maxChars = 12000;
|
||||||
const trimmedPrompt = prompt && prompt.length > maxChars
|
const trimmedPrompt = prompt && prompt.length > maxChars
|
||||||
? prompt.substring(0, maxChars) + '\n\n[Truncated]'
|
? prompt.substring(0, maxChars) + '\n\n[Truncated]'
|
||||||
: prompt;
|
: prompt;
|
||||||
|
|
||||||
const MAX_RETRIES = 3;
|
const MAX_RETRIES = 3;
|
||||||
const RETRY_DELAYS = [2000, 20000, 30000];
|
const RETRY_DELAYS = [0, 15000, 30000]; // No delay on first attempt
|
||||||
let lastError = '';
|
let lastError = '';
|
||||||
|
|
||||||
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
||||||
await delay(RETRY_DELAYS[attempt]);
|
if (RETRY_DELAYS[attempt] > 0) await delay(RETRY_DELAYS[attempt]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('https://cv.intaleqapp.com/cv/server/generate_cv.php', {
|
const response = await fetch('https://cv.intaleqapp.com/cv/server/generate_cv.php', {
|
||||||
@@ -60,7 +60,8 @@ async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText
|
|||||||
} else {
|
} else {
|
||||||
const text = data.candidates?.[0]?.content?.parts?.[0]?.text;
|
const text = data.candidates?.[0]?.content?.parts?.[0]?.text;
|
||||||
if (!text) {
|
if (!text) {
|
||||||
lastError = 'Empty response from API.';
|
console.error('[LJA-BG] Empty text. Full response:', JSON.stringify(data).substring(0, 500));
|
||||||
|
lastError = 'Empty response from API. Server returned: ' + JSON.stringify(data).substring(0, 200);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
await incrementUsage();
|
await incrementUsage();
|
||||||
|
|||||||
@@ -48,9 +48,8 @@ if (empty($apiKey)) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $model = "gemini-flash-lite-latest";
|
// gemini-2.5-flash is required for reliable structured JSON output (list_analysis)
|
||||||
$model = "gemini-flash-lite-latest";
|
$model = "gemini-2.5-flash";
|
||||||
// $model = "gemini-2.5-flash";
|
|
||||||
$geminiUrl = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:generateContent?key=" . $apiKey;
|
$geminiUrl = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:generateContent?key=" . $apiKey;
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
|
|||||||
Reference in New Issue
Block a user