Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,7 @@ def get_inference_client():
|
|
| 14 |
|
| 15 |
def extract_and_clean_json(text):
|
| 16 |
try:
|
|
|
|
| 17 |
json_match = re.search(r'\{.*?\}', text, re.DOTALL)
|
| 18 |
if json_match:
|
| 19 |
json_str = json_match.group()
|
|
@@ -39,7 +40,6 @@ def extract_and_clean_json(text):
|
|
| 39 |
return None
|
| 40 |
|
| 41 |
def generate_presentation_content(topic, client):
|
| 42 |
-
# Dividir la solicitud en dos partes
|
| 43 |
prompt_part1 = f"""Crea una presentación de PowerPoint sobre el tema: {topic}.
|
| 44 |
Genera exactamente 5 diapositivas con la siguiente estructura:
|
| 45 |
1. Título de la presentación
|
|
@@ -198,6 +198,8 @@ def main():
|
|
| 198 |
file_name=f"{topic.replace(' ', '_')}_presentacion.pptx",
|
| 199 |
mime="application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
| 200 |
)
|
|
|
|
|
|
|
| 201 |
except Exception as e:
|
| 202 |
st.error(f"Ocurrió un error al generar la presentación: {str(e)}")
|
| 203 |
else:
|
|
@@ -205,4 +207,3 @@ def main():
|
|
| 205 |
|
| 206 |
if __name__ == "__main__":
|
| 207 |
main()
|
| 208 |
-
|
|
|
|
| 14 |
|
| 15 |
def extract_and_clean_json(text):
|
| 16 |
try:
|
| 17 |
+
# Extracción del JSON de la respuesta
|
| 18 |
json_match = re.search(r'\{.*?\}', text, re.DOTALL)
|
| 19 |
if json_match:
|
| 20 |
json_str = json_match.group()
|
|
|
|
| 40 |
return None
|
| 41 |
|
| 42 |
def generate_presentation_content(topic, client):
|
|
|
|
| 43 |
prompt_part1 = f"""Crea una presentación de PowerPoint sobre el tema: {topic}.
|
| 44 |
Genera exactamente 5 diapositivas con la siguiente estructura:
|
| 45 |
1. Título de la presentación
|
|
|
|
| 198 |
file_name=f"{topic.replace(' ', '_')}_presentacion.pptx",
|
| 199 |
mime="application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
| 200 |
)
|
| 201 |
+
else:
|
| 202 |
+
st.error("No se generó contenido de presentación válido.")
|
| 203 |
except Exception as e:
|
| 204 |
st.error(f"Ocurrió un error al generar la presentación: {str(e)}")
|
| 205 |
else:
|
|
|
|
| 207 |
|
| 208 |
if __name__ == "__main__":
|
| 209 |
main()
|
|
|