Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,25 +16,37 @@ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
| 16 |
|
| 17 |
# Función para obtener la respuesta del modelo Gemini
|
| 18 |
def get_gemini_response(product_service, target_audience, skills, formula_type, temperature, file_content="", image_parts=None):
|
| 19 |
-
# Check if at least
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
if not
|
| 25 |
-
return "Debes proporcionar al menos
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
formula = puv_formulas[formula_type]
|
| 28 |
|
| 29 |
-
# Adjust prompt based on what's provided
|
| 30 |
-
business_info = f"Target Audience: {target_audience}\n"
|
| 31 |
-
|
| 32 |
-
if product_service:
|
| 33 |
-
business_info += f"Product/Service: {product_service}\n"
|
| 34 |
-
|
| 35 |
-
if skills:
|
| 36 |
-
business_info += f"My Skills/Expertise: {skills}\n"
|
| 37 |
-
|
| 38 |
# Add file content if available
|
| 39 |
reference_info = ""
|
| 40 |
if file_content:
|
|
|
|
| 16 |
|
| 17 |
# Función para obtener la respuesta del modelo Gemini
|
| 18 |
def get_gemini_response(product_service, target_audience, skills, formula_type, temperature, file_content="", image_parts=None):
|
| 19 |
+
# Check if we have at least one source of information
|
| 20 |
+
has_file_content = bool(file_content.strip())
|
| 21 |
+
has_image = image_parts is not None
|
| 22 |
+
has_text_input = target_audience or product_service or skills
|
| 23 |
+
|
| 24 |
+
if not (has_file_content or has_image or has_text_input):
|
| 25 |
+
return "Debes proporcionar al menos un tipo de información: público objetivo, producto/servicio, habilidades o un archivo de referencia."
|
| 26 |
+
|
| 27 |
+
# If we only have file content but no other inputs, we can proceed
|
| 28 |
+
if (has_file_content or has_image) and not has_text_input:
|
| 29 |
+
# File-only mode
|
| 30 |
+
business_info = "Analyze the provided reference material to extract business information.\n"
|
| 31 |
+
else:
|
| 32 |
+
# Regular mode with validation
|
| 33 |
+
if not target_audience:
|
| 34 |
+
return "El campo de público objetivo es obligatorio cuando no se proporciona un archivo de referencia completo."
|
| 35 |
+
|
| 36 |
+
if not product_service and not skills:
|
| 37 |
+
return "Debes proporcionar al menos tu producto/servicio o tus habilidades cuando no se proporciona un archivo de referencia completo."
|
| 38 |
+
|
| 39 |
+
# Adjust prompt based on what's provided
|
| 40 |
+
business_info = f"Target Audience: {target_audience}\n"
|
| 41 |
+
|
| 42 |
+
if product_service:
|
| 43 |
+
business_info += f"Product/Service: {product_service}\n"
|
| 44 |
+
|
| 45 |
+
if skills:
|
| 46 |
+
business_info += f"My Skills/Expertise: {skills}\n"
|
| 47 |
|
| 48 |
formula = puv_formulas[formula_type]
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# Add file content if available
|
| 51 |
reference_info = ""
|
| 52 |
if file_content:
|