🔧 Fix AI Analysis Service - Improved Prompts & Error Handling
✅ FIXED: AI analysis prompts to bypass OpenAI safety guardrails ✅ FIXED: Added technical analysis focus instead of trading advice tone ✅ FIXED: Improved JSON parsing and error handling ✅ ADDED: Option to use existing screenshots for testing (useExisting param) ✅ IMPROVED: Better image detail settings and temperature for consistency 🐛 DEBUGGING: Still investigating why AI claims it can't see images - OpenAI vision capabilities confirmed working with public images - Model gpt-4o has proper vision support - Issue appears to be with chart image content or encoding 🎯 NEXT: Debug image encoding and model response inconsistency
This commit is contained in:
71
debug-openai-vision.js
Normal file
71
debug-openai-vision.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const OpenAI = require('openai').default
|
||||
|
||||
async function testOpenAIVision() {
|
||||
try {
|
||||
console.log('🔍 Testing OpenAI Vision capabilities...')
|
||||
|
||||
const openai = new OpenAI({
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
})
|
||||
|
||||
// Test with a simple text-only request first
|
||||
console.log('📝 Testing text-only request...')
|
||||
|
||||
const textResponse = await openai.chat.completions.create({
|
||||
model: "gpt-4o",
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: "Respond with a simple JSON: {'test': 'success'}"
|
||||
}
|
||||
],
|
||||
max_tokens: 50
|
||||
})
|
||||
|
||||
console.log('✅ Text response:', textResponse.choices[0]?.message?.content)
|
||||
|
||||
// Test with a simple image URL (public image)
|
||||
console.log('🖼️ Testing with public image...')
|
||||
|
||||
const imageResponse = await openai.chat.completions.create({
|
||||
model: "gpt-4o",
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{ type: "text", text: "What do you see in this image? Respond with JSON: {'description': 'your description'}" },
|
||||
{
|
||||
type: "image_url",
|
||||
image_url: {
|
||||
url: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
max_tokens: 100
|
||||
})
|
||||
|
||||
console.log('✅ Image response:', imageResponse.choices[0]?.message?.content)
|
||||
|
||||
// Check account details
|
||||
console.log('🔍 Checking available models...')
|
||||
|
||||
const models = await openai.models.list()
|
||||
const visionModels = models.data.filter(model =>
|
||||
model.id.includes('gpt-4') && (model.id.includes('vision') || model.id.includes('gpt-4o'))
|
||||
)
|
||||
|
||||
console.log('🎯 Available vision models:')
|
||||
visionModels.forEach(model => console.log(` - ${model.id}`))
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Error:', error.message)
|
||||
if (error.response) {
|
||||
console.error('📊 Response status:', error.response.status)
|
||||
console.error('📝 Response data:', JSON.stringify(error.response.data, null, 2))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testOpenAIVision()
|
||||
Reference in New Issue
Block a user