hugpy-engine 0.3.9__tar.gz → 0.3.11__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.9 → hugpy_engine-0.3.11}/PKG-INFO +1 -1
  2. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/pyproject.toml +1 -1
  3. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/task_endpoints.py +67 -0
  4. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine.egg-info/PKG-INFO +1 -1
  5. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/README.md +0 -0
  6. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/setup.cfg +0 -0
  7. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/__init__.py +0 -0
  8. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/categories.py +0 -0
  9. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/config/__init__.py +0 -0
  10. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/config/main.py +0 -0
  11. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/config/models/__init__.py +0 -0
  12. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/config/models/models_config.py +0 -0
  13. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/config/models/models_default.py +0 -0
  14. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/core_auth.py +0 -0
  15. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/dispatch/__init__.py +0 -0
  16. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/dispatch/dispatch.py +0 -0
  17. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/fit/__init__.py +0 -0
  18. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/fit/types.py +0 -0
  19. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/imports/__init__.py +0 -0
  20. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/imports/classes.py +0 -0
  21. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/imports/constants.py +0 -0
  22. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/imports/functions.py +0 -0
  23. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/imports/init_imports.py +0 -0
  24. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/llama/__init__.py +0 -0
  25. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/llama/runners/__init__.py +0 -0
  26. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/llama/runners/fitevict_runner.py +0 -0
  27. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/name_match.py +0 -0
  28. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/placement.py +0 -0
  29. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/py.typed +0 -0
  30. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/resolvers/__init__.py +0 -0
  31. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/resolvers/assure_model_key.py +0 -0
  32. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/resolvers/categories/__init__.py +0 -0
  33. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/resolvers/categories/builders.py +0 -0
  34. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/resolvers/categories/frameworks.py +0 -0
  35. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/resolvers/model_resolver.py +0 -0
  36. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/resolvers/task_resolution.py +0 -0
  37. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/schemas/__init__.py +0 -0
  38. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/schemas/chat_schemas.py +0 -0
  39. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/schemas/event_schemas.py +0 -0
  40. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/schemas/metadata_schemas.py +0 -0
  41. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/schemas/model_schemas.py +0 -0
  42. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/schemas/runner_schemas.py +0 -0
  43. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/schemas/task_schemas.py +0 -0
  44. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/task_deps.py +0 -0
  45. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/tasks.py +0 -0
  46. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/utils/__init__.py +0 -0
  47. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/utils/json_scavenge.py +0 -0
  48. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/utils/model_marker.py +0 -0
  49. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine/utils/no_think.py +0 -0
  50. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine.egg-info/SOURCES.txt +0 -0
  51. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine.egg-info/dependency_links.txt +0 -0
  52. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/src/hugpy_engine.egg-info/requires.txt +0 -0
  53. {hugpy_engine-0.3.9 → hugpy_engine-0.3.11}/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.9
3
+ Version: 0.3.11
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.9"
7
+ version = "0.3.11"
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
@@ -122,6 +123,7 @@ _BODY_SPECS: dict[str, dict] = {
122
123
  "guidance_scale", "negative_prompt", "seed", "width",
123
124
  "height", "image", "image_path", "image_b64", "mask", "mask_path", "mask_b64",
124
125
  "strength", "sampler_name", "scheduler", "denoise", "response_format",
126
+ "id_strength", "reference_provenance",
125
127
  "metadata", "placement_intent", "max_wait_s", "keep_artifacts", "_route"),
126
128
  },
127
129
  "/v1/videos/generations": {
@@ -236,6 +238,27 @@ def build_endpoint_request(kwargs: dict, model_key: str, *, task: str,
236
238
  break
237
239
  if kwargs.get("return_b64") is True and "response_format" not in body:
238
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
+ # Only the Comfy checkpoint runner currently implements this image
247
+ # conditioning contract. Refuse before relay, including when an
248
+ # older remote Wrapper would otherwise ignore the new fields.
249
+ from hugpy_engine.config.models.models_config import MODEL_REGISTRY
250
+ selected = MODEL_REGISTRY.get(model_key)
251
+ if getattr(selected, "framework", None) != "comfy":
252
+ raise ValueError("reference images require a Comfy checkpoint with "
253
+ "an explicitly configured IP-Adapter pairing")
254
+ body["reference_images"] = _image_references(
255
+ references if references is not None else encoded,
256
+ encoded=encoded is not None)
257
+ strength = body.get("id_strength")
258
+ if strength is not None and (isinstance(strength, bool)
259
+ or not isinstance(strength, (int, float))
260
+ or not math.isfinite(strength) or not 0 <= strength <= 1):
261
+ raise ValueError("id_strength must be a finite number between 0 and 1")
239
262
  for field in ("image", "mask"):
240
263
  value = body.get(field)
241
264
  path = body.pop(field + "_path", None)
@@ -256,6 +279,50 @@ def build_endpoint_request(kwargs: dict, model_key: str, *, task: str,
256
279
  pool=kwargs.get("pool"))
257
280
 
258
281
 
282
+ def _image_references(value, *, encoded=False):
283
+ """Carry bounded reference bytes to the selected worker, independent of shared disks.
284
+
285
+ A worker-local path or artifact remains an explicit object. A central-local
286
+ file is inlined, using the same input contract as init images and masks.
287
+ """
288
+ limit = 8 * 1024 * 1024
289
+ if not isinstance(value, (list, tuple)) or not 1 <= len(value) <= 4:
290
+ raise ValueError("reference_images must contain between 1 and 4 images")
291
+ result = []
292
+ for ref in value:
293
+ if isinstance(ref, str) and ref:
294
+ if not encoded and os.path.isfile(ref):
295
+ with open(ref, "rb") as handle:
296
+ raw = handle.read(limit + 1)
297
+ if not raw or len(raw) > limit:
298
+ raise ValueError("each reference image must contain 1 byte to 8 MiB")
299
+ result.append({"b64": base64.b64encode(raw).decode("ascii")})
300
+ continue
301
+ ref = ({"path": ref} if not encoded and os.path.isabs(ref)
302
+ else {"b64": ref})
303
+ if not isinstance(ref, dict) or len(ref) != 1 or not (
304
+ set(ref) <= {"b64", "path", "artifact_id"}):
305
+ raise ValueError("each reference image needs one of b64, path, or artifact_id")
306
+ key, item = next(iter(ref.items()))
307
+ if not isinstance(item, str) or not item:
308
+ raise ValueError("reference image inputs must be non-empty strings")
309
+ if key == "path" and os.path.isfile(item):
310
+ result.extend(_image_references([item]))
311
+ continue
312
+ if key == "b64":
313
+ item = item.partition(",")[2] if item.startswith("data:") else item
314
+ if len(item) > 4 * ((limit + 2) // 3):
315
+ raise ValueError("reference image exceeds the 8 MiB inline input limit")
316
+ try:
317
+ raw = base64.b64decode(item, validate=True)
318
+ except (ValueError, TypeError) as exc:
319
+ raise ValueError("reference image is not valid base64") from exc
320
+ if not raw or len(raw) > limit:
321
+ raise ValueError("each reference image must contain 1 byte to 8 MiB")
322
+ result.append({key: item})
323
+ return result
324
+
325
+
259
326
  class TaskEndpointRunner:
260
327
  """Relays one non-chat request to hugpy_core's front-door route and returns
261
328
  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.9
3
+ Version: 0.3.11
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