MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / build_payload

Function build_payload

scripts/server/post_sync_i2i_presigned.py:79–102  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

77
78
79def get_request_properties(url: str, task: str) -> Dict[str, Any]:
80 response = requests.get(f"{url.rstrip('/')}/openapi.json", timeout=30)
81 response.raise_for_status()
82 document = response.json()
83 schema = document["paths"]["/v1/tasks/sync"]["post"]["requestBody"]["content"]["application/json"]["schema"]
84 if "discriminator" in schema:
85 tasks = schema["discriminator"]["mapping"]
86 if task not in tasks:
87 raise ValueError(f"Task {task!r} is not available; choose from: {', '.join(tasks)}")
88 schema = {"$ref": tasks[task]}
89 if "$ref" in schema:
90 schema = document["components"]["schemas"][schema["$ref"].rsplit("/", 1)[-1]]
91 properties = schema["properties"]
92 if "task" in properties and properties["task"]["const"] != task:
93 raise ValueError(f"This endpoint requires task={properties['task']['const']!r}")
94 return properties
95
96
97def build_payload(args: argparse.Namespace, properties: Dict[str, Any]) -> Dict[str, Any]:
98 payload: Dict[str, Any] = {
99 "prompt": args.prompt,
100 "negative_prompt": args.negative_prompt,
101 "seed": args.seed,
102 "aspect_ratio": args.aspect_ratio,
103 "save_result_path": args.save_result_path,
104 "presigned_url": args.presigned_url,
105 }

Callers 1

mainFunction · 0.70

Calls 1

file_to_base64Function · 0.85

Tested by

no test coverage detected