✅ Solucionado
El error ocurría porque faltaba el caso de Anthropic en la función de análisis de imágenes. Ahora Anthropic Claude puede: Analizar imágenes con vision Analizar documentos PDF Usar el formato correcto de mensajes con system separado Backend actualizado a v1.2.2
This commit is contained in:
@@ -276,7 +276,7 @@ def extract_pdf_text_smart(pdf_content: bytes, max_chars: int = None) -> dict:
|
||||
}
|
||||
|
||||
|
||||
BACKEND_VERSION = "1.2.1"
|
||||
BACKEND_VERSION = "1.2.2"
|
||||
app = FastAPI(title="Checklist Inteligente API", version=BACKEND_VERSION)
|
||||
|
||||
# S3/MinIO configuration
|
||||
@@ -3211,6 +3211,53 @@ NOTA:
|
||||
|
||||
ai_response = response.choices[0].message.content
|
||||
|
||||
elif ai_config.provider == "anthropic":
|
||||
import anthropic
|
||||
|
||||
client = anthropic.Anthropic(api_key=ai_config.api_key)
|
||||
|
||||
if is_pdf:
|
||||
# Para PDF, solo texto
|
||||
response = client.messages.create(
|
||||
model=ai_config.model_name or "claude-sonnet-4-5",
|
||||
max_tokens=500,
|
||||
system=system_prompt,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"{user_message}\n\n--- CONTENIDO DEL DOCUMENTO PDF ({len(pdf_text)} caracteres) ---\n{pdf_text[:100000]}"
|
||||
}
|
||||
]
|
||||
)
|
||||
else:
|
||||
# Para imagen, usar vision
|
||||
response = client.messages.create(
|
||||
model=ai_config.model_name or "claude-sonnet-4-5",
|
||||
max_tokens=500,
|
||||
system=system_prompt,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": user_message
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"source": {
|
||||
"type": "base64",
|
||||
"media_type": "image/jpeg",
|
||||
"data": image_b64
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
ai_response = response.content[0].text
|
||||
|
||||
elif ai_config.provider == "gemini":
|
||||
import google.generativeai as genai
|
||||
from PIL import Image
|
||||
|
||||
@@ -1953,6 +1953,7 @@ function QuestionsManagerModal({ checklist, onClose }) {
|
||||
{formData.photo_requirement === 'required' && '• El mecánico DEBE adjuntar al menos 1 archivo'}
|
||||
</p>
|
||||
</div>
|
||||
{formData.photo_requirement !== 'none' && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
Máx. archivos
|
||||
@@ -1964,12 +1965,12 @@ function QuestionsManagerModal({ checklist, onClose }) {
|
||||
value={formData.max_photos}
|
||||
onChange={(e) => setFormData({ ...formData, max_photos: parseInt(e.target.value) })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500"
|
||||
disabled={formData.photo_requirement === 'none'}
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">
|
||||
Cantidad máxima de fotos/PDFs permitidos
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user