trodo-python 2.18.1__tar.gz → 2.18.2__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.
- {trodo_python-2.18.1 → trodo_python-2.18.2}/PKG-INFO +1 -1
- {trodo_python-2.18.1 → trodo_python-2.18.2}/pyproject.toml +1 -1
- trodo_python-2.18.2/tests/test_get_prompt_version_types.py +54 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/__init__.py +4 -2
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo_python.egg-info/PKG-INFO +1 -1
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo_python.egg-info/SOURCES.txt +1 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/README.md +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/setup.cfg +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_anon_distinct_id.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_auto_instrument_fixes.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_cross_process_session.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_datasets.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_end_run.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_error_enrichment.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_experiments.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_llm_usage_cost.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_multi_agent_shape.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_processor_methods.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_prompt_trace.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_prompts.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_register_otel.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_start_run.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_user_traits.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/tests/test_wrap_agent_unchanged.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/api/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/api/async_client.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/api/endpoints.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/api/http_client.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/auto/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/auto/auto_event_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/client.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/managers/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/managers/dataset_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/managers/experiment_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/managers/group_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/managers/people_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/managers/prompt_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/managers/user_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/auto_instrument.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/context.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/helpers.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/processor.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/prompt_trace.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/register.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/transport.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/otel/wrap_agent.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/prompts/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/prompts/compile.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/prompts/template.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/prompts/types.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/queue/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/queue/batch_flusher.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/queue/event_queue.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/session/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/session/server_session.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/session/session_manager.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/types.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/user_context.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/util/__init__.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo/util/lru.py +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo_python.egg-info/dependency_links.txt +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo_python.egg-info/requires.txt +0 -0
- {trodo_python-2.18.1 → trodo_python-2.18.2}/trodo_python.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""The public get_prompt must accept a version_hash, not just an int.
|
|
2
|
+
|
|
3
|
+
The manager has always taken ``Union[int, str]`` and documents hash support —
|
|
4
|
+
the hash is the stable identity the dashboard shows and the SDK returns. But
|
|
5
|
+
the top-level ``trodo.get_prompt`` wrapper narrowed the hint to ``int``, so a
|
|
6
|
+
type checker flagged the documented usage, and the dashboard's own "Use this
|
|
7
|
+
prompt" snippet emits ``version="<hash>"`` for Python.
|
|
8
|
+
|
|
9
|
+
Checked by signature rather than by a network call: the wrapper only forwards,
|
|
10
|
+
so the contract IS the signature.
|
|
11
|
+
"""
|
|
12
|
+
import inspect
|
|
13
|
+
import typing
|
|
14
|
+
|
|
15
|
+
import trodo
|
|
16
|
+
from trodo.managers.prompt_manager import PromptManager
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _version_annotation(fn):
|
|
20
|
+
return typing.get_type_hints(fn)["version"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_public_get_prompt_accepts_int_or_str():
|
|
24
|
+
ann = _version_annotation(trodo.get_prompt)
|
|
25
|
+
args = typing.get_args(ann)
|
|
26
|
+
assert int in args, f"version should accept int, got {ann}"
|
|
27
|
+
assert str in args, f"version should accept a version_hash (str), got {ann}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_matches_the_manager_it_forwards_to():
|
|
31
|
+
assert _version_annotation(trodo.get_prompt) == _version_annotation(PromptManager.get)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_forwards_version_through_untouched():
|
|
35
|
+
"""A hash must reach the manager as-is — not coerced, not dropped."""
|
|
36
|
+
seen = {}
|
|
37
|
+
|
|
38
|
+
class _Stub:
|
|
39
|
+
def get(self, name, **kwargs):
|
|
40
|
+
seen.update(kwargs, name=name)
|
|
41
|
+
return "sentinel"
|
|
42
|
+
|
|
43
|
+
class _Client:
|
|
44
|
+
prompts = _Stub()
|
|
45
|
+
|
|
46
|
+
original = trodo._get_client
|
|
47
|
+
trodo._get_client = lambda: _Client()
|
|
48
|
+
try:
|
|
49
|
+
assert trodo.get_prompt("p", version="a3f9c2") == "sentinel"
|
|
50
|
+
finally:
|
|
51
|
+
trodo._get_client = original
|
|
52
|
+
|
|
53
|
+
assert seen["version"] == "a3f9c2"
|
|
54
|
+
assert seen["label"] is None
|
|
@@ -322,7 +322,7 @@ def reset(distinct_id: str) -> ResetResult:
|
|
|
322
322
|
def get_prompt(
|
|
323
323
|
name: str,
|
|
324
324
|
label: Optional[str] = None,
|
|
325
|
-
version: Optional[int] = None,
|
|
325
|
+
version: Optional[Union[int, str]] = None,
|
|
326
326
|
cache_ttl_seconds: Optional[float] = None,
|
|
327
327
|
fallback: Optional[Dict[str, Any]] = None,
|
|
328
328
|
max_retries: int = 2,
|
|
@@ -330,7 +330,9 @@ def get_prompt(
|
|
|
330
330
|
"""Fetch a managed prompt by name.
|
|
331
331
|
|
|
332
332
|
Follows the ``production`` label by default; pass ``label`` for a different
|
|
333
|
-
one or ``version`` to pin exactly.
|
|
333
|
+
one or ``version`` to pin exactly. ``version`` may be the integer
|
|
334
|
+
``version_no`` or a ``version_hash`` (full, or an unambiguous short prefix
|
|
335
|
+
like ``a3f9c2``) — the hash is the stable identity, so prefer it.
|
|
334
336
|
|
|
335
337
|
Cached for 60s with stale-while-revalidate, so a Trodo outage degrades
|
|
336
338
|
instead of taking your app down. Pass ``fallback`` to cover cold start::
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|