Fix login restriction handling and improve AI analysis debugging
- Add proper handling when layouts are private/restricted even with login - Force re-authentication when restriction is detected without user menu - Fall back to base chart when layouts are inaccessible - Add detailed logging to AI analysis service to debug JSON parsing issues - Log full AI response content and extracted JSON for troubleshooting This should fix both the login restriction bypass and AI analysis failures.
This commit is contained in:
@@ -184,16 +184,22 @@ Be concise but thorough. Only return valid JSON.`
|
||||
throw new Error('No content received from OpenAI')
|
||||
}
|
||||
|
||||
console.log('AI response content:', content)
|
||||
|
||||
// Parse the JSON response
|
||||
const jsonMatch = content.match(/\{[\s\S]*\}/)
|
||||
if (!jsonMatch) {
|
||||
console.error('No JSON found in response. Full content:', content)
|
||||
throw new Error('No JSON found in response')
|
||||
}
|
||||
|
||||
console.log('Extracted JSON:', jsonMatch[0])
|
||||
|
||||
const analysis = JSON.parse(jsonMatch[0])
|
||||
|
||||
// Validate the structure
|
||||
if (!analysis.summary || !analysis.marketSentiment || !analysis.recommendation || !analysis.confidence) {
|
||||
console.error('Invalid analysis structure:', analysis)
|
||||
throw new Error('Invalid analysis structure')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user