Upload handler.py with huggingface_hub
Browse files- handler.py +17 -4
handler.py
CHANGED
|
@@ -147,10 +147,23 @@ class EndpointHandler:
|
|
| 147 |
# Extract and validate parameters
|
| 148 |
logger.info("Parsing request parameters...")
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
# Log request details
|
| 156 |
logger.info(f" text_prompt: '{text_prompt}'")
|
|
|
|
| 147 |
# Extract and validate parameters
|
| 148 |
logger.info("Parsing request parameters...")
|
| 149 |
|
| 150 |
+
# DEBUG: Log the exact structure we received
|
| 151 |
+
logger.info(f" Received keys: {list(data.keys())}")
|
| 152 |
+
if "parameters" in data:
|
| 153 |
+
logger.info(f" parameters dict keys: {list(data['parameters'].keys())}")
|
| 154 |
+
|
| 155 |
+
# Video comes from "inputs" (HF toolkit standard)
|
| 156 |
+
video_data = data.get("inputs")
|
| 157 |
+
|
| 158 |
+
# Parameters might be at top level (flattened) or in "parameters" dict
|
| 159 |
+
# HF Inference Toolkit doesn't always flatten, so check both locations
|
| 160 |
+
parameters = data.get("parameters", {})
|
| 161 |
+
text_prompt = data.get("text_prompt") or parameters.get("text_prompt", "")
|
| 162 |
+
output_repo = data.get("output_repo") or parameters.get("output_repo")
|
| 163 |
+
return_format = data.get("return_format") or parameters.get("return_format", "metadata_only")
|
| 164 |
+
|
| 165 |
+
# DEBUG: Log what we extracted
|
| 166 |
+
logger.info(f" Extracted text_prompt: '{text_prompt}'")
|
| 167 |
|
| 168 |
# Log request details
|
| 169 |
logger.info(f" text_prompt: '{text_prompt}'")
|