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

Function _run_workflow

script/paper2poster_worker.py:55–97  ·  view source on GitHub ↗
(in_data: dict)

Source from the content-addressed store, hash-verified

53
54
55async def _run_workflow(in_data: dict) -> dict:
56 api_key = (in_data.get("api_key") or "").strip()
57 api_url = (in_data.get("chat_api_url") or "").strip()
58 if api_key:
59 os.environ["OPENAI_API_KEY"] = api_key
60 if api_url:
61 os.environ["OPENAI_BASE_URL"] = api_url
62
63 request = Paper2PosterRequest(
64 chat_api_url=api_url,
65 api_key=api_key,
66 chat_api_key=api_key,
67 model=in_data.get("model", "gpt-4o-2024-08-06"),
68 vision_model=in_data.get("vision_model", "gpt-4o-2024-08-06"),
69 poster_width=in_data.get("poster_width", 54.0),
70 poster_height=in_data.get("poster_height", 36.0),
71 logo_path=in_data.get("logo_path", ""),
72 aff_logo_path=in_data.get("aff_logo_path", ""),
73 url=in_data.get("url", ""),
74 )
75 state = Paper2PosterState(
76 request=request,
77 messages=[],
78 result_path=in_data.get("result_path", ""),
79 paper_file=in_data.get("paper_file", ""),
80 poster_width=in_data.get("poster_width", 54.0),
81 poster_height=in_data.get("poster_height", 36.0),
82 logo_path=in_data.get("logo_path", ""),
83 aff_logo_path=in_data.get("aff_logo_path", ""),
84 url=in_data.get("url", ""),
85 )
86
87 final_state = await run_workflow("paper2poster", state)
88 if isinstance(final_state, dict):
89 output_pptx_path = final_state.get("output_pptx_path") or ""
90 output_png_path = final_state.get("output_png_path") or ""
91 errors = final_state.get("errors") or []
92 else:
93 output_pptx_path = getattr(final_state, "output_pptx_path", "") or ""
94 output_png_path = getattr(final_state, "output_png_path", "") or ""
95 errors = getattr(final_state, "errors", []) or []
96
97 return _build_worker_result(output_pptx_path, output_png_path, errors)
98
99
100def main() -> int:

Callers 1

mainFunction · 0.85

Calls 5

Paper2PosterRequestClass · 0.90
Paper2PosterStateClass · 0.90
run_workflowFunction · 0.90
_build_worker_resultFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected