langwatch 0.2.12__py3-none-any.whl → 0.2.14__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 +1 -1
- langwatch/prompts/decorators/prompt_service_tracing.py +15 -5
- langwatch/prompts/service.py +11 -5
- langwatch/telemetry/span.py +2 -0
- langwatch/telemetry/tracing.py +2 -0
- {langwatch-0.2.12.dist-info → langwatch-0.2.14.dist-info}/METADATA +1 -1
- {langwatch-0.2.12.dist-info → langwatch-0.2.14.dist-info}/RECORD +8 -8
- {langwatch-0.2.12.dist-info → langwatch-0.2.14.dist-info}/WHEEL +0 -0
langwatch/__version__.py
CHANGED
|
@@ -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:
|
|
19
|
-
"""
|
|
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(
|
|
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
|
{
|
langwatch/prompts/service.py
CHANGED
|
@@ -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(
|
|
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'
|
|
112
|
+
subject=f'handle_or_id="{prompt_id}"',
|
|
109
113
|
op="fetch",
|
|
110
114
|
)
|
|
111
115
|
if ok is None:
|
|
112
|
-
raise RuntimeError(
|
|
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(
|
langwatch/telemetry/span.py
CHANGED
|
@@ -79,6 +79,7 @@ class LangWatchSpan:
|
|
|
79
79
|
|
|
80
80
|
def __init__(
|
|
81
81
|
self,
|
|
82
|
+
*,
|
|
82
83
|
trace: Optional["LangWatchTrace"] = None,
|
|
83
84
|
span_id: Optional[Union[str, UUID]] = None,
|
|
84
85
|
parent: Optional[Union[OtelSpan, "LangWatchSpan"]] = None,
|
|
@@ -339,6 +340,7 @@ class LangWatchSpan:
|
|
|
339
340
|
|
|
340
341
|
def update(
|
|
341
342
|
self,
|
|
343
|
+
*,
|
|
342
344
|
span_id: Optional[Union[str, UUID]] = None,
|
|
343
345
|
name: Optional[str] = None,
|
|
344
346
|
type: Optional[SpanTypes] = None,
|
langwatch/telemetry/tracing.py
CHANGED
|
@@ -71,6 +71,7 @@ class LangWatchTrace:
|
|
|
71
71
|
|
|
72
72
|
def __init__(
|
|
73
73
|
self,
|
|
74
|
+
*,
|
|
74
75
|
trace_id: Optional[Union[str, UUID]] = None,
|
|
75
76
|
metadata: Optional[TraceMetadata] = None,
|
|
76
77
|
expected_output: Optional[str] = None,
|
|
@@ -306,6 +307,7 @@ class LangWatchTrace:
|
|
|
306
307
|
|
|
307
308
|
def update(
|
|
308
309
|
self,
|
|
310
|
+
*,
|
|
309
311
|
trace_id: Optional[Union[str, UUID]] = None,
|
|
310
312
|
metadata: Optional[TraceMetadata] = None,
|
|
311
313
|
expected_output: Optional[str] = None,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
langwatch/__init__.py,sha256=OX8vN2-VFNUqRo9mJC8LUjHGMKYSRTwmzUQj_sKAVXQ,4210
|
|
2
|
-
langwatch/__version__.py,sha256=
|
|
2
|
+
langwatch/__version__.py,sha256=hDqsjjAbGMSl_DZBFOqD1TXiZ5AnjBLKY1nrRxJz6zo,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,14 +392,14 @@ 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=
|
|
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=
|
|
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
|
|
401
|
-
langwatch/telemetry/span.py,sha256=
|
|
402
|
-
langwatch/telemetry/tracing.py,sha256=
|
|
401
|
+
langwatch/telemetry/span.py,sha256=g-RGWfQk4Q3b2TpipiHqjEV7rwmidaUHp54q51UxQ6s,32801
|
|
402
|
+
langwatch/telemetry/tracing.py,sha256=uOrJoHScKJcJjV2OqarhmfXMWB8yKK4L16wsQsicL6I,26672
|
|
403
403
|
langwatch/telemetry/types.py,sha256=Q9H7nT3GMK1aluRB7CCX8BR7VFKrQY_vdFdyF4Yc98U,501
|
|
404
404
|
langwatch/utils/__init__.py,sha256=3rqQTgzEtmICJW_KSPuLa5q8p5udxt5SRi28Z2vZB10,138
|
|
405
405
|
langwatch/utils/capture.py,sha256=uVKPqHCm-o8CpabsUfhqbNFr5sgUHzcKnBadvL2oIwI,1172
|
|
@@ -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.
|
|
412
|
-
langwatch-0.2.
|
|
413
|
-
langwatch-0.2.
|
|
411
|
+
langwatch-0.2.14.dist-info/METADATA,sha256=dQi4CnhlrCsdJBMxJLw3rX_e4JZS-KjZenTPLIf9MjI,13036
|
|
412
|
+
langwatch-0.2.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
413
|
+
langwatch-0.2.14.dist-info/RECORD,,
|
|
File without changes
|