Auto-deploy: 2026-05-17 23:23:33

This commit is contained in:
Hamza-Ayed
2026-05-17 23:23:33 +03:00
parent 3ac8260c1d
commit 9bf1406796

View File

@@ -1057,20 +1057,24 @@ Brief honest assessment of this opportunity for my profile`
if (!response.ok) throw new Error('API Request failed');
const data = await response.json();
if (!data.candidates || !data.candidates[0].content) {
throw new Error('API blocked or returned empty response.');
}
let resultText = data.candidates[0].content.parts[0].text;
resultText = resultText.replace(/```json/g, '').replace(/```/g, '').trim();
resultText = resultText.replace(/```json/gi, '').replace(/```/g, '').trim();
let results;
try {
const match = resultText.match(/\[[\s\S]*\]/);
if (match) {
results = JSON.parse(match[0]);
const startIdx = resultText.indexOf('[');
const endIdx = resultText.lastIndexOf(']');
if (startIdx !== -1 && endIdx !== -1) {
results = JSON.parse(resultText.substring(startIdx, endIdx + 1));
} else {
results = JSON.parse(resultText);
}
} catch(e) {
console.error(resultText);
throw new Error('Failed to parse AI response');
console.error("AI JSON Parse Error. Raw Response:", resultText);
throw new Error('JSON Error: ' + resultText.substring(0, 80));
}
results.forEach(res => {