create_ppt_task
Generate PowerPoint presentations using a template, content description, and optional features like speech notes, autofill, and image insertion. Track task progress and download the final PPT.
Instructions
创建PPT生成任务。
使用说明:
1. 在调用本工具前,必须先调用get_theme_list获取有效的template_id。
2. 工具会返回任务ID(sid),需用get_task_progress轮询查询进度。
3. 任务完成后,可从get_task_progress结果中获取PPT下载地址。
4. 需先设置环境变量AIPPT_APP_ID和AIPPT_API_SECRET。
参数:
- text: PPT生成的内容描述,用于生成PPT的主题和内容。
- template_id: PPT模板ID,需通过get_theme_list获取。
- author: PPT作者名称,将显示在生成的PPT中。
- is_card_note: 是否生成PPT演讲备注,True表示生成,False表示不生成。
- search: 是否联网搜索,True表示联网搜索补充内容,False表示不联网。
- is_figure: 是否自动配图,True表示自动配图,False表示不配图。
- ai_image: AI配图类型,仅在is_figure为True时生效。可选值:normal-普通配图(20%正文配图),advanced-高级配图(50%正文配图)。
返回:
成功时返回包含sid的字典,失败时抛出异常。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ai_image | No | normal | |
| author | No | XXXX | |
| is_card_note | No | ||
| is_figure | No | ||
| search | No | ||
| template_id | Yes | ||
| text | Yes |
Implementation Reference
- src/zwppt_mcp/server.py:90-145 (handler)The core handler function for the 'create_ppt_task' tool. Decorated with @mcp.tool() for registration in FastMCP. Includes input schema via type hints and detailed docstring parameters. Executes API call to create PPT task and returns task ID (sid).@mcp.tool() def create_ppt_task( ctx: Context, text: str, template_id: str, author: str = "XXXX", is_card_note: bool = True, search: bool = False, is_figure: bool = True, ai_image: str = "normal" ) -> Dict[str, Any]: """ 创建PPT生成任务。 使用说明: 1. 在调用本工具前,必须先调用get_theme_list获取有效的template_id。 2. 工具会返回任务ID(sid),需用get_task_progress轮询查询进度。 3. 任务完成后,可从get_task_progress结果中获取PPT下载地址。 4. 需先设置环境变量AIPPT_APP_ID和AIPPT_API_SECRET。 参数: - text: PPT生成的内容描述,用于生成PPT的主题和内容。 - template_id: PPT模板ID,需通过get_theme_list获取。 - author: PPT作者名称,将显示在生成的PPT中。 - is_card_note: 是否生成PPT演讲备注,True表示生成,False表示不生成。 - search: 是否联网搜索,True表示联网搜索补充内容,False表示不联网。 - is_figure: 是否自动配图,True表示自动配图,False表示不配图。 - ai_image: AI配图类型,仅在is_figure为True时生效。可选值:normal-普通配图(20%正文配图),advanced-高级配图(50%正文配图)。 返回: 成功时返回包含sid的字典,失败时抛出异常。 """ url = 'https://zwapi.xfyun.cn/api/ppt/v2/create' form_data = MultipartEncoder( fields={ "query": text, "templateId": template_id, "author": author, "isCardNote": str(is_card_note), "search": str(search), "isFigure": str(is_figure), "aiImage": ai_image } ) headers = get_headers(form_data.content_type) response = requests.post(url, data=form_data, headers=headers) if response.status_code != 200: raise Exception(f"调用失败: {response.text}") resp = json.loads(response.text) if resp['code'] == 0: return {"sid": resp['data']['sid']} else: raise Exception(f"调用失败: {response.text}")