langwatch 0.2.12__py3-none-any.whl → 0.2.13__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.
langwatch/__version__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Version information for LangWatch."""
2
2
 
3
- __version__ = "0.2.12"
3
+ __version__ = "0.2.13"
@@ -1,6 +1,6 @@
1
1
  from functools import wraps
2
2
  from opentelemetry import trace
3
- from typing import TYPE_CHECKING, TypeVar, Callable, Any
3
+ from typing import TYPE_CHECKING, Optional, TypeVar, Callable, Any
4
4
  import json
5
5
 
6
6
  from langwatch.attributes import AttributeKey
@@ -10,16 +10,26 @@ if TYPE_CHECKING:
10
10
 
11
11
  T = TypeVar("T")
12
12
 
13
+ # Type alias for the get method with named parameters
14
+ PromptGetMethod = Callable[[T, str, Optional[int]], "Prompt"]
15
+
13
16
 
14
17
  class PromptServiceTracing:
15
18
  """Namespace for PromptService method tracing decorators"""
16
19
 
17
20
  @staticmethod
18
- def get(func: Callable[[T, str], "Prompt"]) -> Callable[[T, str], "Prompt"]:
19
- """Type-safe decorator for PromptService.get method with OpenTelemetry tracing"""
21
+ def get(func: PromptGetMethod[T]) -> PromptGetMethod[T]:
22
+ """
23
+ Type-safe decorator for PromptService.get method with OpenTelemetry tracing
24
+
25
+ Expected function signature:
26
+ def get(self: T, *, prompt_id: str, version_number: Optional[int] = None) -> Prompt
27
+ """
20
28
 
21
29
  @wraps(func)
22
- def wrapper(self: T, prompt_id: str) -> "Prompt":
30
+ def wrapper(
31
+ self: T, prompt_id: str, version_number: Optional[int] = None
32
+ ) -> "Prompt":
23
33
  with trace.get_tracer(__name__).start_as_current_span(
24
34
  PromptServiceTracing._create_span_name("get")
25
35
  ) as span:
@@ -34,7 +44,7 @@ class PromptServiceTracing:
34
44
  ),
35
45
  )
36
46
  try:
37
- result = func(self, prompt_id)
47
+ result = func(self, prompt_id, version_number)
38
48
 
39
49
  span.set_attributes(
40
50
  {
@@ -99,17 +99,23 @@ class PromptService:
99
99
  return cls(instance.rest_api_client)
100
100
 
101
101
  @prompt_service_tracing.get
102
- def get(self, prompt_id: str) -> Prompt:
103
- """Retrieve a prompt by its ID."""
104
- resp = get_api_prompts_by_id.sync_detailed(id=prompt_id, client=self._client)
102
+ def get(self, prompt_id: str, version_number: Optional[int] = None) -> Prompt:
103
+ """Retrieve a prompt by its ID. You can optionally specify a version number to get a specific version of the prompt."""
104
+ resp = get_api_prompts_by_id.sync_detailed(
105
+ id=prompt_id,
106
+ client=self._client,
107
+ version=version_number if version_number is not None else UNSET,
108
+ )
105
109
  ok = unwrap_response(
106
110
  resp,
107
111
  ok_type=GetApiPromptsByIdResponse200,
108
- subject=f'id="{prompt_id}"',
112
+ subject=f'handle_or_id="{prompt_id}"',
109
113
  op="fetch",
110
114
  )
111
115
  if ok is None:
112
- raise RuntimeError(f"Failed to fetch prompt with id={prompt_id}")
116
+ raise RuntimeError(
117
+ f"Failed to fetch prompt with handle_or_id={prompt_id} version={version_number if version_number is not None else 'latest'}"
118
+ )
113
119
  return Prompt(ok)
114
120
 
115
121
  def create(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langwatch
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: LangWatch Python SDK, for monitoring your LLMs
5
5
  Author-email: Langwatch Engineers <engineering@langwatch.ai>
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  langwatch/__init__.py,sha256=OX8vN2-VFNUqRo9mJC8LUjHGMKYSRTwmzUQj_sKAVXQ,4210
2
- langwatch/__version__.py,sha256=hxYYl5O_5AO3iLsNn-AnlrsAUoq3Kh_t-6h9pQS-91w,65
2
+ langwatch/__version__.py,sha256=HVFxNn7t6kR8K-GnHVEDZBIIIXdVHb9ylZj64PfZuLo,65
3
3
  langwatch/attributes.py,sha256=nXdI_G85wQQCAdAcwjCiLYdEYj3wATmfgCmhlf6dVIk,3910
4
4
  langwatch/batch_evaluation.py,sha256=piez7TYqUZPb9NlIShTuTPmSzrZqX-vm2Grz_NGXe04,16078
5
5
  langwatch/client.py,sha256=w-WkYRwgFMlfljAwcR6GBT11kBQOc3Ifb3hGY1htOd4,13156
@@ -392,9 +392,9 @@ langwatch/prompts/__init__.py,sha256=pWgVz97AkKkvqlA8twnfVWuTkH8geMojgGLvY6POIYA
392
392
  langwatch/prompts/errors.py,sha256=9WKzLiOLJAm7DhtKc9c74oquh0IyDQOHNs6xeTFiQRg,5060
393
393
  langwatch/prompts/formatter.py,sha256=Q8zCw_qmN5L5NUSBYkFmX1fChplkh1A2n6HlZ-dngao,1074
394
394
  langwatch/prompts/prompt.py,sha256=zU-iUYaXNHxbVwQmJuEkuhe7Xhb4iextG1Nd3Qr-HYQ,6998
395
- langwatch/prompts/service.py,sha256=BjflqRr3qQCe43WA5Bh2EGvZZywdx0xcdpFqEJRs6ho,9833
395
+ langwatch/prompts/service.py,sha256=CiVuW1y8sYti05jaYSNk40miCg2Q0bA2FSC3iVoM5_o,10187
396
396
  langwatch/prompts/types.py,sha256=0SPb-jfcndvay53PMpuHvtCrIptT-h-eo-9EHM-grl4,654
397
- langwatch/prompts/decorators/prompt_service_tracing.py,sha256=poTKFZn8lnWBdQaCxvv-9LEiKeZnqKkmS6DtiJslAM8,1978
397
+ langwatch/prompts/decorators/prompt_service_tracing.py,sha256=ELrQ9bd3nPurbUXX2K_CN-2zWE00nqjXObs9Gkp4eVg,2309
398
398
  langwatch/prompts/decorators/prompt_tracing.py,sha256=Q3-RM8G-PHkBjVKntSg3c8H2o0P1bpO3UbR3uRgbke0,3182
399
399
  langwatch/telemetry/context.py,sha256=ixKvTBZADFuWglFCK95r8bF4-f-iq_WixzC4ydirCE8,3888
400
400
  langwatch/telemetry/sampling.py,sha256=XDf6ZoXiwpHaHDYd_dDszSqH8_9-CHFNsGAZWOW1VYk,1327
@@ -408,6 +408,6 @@ langwatch/utils/initialization.py,sha256=LOmGCiox7JRiHprnB04AdO8BhUggZtRbWgBPF9m
408
408
  langwatch/utils/module.py,sha256=KLBNOK3mA9gCSifCcQX_lOtU48BJQDWvFKtF6NMvwVA,688
409
409
  langwatch/utils/transformation.py,sha256=5XUnW7Oz8Ck9EMsKeKeoDOrIw3EXpLGMk_fMSeA0Zng,7216
410
410
  langwatch/utils/utils.py,sha256=ZCOSie4o9LdJ7odshNfCNjmgwgQ27ojc5ENqt1rXuSs,596
411
- langwatch-0.2.12.dist-info/METADATA,sha256=95rnOvRVLwqUW6KC-8faUJF2iy79vN-vLLUp6Fhlbbg,13036
412
- langwatch-0.2.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
413
- langwatch-0.2.12.dist-info/RECORD,,
411
+ langwatch-0.2.13.dist-info/METADATA,sha256=dTlhG6fXtWSUUPwLqNxfhI-nVXu_mYrhoUBxnzRwxuM,13036
412
+ langwatch-0.2.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
413
+ langwatch-0.2.13.dist-info/RECORD,,