From 14d50271704de5dc2c62c712de6f84c1d1631b14 Mon Sep 17 00:00:00 2001
From: ronalds
Date: Thu, 4 Dec 2025 14:01:58 -0300
Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Solucionado?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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
---
backend/app/main.py | 49 +++++++++++++++++++++++++++++++++++++++++++-
frontend/src/App.jsx | 35 ++++++++++++++++---------------
2 files changed, 66 insertions(+), 18 deletions(-)
diff --git a/backend/app/main.py b/backend/app/main.py
index 29c6eb4..1770124 100644
--- a/backend/app/main.py
+++ b/backend/app/main.py
@@ -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
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 30fffe1..a8f01d9 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -1953,23 +1953,24 @@ function QuestionsManagerModal({ checklist, onClose }) {
{formData.photo_requirement === 'required' && '• El mecánico DEBE adjuntar al menos 1 archivo'}
-
-
-
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'}
- />
-
- Cantidad máxima de fotos/PDFs permitidos
-
-
+ {formData.photo_requirement !== 'none' && (
+
+
+
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"
+ />
+
+ Cantidad máxima de fotos/PDFs permitidos
+
+
+ )}