diff --git a/servers/fastapi/openai_spec.json b/servers/fastapi/openai_spec.json index 4a9e5e08..b226c5e4 100644 --- a/servers/fastapi/openai_spec.json +++ b/servers/fastapi/openai_spec.json @@ -79,9 +79,10 @@ "schemas": { "Body_generate_presentation_api_api_v1_ppt_presentation_generate_post": { "properties": { - "prompt": { + "content": { "type": "string", - "title": "Prompt" + "title": "Content", + "description": "The content for generating the presentation" }, "n_slides": { "type": "integer", @@ -121,7 +122,7 @@ } }, "type": "object", - "required": ["prompt"], + "required": ["content"], "title": "Body_generate_presentation_api_api_v1_ppt_presentation_generate_post" }, "PresentationPathAndEditPath": { diff --git a/servers/fastapi/tests/test_presentation_generation_api.py b/servers/fastapi/tests/test_presentation_generation_api.py index 5e5f9be5..3806dc61 100644 --- a/servers/fastapi/tests/test_presentation_generation_api.py +++ b/servers/fastapi/tests/test_presentation_generation_api.py @@ -123,7 +123,7 @@ class TestPresentationGenerationAPI: response = client.post( "/api/v1/ppt/presentation/generate", json={ - "prompt": "Create a presentation about artificial intelligence and machine learning", + "content": "Create a presentation about artificial intelligence and machine learning", "n_slides": 5, "language": "English", "export_as": "pdf", @@ -138,7 +138,7 @@ class TestPresentationGenerationAPI: response = client.post( "/api/v1/ppt/presentation/generate", json={ - "prompt": "Create a presentation about artificial intelligence and machine learning", + "content": "Create a presentation about artificial intelligence and machine learning", "n_slides": 5, "language": "English", "export_as": "pptx", @@ -149,7 +149,7 @@ class TestPresentationGenerationAPI: assert "presentation_id" in response.json() assert "pptx" in response.json()["path"] - def test_generate_presentation_with_no_prompt(self, client): + def test_generate_presentation_with_no_content(self, client): response = client.post( "/api/v1/ppt/presentation/generate", json={ @@ -166,7 +166,7 @@ class TestPresentationGenerationAPI: response = client.post( "/api/v1/ppt/presentation/generate", json={ - "prompt": "Create a presentation about artificial intelligence and machine learning", + "content": "Create a presentation about artificial intelligence and machine learning", "n_slides": 0, "language": "English", "export_as": "pdf", @@ -179,7 +179,7 @@ class TestPresentationGenerationAPI: response = client.post( "/api/v1/ppt/presentation/generate", json={ - "prompt": "Create a presentation about artificial intelligence and machine learning", + "content": "Create a presentation about artificial intelligence and machine learning", "n_slides": 5, "language": "English", "export_as": "invalid_type", diff --git a/servers/fastapi/utils/process_slides.py b/servers/fastapi/utils/process_slides.py index 87aa3e21..b9ddb1de 100644 --- a/servers/fastapi/utils/process_slides.py +++ b/servers/fastapi/utils/process_slides.py @@ -51,7 +51,12 @@ async def process_slide_and_fetch_assets( for icon_path in icon_paths: icon_dict = get_dict_at_path(slide.content, icon_path) - icon_dict["__icon_url__"] = results.pop()[0] + icon_result = results.pop() + if icon_result and len(icon_result) > 0: + icon_dict["__icon_url__"] = icon_result[0] + else: + # Fallback to placeholder if no icon found + icon_dict["__icon_url__"] = "/static/icons/placeholder.svg" set_dict_at_path(slide.content, icon_path, icon_dict) return return_assets @@ -159,7 +164,12 @@ async def process_old_and_new_slides_and_fetch_assets( for i, new_icon in enumerate(new_icons): if new_icons_fetch_status[i]: - new_icon_dicts[i]["__icon_url__"] = new_icons[i][0] + icon_result = new_icons[i] + if icon_result and len(icon_result) > 0: + new_icon_dicts[i]["__icon_url__"] = icon_result[0] + else: + # Fallback to placeholder if no icon found + new_icon_dicts[i]["__icon_url__"] = "/static/icons/placeholder.svg" for i, new_image_dict in enumerate(new_image_dicts): set_dict_at_path(new_slide_content, new_image_dict_paths[i], new_image_dict)