MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / run_image2ppt_workflow

Function run_image2ppt_workflow

script/run_image2ppt_cli.py:170–230  ·  view source on GitHub ↗

Execute Image2PPT workflow via the same adapter used by the backend service.

(args, input_path: Path, output_dir: Path)

Source from the content-addressed store, hash-verified

168
169
170async def run_image2ppt_workflow(args, input_path: Path, output_dir: Path) -> Paper2PPTResponse:
171 """Execute Image2PPT workflow via the same adapter used by the backend service."""
172
173 api_url, api_key = resolve_cli_text_credentials(args.api_url, args.api_key)
174 image_api_url, image_api_key = resolve_cli_image_credentials(
175 args.image_api_url,
176 args.image_api_key,
177 fallback_url=api_url,
178 fallback_key=api_key,
179 )
180
181 # Validate API key if AI edit is enabled
182 if args.use_ai_edit and not api_key:
183 raise ValueError("API key is required when --use-ai-edit is enabled. "
184 "Provide via --api-key or DF_API_KEY environment variable.")
185
186 req = Paper2PPTRequest(
187 chat_api_url=api_url,
188 api_key=api_key,
189 chat_api_key=api_key,
190 image_api_url=image_api_url,
191 image_api_key=image_api_key,
192 model=args.model,
193 gen_fig_model=args.gen_fig_model,
194 language=args.language,
195 style=args.style,
196 page_count=args.page_count,
197 credential_scope="image2ppt",
198 use_ai_edit=args.use_ai_edit,
199 input_type="FIGURE",
200 input_content=str(input_path),
201 email="cli_image2ppt@paper2any.local",
202 )
203
204 log.info("%s", "=" * 60)
205 log.info("Image2PPT Workflow Starting")
206 log.info("%s", "=" * 60)
207 log.info("Input Image: %s", input_path)
208 log.info("Output Directory: %s", output_dir)
209 log.info("Workflow: pdf2ppt_qwenvl via workflow adapter")
210 log.info("AI Enhancement: %s", "Enabled" if args.use_ai_edit else "Disabled")
211 log.info("Style: %s", args.style)
212 log.info("Language: %s", args.language)
213 log.info("%s", "=" * 60)
214
215 final_resp = await run_pdf2ppt_wf_api(req, result_path=output_dir)
216 if not final_resp.success:
217 raise RuntimeError("Image2PPT workflow failed")
218
219 artifact_root = Path(final_resp.result_path or output_dir)
220 artifact_candidates = []
221 if final_resp.ppt_pptx_path:
222 p = Path(final_resp.ppt_pptx_path)
223 if p.exists():
224 artifact_candidates.append(p.resolve())
225 artifact_candidates.extend(find_output_artifacts(artifact_root, ("*.pptx", "*.pdf")))
226 if not artifact_candidates:
227 raise RuntimeError(

Callers 1

mainFunction · 0.85

Calls 5

Paper2PPTRequestClass · 0.90
run_pdf2ppt_wf_apiFunction · 0.90
find_output_artifactsFunction · 0.90

Tested by

no test coverage detected