Execute PDF2PPT workflow via the backend workflow adapter.
(args, input_path: Path, output_dir: Path)
| 171 | |
| 172 | |
| 173 | async def run_pdf2ppt_workflow(args, input_path: Path, output_dir: Path) -> Paper2PPTResponse: |
| 174 | """Execute PDF2PPT workflow via the backend workflow adapter.""" |
| 175 | |
| 176 | if args.ocr_api_url: |
| 177 | os.environ["PAPER2DRAWIO_OCR_API_URL"] = args.ocr_api_url |
| 178 | if args.ocr_api_key: |
| 179 | os.environ["PAPER2DRAWIO_OCR_API_KEY"] = args.ocr_api_key |
| 180 | |
| 181 | api_url, api_key = resolve_cli_text_credentials(args.api_url, args.api_key) |
| 182 | image_api_url, image_api_key = resolve_cli_image_credentials( |
| 183 | args.image_api_url, |
| 184 | args.image_api_key, |
| 185 | fallback_url=api_url, |
| 186 | fallback_key=api_key, |
| 187 | ) |
| 188 | |
| 189 | if args.use_ai_edit and not image_api_key: |
| 190 | raise ValueError( |
| 191 | "Image API key is required when --use-ai-edit is enabled. " |
| 192 | "Provide via --image-api-key/DF_IMAGE_API_KEY or reuse a compatible DF_API_KEY." |
| 193 | ) |
| 194 | |
| 195 | req = Paper2PPTRequest( |
| 196 | chat_api_url=api_url, |
| 197 | api_key=api_key, |
| 198 | chat_api_key=api_key, |
| 199 | image_api_url=image_api_url, |
| 200 | image_api_key=image_api_key, |
| 201 | model=args.model, |
| 202 | gen_fig_model=args.gen_fig_model, |
| 203 | language=args.language, |
| 204 | style=args.style, |
| 205 | page_count=args.page_count, |
| 206 | input_type="PDF", |
| 207 | input_content=str(input_path), |
| 208 | email="cli_pdf2ppt@paper2any.local", |
| 209 | credential_scope="pdf2ppt", |
| 210 | use_ai_edit=args.use_ai_edit, |
| 211 | ) |
| 212 | |
| 213 | log.info("%s", "=" * 60) |
| 214 | log.info("PDF2PPT Workflow Starting") |
| 215 | log.info("%s", "=" * 60) |
| 216 | log.info("Input PDF: %s", input_path) |
| 217 | log.info("Output Directory: %s", output_dir) |
| 218 | log.info("Workflow: pdf2ppt_qwenvl via workflow adapter") |
| 219 | log.info("AI Enhancement: %s", "Enabled" if args.use_ai_edit else "Disabled") |
| 220 | log.info("Style: %s", args.style) |
| 221 | log.info("Language: %s", args.language) |
| 222 | log.info("%s", "=" * 60) |
| 223 | |
| 224 | final_resp = await run_pdf2ppt_wf_api(req, result_path=output_dir) |
| 225 | if not final_resp.success: |
| 226 | raise RuntimeError("PDF2PPT workflow failed") |
| 227 | |
| 228 | artifact_root = Path(final_resp.result_path or output_dir) |
| 229 | artifact_candidates = [] |
| 230 | for value in [final_resp.ppt_pptx_path, final_resp.ppt_pdf_path]: |
no test coverage detected