hugpy-engine 0.3.8__tar.gz → 0.3.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/PKG-INFO +1 -1
  2. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/pyproject.toml +1 -1
  3. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/task_endpoints.py +91 -1
  4. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine.egg-info/PKG-INFO +1 -1
  5. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/README.md +0 -0
  6. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/setup.cfg +0 -0
  7. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/__init__.py +0 -0
  8. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/categories.py +0 -0
  9. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/config/__init__.py +0 -0
  10. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/config/main.py +0 -0
  11. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/config/models/__init__.py +0 -0
  12. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/config/models/models_config.py +0 -0
  13. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/config/models/models_default.py +0 -0
  14. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/core_auth.py +0 -0
  15. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/dispatch/__init__.py +0 -0
  16. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/dispatch/dispatch.py +0 -0
  17. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/fit/__init__.py +0 -0
  18. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/fit/types.py +0 -0
  19. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/imports/__init__.py +0 -0
  20. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/imports/classes.py +0 -0
  21. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/imports/constants.py +0 -0
  22. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/imports/functions.py +0 -0
  23. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/imports/init_imports.py +0 -0
  24. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/llama/__init__.py +0 -0
  25. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/llama/runners/__init__.py +0 -0
  26. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/llama/runners/fitevict_runner.py +0 -0
  27. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/name_match.py +0 -0
  28. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/placement.py +0 -0
  29. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/py.typed +0 -0
  30. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/resolvers/__init__.py +0 -0
  31. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/resolvers/assure_model_key.py +0 -0
  32. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/resolvers/categories/__init__.py +0 -0
  33. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/resolvers/categories/builders.py +0 -0
  34. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/resolvers/categories/frameworks.py +0 -0
  35. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/resolvers/model_resolver.py +0 -0
  36. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/resolvers/task_resolution.py +0 -0
  37. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/schemas/__init__.py +0 -0
  38. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/schemas/chat_schemas.py +0 -0
  39. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/schemas/event_schemas.py +0 -0
  40. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/schemas/metadata_schemas.py +0 -0
  41. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/schemas/model_schemas.py +0 -0
  42. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/schemas/runner_schemas.py +0 -0
  43. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/schemas/task_schemas.py +0 -0
  44. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/task_deps.py +0 -0
  45. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/tasks.py +0 -0
  46. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/utils/__init__.py +0 -0
  47. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/utils/json_scavenge.py +0 -0
  48. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/utils/model_marker.py +0 -0
  49. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine/utils/no_think.py +0 -0
  50. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine.egg-info/SOURCES.txt +0 -0
  51. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine.egg-info/dependency_links.txt +0 -0
  52. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine.egg-info/requires.txt +0 -0
  53. {hugpy_engine-0.3.8 → hugpy_engine-0.3.10}/src/hugpy_engine.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hugpy-engine
3
- Version: 0.3.8
3
+ Version: 0.3.10
4
4
  Summary: Hugpy engine: model discovery and classification, allocation and eviction, native llama.cpp and GGUF runners, and the prompt-to-reply inference path with task and placement seams
5
5
  Author-email: putkoff <support@hugpy.ai>
6
6
  License-Expression: LicenseRef-Proprietary
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hugpy-engine"
7
- version = "0.3.8"
7
+ version = "0.3.10"
8
8
  description = "Hugpy engine: model discovery and classification, allocation and eviction, native llama.cpp and GGUF runners, and the prompt-to-reply inference path with task and placement seams"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -28,6 +28,7 @@ import base64
28
28
  import asyncio
29
29
  import json
30
30
  import logging
31
+ import math
31
32
  import os
32
33
  import urllib.error
33
34
  import urllib.request
@@ -120,7 +121,10 @@ _BODY_SPECS: dict[str, dict] = {
120
121
  "input_key": "prompt", "sources": ("prompt", "input", "text"),
121
122
  "passthrough": ("n", "size", "steps", "num_inference_steps",
122
123
  "guidance_scale", "negative_prompt", "seed", "width",
123
- "height", "image", "mask", "strength", "_route"),
124
+ "height", "image", "image_path", "image_b64", "mask", "mask_path", "mask_b64",
125
+ "strength", "sampler_name", "scheduler", "denoise", "response_format",
126
+ "id_strength", "reference_provenance",
127
+ "metadata", "placement_intent", "max_wait_s", "keep_artifacts", "_route"),
124
128
  },
125
129
  "/v1/videos/generations": {
126
130
  "input_key": "prompt", "sources": ("prompt", "input", "text"),
@@ -219,12 +223,98 @@ def build_endpoint_request(kwargs: dict, model_key: str, *, task: str,
219
223
  for k in spec.get("passthrough", ()):
220
224
  if kwargs.get(k) is not None:
221
225
  body[k] = kwargs[k]
226
+ if route == "/v1/images/generations":
227
+ # The old image builders use num_images / num_inference_steps; Comfy's
228
+ # worker workflow consumes n / steps. Normalize without losing explicit
229
+ # zero CFG or caller-selected samplers and schedulers.
230
+ for canonical, aliases in {
231
+ "n": ("num_images",), "steps": ("num_inference_steps",),
232
+ "guidance_scale": ("cfg_scale", "cfg", "guidance"),
233
+ "negative_prompt": ("negative",), "sampler_name": ("sampler",),
234
+ }.items():
235
+ for name in (canonical, *aliases):
236
+ if kwargs.get(name) is not None:
237
+ body[canonical] = kwargs[name]
238
+ break
239
+ if kwargs.get("return_b64") is True and "response_format" not in body:
240
+ body["response_format"] = "b64_json"
241
+ references = kwargs.get("reference_images")
242
+ encoded = kwargs.get("reference_images_b64")
243
+ if references is not None and encoded is not None:
244
+ raise ValueError("supply reference_images or reference_images_b64, not both")
245
+ if references is not None or encoded is not None:
246
+ body["reference_images"] = _image_references(
247
+ references if references is not None else encoded,
248
+ encoded=encoded is not None)
249
+ strength = body.get("id_strength")
250
+ if strength is not None and (isinstance(strength, bool)
251
+ or not isinstance(strength, (int, float))
252
+ or not math.isfinite(strength) or not 0 <= strength <= 1):
253
+ raise ValueError("id_strength must be a finite number between 0 and 1")
254
+ for field in ("image", "mask"):
255
+ value = body.get(field)
256
+ path = body.pop(field + "_path", None)
257
+ if isinstance(value, str):
258
+ path = value
259
+ if path and not isinstance(value, dict) and not body.get(field + "_b64"):
260
+ if os.path.isfile(path):
261
+ with open(path, "rb") as handle:
262
+ raw = handle.read(64 * 1024 * 1024 + 1)
263
+ if len(raw) > 64 * 1024 * 1024:
264
+ raise ValueError(field + " exceeds the 64 MiB inline input limit")
265
+ body[field] = {"b64": base64.b64encode(raw).decode("ascii")}
266
+ else:
267
+ body[field] = {"path": path}
222
268
  rid = kwargs.get("request_id") or make_request_id()
223
269
  return EndpointRequest(request_id=rid, model_key=model_key, route=route,
224
270
  body=body, output=output,
225
271
  pool=kwargs.get("pool"))
226
272
 
227
273
 
274
+ def _image_references(value, *, encoded=False):
275
+ """Carry bounded reference bytes to the selected worker, independent of shared disks.
276
+
277
+ A worker-local path or artifact remains an explicit object. A central-local
278
+ file is inlined, using the same input contract as init images and masks.
279
+ """
280
+ limit = 8 * 1024 * 1024
281
+ if not isinstance(value, (list, tuple)) or not 1 <= len(value) <= 4:
282
+ raise ValueError("reference_images must contain between 1 and 4 images")
283
+ result = []
284
+ for ref in value:
285
+ if isinstance(ref, str) and ref:
286
+ if not encoded and os.path.isfile(ref):
287
+ with open(ref, "rb") as handle:
288
+ raw = handle.read(limit + 1)
289
+ if not raw or len(raw) > limit:
290
+ raise ValueError("each reference image must contain 1 byte to 8 MiB")
291
+ result.append({"b64": base64.b64encode(raw).decode("ascii")})
292
+ continue
293
+ ref = ({"path": ref} if not encoded and os.path.isabs(ref)
294
+ else {"b64": ref})
295
+ if not isinstance(ref, dict) or len(ref) != 1 or not (
296
+ set(ref) <= {"b64", "path", "artifact_id"}):
297
+ raise ValueError("each reference image needs one of b64, path, or artifact_id")
298
+ key, item = next(iter(ref.items()))
299
+ if not isinstance(item, str) or not item:
300
+ raise ValueError("reference image inputs must be non-empty strings")
301
+ if key == "path" and os.path.isfile(item):
302
+ result.extend(_image_references([item]))
303
+ continue
304
+ if key == "b64":
305
+ item = item.partition(",")[2] if item.startswith("data:") else item
306
+ if len(item) > 4 * ((limit + 2) // 3):
307
+ raise ValueError("reference image exceeds the 8 MiB inline input limit")
308
+ try:
309
+ raw = base64.b64decode(item, validate=True)
310
+ except (ValueError, TypeError) as exc:
311
+ raise ValueError("reference image is not valid base64") from exc
312
+ if not raw or len(raw) > limit:
313
+ raise ValueError("each reference image must contain 1 byte to 8 MiB")
314
+ result.append({key: item})
315
+ return result
316
+
317
+
228
318
  class TaskEndpointRunner:
229
319
  """Relays one non-chat request to hugpy_core's front-door route and returns
230
320
  its response as a TaskResult. One class for every route — the route rides the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hugpy-engine
3
- Version: 0.3.8
3
+ Version: 0.3.10
4
4
  Summary: Hugpy engine: model discovery and classification, allocation and eviction, native llama.cpp and GGUF runners, and the prompt-to-reply inference path with task and placement seams
5
5
  Author-email: putkoff <support@hugpy.ai>
6
6
  License-Expression: LicenseRef-Proprietary
File without changes
File without changes