trodo-python 2.13.0__py3-none-any.whl → 2.14.0__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.
@@ -16,7 +16,7 @@ from __future__ import annotations
16
16
 
17
17
  import threading
18
18
  import time
19
- from typing import Any, Callable, Dict, List, Optional, Set
19
+ from typing import Any, Callable, Dict, List, Optional, Set, Union
20
20
 
21
21
  from ..prompts.compile import CompileError, compile_prompt
22
22
  from ..prompts.template import TemplateError, render
@@ -38,7 +38,7 @@ __all__ = [
38
38
  DEFAULT_TTL_SECONDS = 60.0
39
39
 
40
40
 
41
- def _cache_key(name: str, version: Optional[int], label: Optional[str]) -> str:
41
+ def _cache_key(name: str, version: Optional[Union[int, str]], label: Optional[str]) -> str:
42
42
  # Resolution happens server-side on every fetch; the client only caches
43
43
  # under whatever selector was asked for. So a label flip propagates within
44
44
  # one TTL without the client knowing anything about labels.
@@ -73,6 +73,9 @@ def _to_prompt(raw: Dict[str, Any], is_fallback: bool = False) -> ManagedPrompt:
73
73
  description=raw.get("description"),
74
74
  tags=list(raw.get("tags") or []),
75
75
  version=int(raw.get("version") or 0),
76
+ version_hash=raw.get("version_hash"),
77
+ content_hash=raw.get("content_hash"),
78
+ parent_hash=raw.get("parent_hash"),
76
79
  labels=list(raw.get("labels") or []),
77
80
  messages=list(raw.get("messages") or []),
78
81
  model=dict(raw.get("model") or {}),
@@ -172,7 +175,7 @@ class PromptManager:
172
175
  self,
173
176
  name: str,
174
177
  label: Optional[str] = None,
175
- version: Optional[int] = None,
178
+ version: Optional[Union[int, str]] = None,
176
179
  cache_ttl_seconds: Optional[float] = None,
177
180
  fallback: Optional[Dict[str, Any]] = None,
178
181
  max_retries: int = 2,
@@ -181,7 +184,8 @@ class PromptManager:
181
184
 
182
185
  Without arguments you get the version labelled ``production``; pass
183
186
  ``label`` to follow a different deploy label, or ``version`` to pin
184
- exactly.
187
+ exactly. ``version`` may be the integer ``version_no`` or a
188
+ ``version_hash`` (full, or an unambiguous short prefix like ``a3f9c2``).
185
189
 
186
190
  Availability ladder — fresh cache -> stale cache -> ``fallback`` ->
187
191
  raise. A prompt fetch is on your hot path, so a Trodo outage degrades
trodo/prompts/types.py CHANGED
@@ -59,6 +59,13 @@ class ManagedPrompt:
59
59
  response_format: Optional[ResponseFormat] = None
60
60
  variables: List[PromptVariable] = field(default_factory=list)
61
61
  version: int = 0
62
+ #: Git-style commit id of this version (content + parent + message + author
63
+ #: + time). Stable and immutable — the recommended way to reference a version.
64
+ version_hash: Optional[str] = None
65
+ #: sha256 of the content; identical content shares it.
66
+ content_hash: Optional[str] = None
67
+ #: The preceding version's ``version_hash`` (None for the first).
68
+ parent_hash: Optional[str] = None
62
69
  labels: List[str] = field(default_factory=list)
63
70
  tags: List[str] = field(default_factory=list)
64
71
  description: Optional[str] = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trodo-python
3
- Version: 2.13.0
3
+ Version: 2.14.0
4
4
  Summary: Trodo Analytics SDK for Python — server-side event tracking
5
5
  License: ISC
6
6
  Keywords: analytics,tracking,trodo,server-side
@@ -11,7 +11,7 @@ trodo/auto/auto_event_manager.py,sha256=cztuRsRkNoJE5R4NfSfTrTJTGl4jx2Yb-Ncy0aVA
11
11
  trodo/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  trodo/managers/group_manager.py,sha256=ki3Se3qEoSZfREX63oeDeBmEfZF-ISHLE8azEtLg0tM,3542
13
13
  trodo/managers/people_manager.py,sha256=mMVnx40Mlifx6NGgChvohC9ViK6dQu2mkXNHbV8pK1E,2882
14
- trodo/managers/prompt_manager.py,sha256=vdii9mgsa5_M7Ewii3mcx6M9xJu_eJBRx_FoGQBII9E,10420
14
+ trodo/managers/prompt_manager.py,sha256=kyQFdty7l7w7ngzsHw6zs1bgL4oa1Lj3ugMPxakrMqM,10719
15
15
  trodo/otel/__init__.py,sha256=yiRFXWUU45bAM2CV37XeO7zf1hmnmjufdP4XO50yEyE,624
16
16
  trodo/otel/auto_instrument.py,sha256=hJesQMOOp86U66PampcGNINmBVvwVuU_WHVrbUMauug,20895
17
17
  trodo/otel/context.py,sha256=iJ1rE42-SbO8VZHAxhIl2ZJXgNwLIVps5xLg8GKgfFc,1165
@@ -23,14 +23,14 @@ trodo/otel/wrap_agent.py,sha256=_nFDhxPyl0RlNKj29cBNeRc_zAY5FUiHvTiNUWxTt0M,3904
23
23
  trodo/prompts/__init__.py,sha256=yunNc8WkTSfEEkRR-NZWXAt_ZB3Ee2INRh-4RE7uHj4,806
24
24
  trodo/prompts/compile.py,sha256=sEMl8EWdK0G9uOKGcgc39ujnA5RLCUtbk26TYVqK68Q,6345
25
25
  trodo/prompts/template.py,sha256=obQiivPCR6LEdz7q1cby7uL25tYHYui4aoEaiUNqWfs,9357
26
- trodo/prompts/types.py,sha256=jAlxy4-Wj7FUH3hoX-XG2dymwdZv6HZWtWAU8ZF1StY,2917
26
+ trodo/prompts/types.py,sha256=RhvYSuXCrwnZHu5TftObIAs-TQa2E7v08alNmD62x4s,3327
27
27
  trodo/queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  trodo/queue/batch_flusher.py,sha256=4Lg6T3Urwi9U0Q4FpFGPmjDYKg4ZliCTR-ND8BJvWaY,1298
29
29
  trodo/queue/event_queue.py,sha256=EVFZrhlq_kwC3jJ2GK0wMhHISf9UzLCZNDnT_aZ2I2A,872
30
30
  trodo/session/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  trodo/session/server_session.py,sha256=McsudEiq33XDq3nqxgzBcUvIjQxCMscwEuAPnYXrTjs,2136
32
32
  trodo/session/session_manager.py,sha256=JrgH1VeicmtlxPR4dXEuJbxhi23OelkgwW3-9Slv80o,2525
33
- trodo_python-2.13.0.dist-info/METADATA,sha256=HxXOZvtOQo-X2QNd0HQVo2jEAQUnCrkkRpwMM9tdHUw,23115
34
- trodo_python-2.13.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
35
- trodo_python-2.13.0.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
36
- trodo_python-2.13.0.dist-info/RECORD,,
33
+ trodo_python-2.14.0.dist-info/METADATA,sha256=RCejgO9mpxqpdJhLGakkYLLVCzSB0ZJXwdFMQFrkXP8,23115
34
+ trodo_python-2.14.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
35
+ trodo_python-2.14.0.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
36
+ trodo_python-2.14.0.dist-info/RECORD,,