diff --git a/backend/app/main.py b/backend/app/main.py index 742a2a0..33420d2 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.3" +BACKEND_VERSION = "1.2.4" app = FastAPI(title="Checklist Inteligente API", version=BACKEND_VERSION) # S3/MinIO configuration @@ -3172,7 +3172,9 @@ NOTA: if ai_config.provider == "openai": import openai - openai.api_key = ai_config.api_key + + # Crear cliente de OpenAI + client = openai.OpenAI(api_key=ai_config.api_key) # Construir mensaje segĂșn si es PDF o imagen if is_pdf: @@ -3203,7 +3205,7 @@ NOTA: } ] - response = openai.ChatCompletion.create( + response = client.chat.completions.create( model=ai_config.model_name, messages=messages_content, max_tokens=500 @@ -3347,8 +3349,11 @@ Responde en formato JSON: "confidence": 0.0-1.0 }""" - response = openai.ChatCompletion.create( - model="gpt-4-vision-preview" if "gpt-4" in str(settings.OPENAI_API_KEY) else "gpt-4o", + # Crear cliente de OpenAI + client = openai.OpenAI(api_key=settings.OPENAI_API_KEY) + + response = client.chat.completions.create( + model="gpt-4o", messages=[ { "role": "system",