unique_toolkit 2026.48.0.dev9__py3-none-any.whl → 2026.48.0.dev11__py3-none-any.whl

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.
@@ -0,0 +1,17 @@
1
+ """Event model for Activity Records, mirroring ``@unique/activity-events-client``."""
2
+
3
+ from .schemas import (
4
+ ACTIVITY_METADATA_MAX_LENGTH,
5
+ ActivityActor,
6
+ ActivityAgent,
7
+ ActivityCloudEvent,
8
+ ActivityEventData,
9
+ )
10
+
11
+ __all__ = [
12
+ "ACTIVITY_METADATA_MAX_LENGTH",
13
+ "ActivityActor",
14
+ "ActivityAgent",
15
+ "ActivityCloudEvent",
16
+ "ActivityEventData",
17
+ ]
@@ -0,0 +1,132 @@
1
+ """Activity Records event model, mirroring the zod schema the service validates with: it
2
+ rejects a whole batch if one event fails. Extra keys are forbidden on every path. The
3
+ constructor and plain ``model_validate`` accept both the camelCase wire keys and the
4
+ Python field names (the toolkit convention); ``ActivityCloudEvent.from_wire`` accepts only
5
+ the wire keys, like zod. Experimental: the shape may still change."""
6
+
7
+ from __future__ import annotations
8
+
9
+ from collections.abc import Mapping
10
+ from datetime import UTC, datetime
11
+ from typing import Annotated, Any, Final, Literal, Self
12
+ from uuid import UUID, uuid4
13
+
14
+ from pydantic import (
15
+ AfterValidator,
16
+ AwareDatetime,
17
+ BaseModel,
18
+ Field,
19
+ JsonValue,
20
+ StringConstraints,
21
+ field_serializer,
22
+ model_validator,
23
+ )
24
+
25
+ from unique_toolkit._common.pydantic_helpers import get_configuration_dict
26
+
27
+ ACTIVITY_METADATA_MAX_LENGTH: Final = {"identifier": 128, "ip": 64, "text": 256}
28
+
29
+ _model_config = get_configuration_dict(extra="forbid")
30
+ _NIL_UUID: Final = UUID(int=0)
31
+ _MAX_UUID: Final = UUID(int=2**128 - 1)
32
+
33
+
34
+ def _is_zod_uuid(value: UUID) -> UUID:
35
+ # zod's z.uuid(): versions 1 to 8 with the RFC variant, plus the nil and max UUIDs.
36
+ if value in (_NIL_UUID, _MAX_UUID) or (value.version or 0) in range(1, 9):
37
+ return value
38
+ raise ValueError("must be a UUID of version 1 to 8")
39
+
40
+
41
+ def _max_length(limit: int) -> AfterValidator:
42
+ # zod counts UTF-16 code units, Python counts code points.
43
+ def check(value: str) -> str:
44
+ if len(value.encode("utf-16-le", "surrogatepass")) > 2 * limit:
45
+ raise ValueError(f"must be at most {limit} characters")
46
+ return value
47
+
48
+ return AfterValidator(check)
49
+
50
+
51
+ _NonEmpty = Annotated[str, StringConstraints(strict=True, min_length=1)]
52
+ _Identifier = Annotated[
53
+ _NonEmpty, _max_length(ACTIVITY_METADATA_MAX_LENGTH["identifier"])
54
+ ]
55
+ _Ip = Annotated[_NonEmpty, _max_length(ACTIVITY_METADATA_MAX_LENGTH["ip"])]
56
+ _Text = Annotated[_NonEmpty, _max_length(ACTIVITY_METADATA_MAX_LENGTH["text"])]
57
+
58
+
59
+ class ActivityActor(BaseModel):
60
+ """Mirrors ``CloudEventActorSchema``."""
61
+
62
+ model_config = _model_config
63
+
64
+ id: _Identifier
65
+ type: Literal["user", "service"]
66
+ ip: _Ip | None = None
67
+
68
+
69
+ class ActivityAgent(BaseModel):
70
+ """Mirrors ``CloudEventAgentSchema``: the assistant or space the action ran in."""
71
+
72
+ model_config = _model_config
73
+
74
+ id: _Identifier
75
+
76
+
77
+ class ActivityEventData(BaseModel):
78
+ """Mirrors ``CloudEventDataSchema``."""
79
+
80
+ model_config = _model_config
81
+
82
+ actor: ActivityActor
83
+ agent: ActivityAgent | None = None
84
+ company_id: _NonEmpty
85
+ target_type: _Identifier | None = None
86
+ target_id: _Identifier | None = None
87
+ target_name: _Text | None = None
88
+ subtype: _Text | None = None
89
+ correlation_id: _Identifier | None = None
90
+ critical_data: dict[str, JsonValue] | None = None
91
+
92
+ @model_validator(mode="after")
93
+ def _target_set_together(self) -> ActivityEventData:
94
+ if (self.target_type is None) != (self.target_id is None):
95
+ raise ValueError("target_type and target_id must be set together")
96
+ return self
97
+
98
+
99
+ class ActivityCloudEvent(BaseModel):
100
+ """Mirrors ``CloudEventSchema``: the CloudEvents 1.0 envelope the ingest accepts.
101
+
102
+ Extra keys are always forbidden. The constructor and ``model_validate`` accept wire keys
103
+ and Python field names; ``from_wire`` is the strict wire check, used for stored payloads."""
104
+
105
+ model_config = _model_config
106
+
107
+ specversion: Literal["1.0"] = "1.0"
108
+ id: Annotated[UUID, AfterValidator(_is_zod_uuid)] = Field(default_factory=uuid4)
109
+ # "_" separates source and event id in the service's ``{source}_{id}`` record id.
110
+ source: Annotated[str, StringConstraints(strict=True, pattern=r"^[^:_]+$")]
111
+ type: _NonEmpty
112
+ time: AwareDatetime = Field(default_factory=lambda: datetime.now(UTC))
113
+ datacontenttype: Literal["application/json"] | None = "application/json"
114
+ data: ActivityEventData
115
+
116
+ @field_serializer("time")
117
+ def _serialize_time(self, value: datetime) -> str:
118
+ # Same shape as JS ``toISOString()``; the service schema rejects ``+00:00``.
119
+ return (
120
+ value.astimezone(UTC)
121
+ .isoformat(timespec="milliseconds")
122
+ .replace("+00:00", "Z")
123
+ )
124
+
125
+ @classmethod
126
+ def from_wire(cls, payload: Mapping[str, Any]) -> Self:
127
+ """Validate a wire dict like zod does: camelCase keys only, no Python field names."""
128
+ return cls.model_validate(payload, by_alias=True, by_name=False)
129
+
130
+ def to_wire(self) -> dict[str, Any]:
131
+ """JSON-ready dict in the camelCase wire format, without ``None`` fields."""
132
+ return self.model_dump(mode="json", by_alias=True, exclude_none=True)
@@ -119,6 +119,7 @@ class LanguageModelName(StrEnum):
119
119
  GEMINI_3_PRO_PREVIEW = "litellm:gemini-3-pro-preview"
120
120
  GEMINI_4_ARGON = "litellm:gemini-4-argon"
121
121
  GEMINI_4_CARBON = "litellm:gemini-4-carbon"
122
+ GEMINI_4_HYDROGEN = "litellm:gemini-4-hydrogen"
122
123
  GROK_4_1_FAST_NON_REASONING = "litellm:grok-4-1-fast-non-reasoning"
123
124
  GROK_4_1_FAST_REASONING = "litellm:grok-4-1-fast-reasoning"
124
125
  GROK_4_5 = "litellm:grok-4-5"
@@ -182,6 +183,7 @@ class LanguageModelName(StrEnum):
182
183
  VERTEX_GEMINI_3_8_FLASH = "litellm:vertex-gemini-3-8-flash"
183
184
  VERTEX_GEMINI_4_ARGON = "litellm:vertex-gemini-4-argon"
184
185
  VERTEX_GEMINI_4_CARBON = "litellm:vertex-gemini-4-carbon"
186
+ VERTEX_GEMINI_4_HYDROGEN = "litellm:vertex-gemini-4-hydrogen"
185
187
 
186
188
 
187
189
  class EncoderName(StrEnum):
@@ -2577,6 +2579,35 @@ class LanguageModelInfo(BaseModel):
2577
2579
  default_options={"reasoning_effort": "medium"},
2578
2580
  supported_reasoning_efforts=["low", "medium", "high"],
2579
2581
  )
2582
+ case (
2583
+ LanguageModelName.GEMINI_4_HYDROGEN
2584
+ | LanguageModelName.VERTEX_GEMINI_4_HYDROGEN
2585
+ ):
2586
+ return cls(
2587
+ name=model_name,
2588
+ capabilities=[
2589
+ ModelCapabilities.FUNCTION_CALLING,
2590
+ ModelCapabilities.STREAMING,
2591
+ ModelCapabilities.VISION,
2592
+ ModelCapabilities.STRUCTURED_OUTPUT,
2593
+ ModelCapabilities.REASONING,
2594
+ ],
2595
+ provider=LanguageModelProvider.LITELLM,
2596
+ family=ModelFamily.GOOGLE,
2597
+ version="gemini-4-hydrogen",
2598
+ encoder_name=EncoderName.O200K_BASE, # TODO: Update encoder with litellm
2599
+ token_limits=LanguageModelTokenLimits(
2600
+ # Unified 1,048,576 context window; 65,536 single-request output cap.
2601
+ # https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-hydrogen
2602
+ token_limit_input=1_048_576,
2603
+ token_limit_output=65_536,
2604
+ ),
2605
+ published_at=date(2026, 11, 12),
2606
+ # Google also has xhigh, but LiteLLM can't send it via reasoning_effort yet.
2607
+ # https://docs.litellm.ai/blog/gemini-4-hydrogen
2608
+ default_options={"reasoning_effort": "medium"},
2609
+ supported_reasoning_efforts=["low", "medium", "high"],
2610
+ )
2580
2611
  case LanguageModelName.GROK_4_1_FAST_NON_REASONING:
2581
2612
  return cls(
2582
2613
  name=model_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: unique-toolkit
3
- Version: 2026.48.0.dev9
3
+ Version: 2026.48.0.dev11
4
4
  Summary:
5
5
  Author: Cedric Klinkert, Martin Fadler, Sadique Sheik, Fabian Schläpfer, Pascal Hauri, Ejiroghene Oki-Peter, Rami Azouz, Ricardo Visini, Sanzio Monti
6
6
  Author-email: Cedric Klinkert <cedric.klinkert@unique.ch>, Martin Fadler <martin.fadler@unique.ch>, Sadique Sheik <sadique@unique.ch>, Fabian Schläpfer <fabian@unique.ch>, Pascal Hauri <pascal@unique.ch>, Ejiroghene Oki-Peter <oki-peter.ejiroghene@unique.ai>, Rami Azouz <rami.ext@unique.ch>, Ricardo Visini <ricardo.visini@unique.ch>, Sanzio Monti <sanzio.monti@unique.ai>
@@ -16,7 +16,7 @@ Requires-Dist: sseclient>=0.0.27,<0.0.28
16
16
  Requires-Dist: openai>=1.105.0,<3
17
17
  Requires-Dist: platformdirs>=4.0.0,<5
18
18
  Requires-Dist: pillow>=13.0.0
19
- Requires-Dist: unique-sdk>=2026.48.0.dev7,<2026.48.0rc0
19
+ Requires-Dist: unique-sdk>=2026.48.0.dev8,<2026.48.0rc0
20
20
  Requires-Dist: jambo>=0.1.2,<0.2
21
21
  Requires-Dist: jinja2>=3.1.6,<4
22
22
  Requires-Dist: docxtpl>=0.20.1,<0.21
@@ -361,6 +361,8 @@ unique_toolkit/experimental/integrations/openai/streaming/event_routing/subscrib
361
361
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/subscribers/message_persister.py,sha256=JVA0lcF3_WCYEUgWqX53gO5Lj7zR1iFCCuNXuWDPGbo,8930
362
362
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/subscribers/progress_log_persister.py,sha256=VCYGZY3WSpI7mvVs2gO89-M0JenakW01BGfBfFkPDrw,3499
363
363
  unique_toolkit/experimental/resources/__init__.py,sha256=KdMPaaneY0twZ-JBfwImRjXZaWT68NVuOIeqdNXFh_Y,3377
364
+ unique_toolkit/experimental/resources/activity_records/__init__.py,sha256=QEvl-xjtN-5oQT6v1uPlKbnfJs5EHb4f7EDhOg6UyRU,375
365
+ unique_toolkit/experimental/resources/activity_records/schemas.py,sha256=l0AJLOR1Tj2ukRH3Kw06mVVFKEouHn6w05XToK47Go8,4728
364
366
  unique_toolkit/experimental/resources/content_folder/__init__.py,sha256=c5MUj1xIP10L7tcM4-hG2m1_yUMVfKr_jHAncUXVNvo,2492
365
367
  unique_toolkit/experimental/resources/content_folder/functions.py,sha256=nJle9Qnh-x1SLNetBBhTbQPu-zEBfQaHFnMq8N9RGEQ,16692
366
368
  unique_toolkit/experimental/resources/content_folder/schemas.py,sha256=LYWRpMLFVg_iKT9dw2AyCNfTPVmKeB8erMSsgbIkZ48,5345
@@ -404,7 +406,7 @@ unique_toolkit/language_model/constants.py,sha256=B-topqW0r83dkC_25DeQfnPk3n53qz
404
406
  unique_toolkit/language_model/default_language_model.py,sha256=mcyuFs_V6tp52C8xJSHiEHO4kFGj6xed1gvozvCRD7k,1181
405
407
  unique_toolkit/language_model/errors.py,sha256=0nm4psGCGJM2B7LIyKXy7WuswRzwARIgIK5xoC4xo34,3186
406
408
  unique_toolkit/language_model/functions.py,sha256=6Le6dDm9su6xk3sQ8IPiyUn2tf1qvzxHVUhyTTgP8Kw,28109
407
- unique_toolkit/language_model/infos.py,sha256=nWm0X3Kjeyam4EfA6ALbuJ8wYxvA5zL8_Z89JYniMf8,189850
409
+ unique_toolkit/language_model/infos.py,sha256=ZXEPfmc--icQhH13-UJbm-89ojKCgS43ULd1VhvQheo,191539
408
410
  unique_toolkit/language_model/invocation_stats.py,sha256=CQbpUz394IsVd8eNTB1gPSMt5f0UXmkN1amNsqtAW6U,5857
409
411
  unique_toolkit/language_model/model_costs.py,sha256=AVHAuMTzsglzusWsVF_xwBVEndST-TVCVi0H49OhdvE,7419
410
412
  unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
@@ -435,6 +437,6 @@ unique_toolkit/short_term_memory/service.py,sha256=2JMBEBn6GoyK-a0xvdcWpPft-3C74
435
437
  unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
436
438
  unique_toolkit/smart_rules/compile.py,sha256=vRe0aMJWuVIK-VsqomgxQImzke7MDmwgSxxJfYCa7zw,1386
437
439
  unique_toolkit/test_utilities/events.py,sha256=FLrhMh0A_mQutAUjoD0FdMcVQ4Gq31r35OVGzRjvLro,6760
438
- unique_toolkit-2026.48.0.dev9.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
439
- unique_toolkit-2026.48.0.dev9.dist-info/METADATA,sha256=FVFBN8wMINrWH-Ch7as1jEkZUeoWUcoqyOKRp26wnVQ,7821
440
- unique_toolkit-2026.48.0.dev9.dist-info/RECORD,,
440
+ unique_toolkit-2026.48.0.dev11.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
441
+ unique_toolkit-2026.48.0.dev11.dist-info/METADATA,sha256=ySFJLUz3wZ8xLvuIzxLtyYtqWD-NPejXA0qXRKh12sk,7822
442
+ unique_toolkit-2026.48.0.dev11.dist-info/RECORD,,