langwatch 0.2.19__py3-none-any.whl → 0.3.1__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/__init__.py +5 -5
- langwatch/__version__.py +1 -1
- langwatch/generated/langwatch_rest_api_client/models/__init__.py +2 -18
- langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2.py +7 -115
- langwatch/generated/langwatch_rest_api_client/models/{post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item_function.py → post_api_scenario_events_body_type_2_messages_item.py} +23 -22
- langwatch/prompts/__init__.py +2 -2
- langwatch/prompts/decorators/prompt_service_tracing.py +6 -4
- langwatch/prompts/decorators/prompt_tracing.py +13 -7
- langwatch/prompts/local_loader.py +170 -0
- langwatch/prompts/prompt.py +41 -43
- langwatch/prompts/{service.py → prompt_api_service.py} +23 -33
- langwatch/prompts/prompt_facade.py +139 -0
- langwatch/prompts/types/__init__.py +27 -0
- langwatch/prompts/types/prompt_data.py +93 -0
- langwatch/prompts/types/structures.py +37 -0
- langwatch/prompts/types.py +16 -24
- langwatch/utils/transformation.py +16 -5
- {langwatch-0.2.19.dist-info → langwatch-0.3.1.dist-info}/METADATA +1 -1
- {langwatch-0.2.19.dist-info → langwatch-0.3.1.dist-info}/RECORD +20 -22
- langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_0.py +0 -88
- langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_1.py +0 -88
- langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2.py +0 -120
- langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item.py +0 -87
- langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_3.py +0 -88
- langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_4.py +0 -85
- langwatch/prompts/formatter.py +0 -31
- {langwatch-0.2.19.dist-info → langwatch-0.3.1.dist-info}/WHEEL +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
langwatch/__init__.py,sha256=
|
|
2
|
-
langwatch/__version__.py,sha256=
|
|
1
|
+
langwatch/__init__.py,sha256=TzPHzqCFGZJByI3sAIKrNB33Qi4PqVmgYDZuBwPnhPc,4222
|
|
2
|
+
langwatch/__version__.py,sha256=76Y19D8flgXvQE1gQJQMULzN9YyGslJSW_cUX8J6s6I,64
|
|
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=WTNcYSik7kZ2kH-qGDnhbMTosc8e_Xhab_lZlfh5TC8,25559
|
|
@@ -50,7 +50,7 @@ langwatch/generated/langwatch_rest_api_client/api/default/post_index.py,sha256=d
|
|
|
50
50
|
langwatch/generated/langwatch_rest_api_client/api/default/put_api_prompts_by_id.py,sha256=rNENNcsjKsrlBGB11N7uJg1pRA6mBT88z2lkYCSbWfY,8010
|
|
51
51
|
langwatch/generated/langwatch_rest_api_client/api/traces/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
52
52
|
langwatch/generated/langwatch_rest_api_client/api/traces/post_api_trace_search.py,sha256=NWiPvKeRiRKU28nPYEeIMWz3Z_sKomRgbQZxLYMvC00,4050
|
|
53
|
-
langwatch/generated/langwatch_rest_api_client/models/__init__.py,sha256=
|
|
53
|
+
langwatch/generated/langwatch_rest_api_client/models/__init__.py,sha256=DvNiSh0aeE1ZmPUOk30F-Qjsm0sstveCFxLgIEG2FPk,56522
|
|
54
54
|
langwatch/generated/langwatch_rest_api_client/models/annotation.py,sha256=PI0ycptiz9YlWz3DPv7SIG1gif9U2gj12h_jenIGG58,3924
|
|
55
55
|
langwatch/generated/langwatch_rest_api_client/models/dataset_post_entries.py,sha256=yrWY00ONDQNwCTSpK8MtqMqqbigtA5iNYgdhTdlmTfY,2204
|
|
56
56
|
langwatch/generated/langwatch_rest_api_client/models/dataset_post_entries_entries_item.py,sha256=vNgto6j1Hywr7httGXNkHZNXKvLraF5mwKd0D1f-uC8,1299
|
|
@@ -310,14 +310,8 @@ langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_bo
|
|
|
310
310
|
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_1_results_type_0.py,sha256=K0jfkAlg1XK5h5O-AjnB91Yvb2-tZzdCz9CFzE-BCWY,3016
|
|
311
311
|
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_1_results_type_0_verdict.py,sha256=qVxhzbYAysPJC6hmuctug-7LCMWdtUzwMWN005LPMWI,236
|
|
312
312
|
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_1_status.py,sha256=-U7B6pqb5X79Iw0F19Vke7S11HBF87-diek-hJuzglc,291
|
|
313
|
-
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2.py,sha256=
|
|
314
|
-
langwatch/generated/langwatch_rest_api_client/models/
|
|
315
|
-
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_1.py,sha256=YQ6OacpsnkL2MQisRNa14Z-gOrCgF-6XhwSm6NONcrU,2380
|
|
316
|
-
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2.py,sha256=ErGYAwFI0g5l4lhFmErfohnsLSnzskXUU7KHFdgT6DA,3858
|
|
317
|
-
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item.py,sha256=tFO785mBXcNlT3aOBplKx-6GVYhGA6S_avbYW5-QR8g,2877
|
|
318
|
-
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item_function.py,sha256=expSSxFIKQ8nhBofhtlqmXwjkdQGDsc7BBIIbguhYqo,1954
|
|
319
|
-
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_3.py,sha256=K0as-0RmL9qIQnGNtZQmAs-GZu2-mombauEQtCQtXJI,2370
|
|
320
|
-
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_4.py,sha256=MlGOKgRzv3SoCcEYXDKPSTzUk-pVWfNb15hZaLErmfQ,2324
|
|
313
|
+
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2.py,sha256=5oyA7DZAyw3iSb594S6hg8qR9q2Ek90CG864yh9rNnM,4318
|
|
314
|
+
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_body_type_2_messages_item.py,sha256=uT0vY9hRS4yw2X9qEeY2ZsCKmS6HLV6T8xLaVgknctg,1946
|
|
321
315
|
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_response_201.py,sha256=Y-4G9omlFVuezMBsUCjVUHz4gkTJhR9UdjoCYs4OXeM,2235
|
|
322
316
|
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_response_400.py,sha256=KQH2kjMuNauaKkmFMXduIwMmqOin-467tD6_rBTKjaE,1564
|
|
323
317
|
langwatch/generated/langwatch_rest_api_client/models/post_api_scenario_events_response_401.py,sha256=GKaC26oNqfNyWEltpy5BUa8q6pMFM88XgmsfM292fOI,1862
|
|
@@ -388,14 +382,18 @@ langwatch/generated/langwatch_rest_api_client/models/search_request_filters.py,s
|
|
|
388
382
|
langwatch/generated/langwatch_rest_api_client/models/search_response.py,sha256=zDYmJ8bFBSJyF9D3cEn_ffrey-ITIfwr-_7eu72zLyk,2832
|
|
389
383
|
langwatch/generated/langwatch_rest_api_client/models/timestamps.py,sha256=-nRKUPZTAJQNxiKz128xF7DKgZNbFo4G3mr5xNXrkaw,2173
|
|
390
384
|
langwatch/generated/langwatch_rest_api_client/models/trace.py,sha256=K9Lc_EQOrJ2dqMXx9EpiUXReT1_uYF7WRfYyhlfbi3I,7537
|
|
391
|
-
langwatch/prompts/__init__.py,sha256=
|
|
385
|
+
langwatch/prompts/__init__.py,sha256=2BcFhTrcCfxMxDGc5gd09oNZdzY_wlcAGFlt4Mz2lv4,77
|
|
392
386
|
langwatch/prompts/errors.py,sha256=9WKzLiOLJAm7DhtKc9c74oquh0IyDQOHNs6xeTFiQRg,5060
|
|
393
|
-
langwatch/prompts/
|
|
394
|
-
langwatch/prompts/prompt.py,sha256=
|
|
395
|
-
langwatch/prompts/
|
|
396
|
-
langwatch/prompts/
|
|
397
|
-
langwatch/prompts/
|
|
398
|
-
langwatch/prompts/decorators/
|
|
387
|
+
langwatch/prompts/local_loader.py,sha256=JL2l1v8ymyhi8LvTndVIqhzP7XDHm4HXKygYDvSaV5w,6596
|
|
388
|
+
langwatch/prompts/prompt.py,sha256=SgLDo9hO-CuRE-AZ8zx9v7-KqjiabiW8GzD9jdx1IoA,6914
|
|
389
|
+
langwatch/prompts/prompt_api_service.py,sha256=tHhwIRjUBSM43_jwDAoGCHJjvvqVeSCrUPwcwMvUHho,9823
|
|
390
|
+
langwatch/prompts/prompt_facade.py,sha256=47matSK4G2Ce3HWUnO13-k7jlDuZQePGCck4gkbTmXM,5052
|
|
391
|
+
langwatch/prompts/types.py,sha256=p1bRMvfCCpGGiVwzFtQijVtWl5GWugL_vBOFc4B2348,269
|
|
392
|
+
langwatch/prompts/decorators/prompt_service_tracing.py,sha256=uSYw0vExo7AuxbcCRnxbYl6UOfOQSC0IsisSqYy153Y,2395
|
|
393
|
+
langwatch/prompts/decorators/prompt_tracing.py,sha256=GD1iA7j7_BzqO7iwkRUt4-RQrursuRg1gvtu89SsiY8,3443
|
|
394
|
+
langwatch/prompts/types/__init__.py,sha256=uEnjOQC4LkLMWQ0fXfKe573xKOvoMdPgC6uY-yo9B_g,506
|
|
395
|
+
langwatch/prompts/types/prompt_data.py,sha256=g_EQ94-PGfa4Ptwd3e2rMqoIZiX052MEEZKyF77m9D0,3137
|
|
396
|
+
langwatch/prompts/types/structures.py,sha256=cB94bn-qhFgHHYXcrmJV6Bk9idk5ZmyfXhFNQAaXw-M,951
|
|
399
397
|
langwatch/telemetry/context.py,sha256=q0hUG9PM3aifIr6ZRuuNNbsGtcAImu9Pv2XTKUp3CGc,4029
|
|
400
398
|
langwatch/telemetry/sampling.py,sha256=XDf6ZoXiwpHaHDYd_dDszSqH8_9-CHFNsGAZWOW1VYk,1327
|
|
401
399
|
langwatch/telemetry/span.py,sha256=g-RGWfQk4Q3b2TpipiHqjEV7rwmidaUHp54q51UxQ6s,32801
|
|
@@ -407,8 +405,8 @@ langwatch/utils/capture.py,sha256=uVKPqHCm-o8CpabsUfhqbNFr5sgUHzcKnBadvL2oIwI,11
|
|
|
407
405
|
langwatch/utils/exceptions.py,sha256=J2_0EZ_GMRTJvCQ-ULX4LOG63r1R-0TCbKg9sskgl5A,498
|
|
408
406
|
langwatch/utils/initialization.py,sha256=1KoZmkHOvGEVF0j-4t4xRQdA_2C_SPiF7qFXqEG4Nkw,4553
|
|
409
407
|
langwatch/utils/module.py,sha256=KLBNOK3mA9gCSifCcQX_lOtU48BJQDWvFKtF6NMvwVA,688
|
|
410
|
-
langwatch/utils/transformation.py,sha256=
|
|
408
|
+
langwatch/utils/transformation.py,sha256=76MGXyrYTxM0Yri36NJqLK-XxL4BBYdmKWAXXlw3D4Q,7690
|
|
411
409
|
langwatch/utils/utils.py,sha256=ZCOSie4o9LdJ7odshNfCNjmgwgQ27ojc5ENqt1rXuSs,596
|
|
412
|
-
langwatch-0.
|
|
413
|
-
langwatch-0.
|
|
414
|
-
langwatch-0.
|
|
410
|
+
langwatch-0.3.1.dist-info/METADATA,sha256=RhkQSUrkCjU-O4v2J-MBLavOEYaML6VtK1MmE1CJBPE,13123
|
|
411
|
+
langwatch-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
412
|
+
langwatch-0.3.1.dist-info/RECORD,,
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
from collections.abc import Mapping
|
|
2
|
-
from typing import Any, Literal, TypeVar, Union, cast
|
|
3
|
-
|
|
4
|
-
from attrs import define as _attrs_define
|
|
5
|
-
from attrs import field as _attrs_field
|
|
6
|
-
|
|
7
|
-
from ..types import UNSET, Unset
|
|
8
|
-
|
|
9
|
-
T = TypeVar("T", bound="PostApiScenarioEventsBodyType2MessagesItemType0")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@_attrs_define
|
|
13
|
-
class PostApiScenarioEventsBodyType2MessagesItemType0:
|
|
14
|
-
"""
|
|
15
|
-
Attributes:
|
|
16
|
-
id (str):
|
|
17
|
-
role (Literal['developer']):
|
|
18
|
-
content (str):
|
|
19
|
-
name (Union[Unset, str]):
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
id: str
|
|
23
|
-
role: Literal["developer"]
|
|
24
|
-
content: str
|
|
25
|
-
name: Union[Unset, str] = UNSET
|
|
26
|
-
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
27
|
-
|
|
28
|
-
def to_dict(self) -> dict[str, Any]:
|
|
29
|
-
id = self.id
|
|
30
|
-
|
|
31
|
-
role = self.role
|
|
32
|
-
|
|
33
|
-
content = self.content
|
|
34
|
-
|
|
35
|
-
name = self.name
|
|
36
|
-
|
|
37
|
-
field_dict: dict[str, Any] = {}
|
|
38
|
-
field_dict.update(self.additional_properties)
|
|
39
|
-
field_dict.update(
|
|
40
|
-
{
|
|
41
|
-
"id": id,
|
|
42
|
-
"role": role,
|
|
43
|
-
"content": content,
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
if name is not UNSET:
|
|
47
|
-
field_dict["name"] = name
|
|
48
|
-
|
|
49
|
-
return field_dict
|
|
50
|
-
|
|
51
|
-
@classmethod
|
|
52
|
-
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
53
|
-
d = dict(src_dict)
|
|
54
|
-
id = d.pop("id")
|
|
55
|
-
|
|
56
|
-
role = cast(Literal["developer"], d.pop("role"))
|
|
57
|
-
if role != "developer":
|
|
58
|
-
raise ValueError(f"role must match const 'developer', got '{role}'")
|
|
59
|
-
|
|
60
|
-
content = d.pop("content")
|
|
61
|
-
|
|
62
|
-
name = d.pop("name", UNSET)
|
|
63
|
-
|
|
64
|
-
post_api_scenario_events_body_type_2_messages_item_type_0 = cls(
|
|
65
|
-
id=id,
|
|
66
|
-
role=role,
|
|
67
|
-
content=content,
|
|
68
|
-
name=name,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
post_api_scenario_events_body_type_2_messages_item_type_0.additional_properties = d
|
|
72
|
-
return post_api_scenario_events_body_type_2_messages_item_type_0
|
|
73
|
-
|
|
74
|
-
@property
|
|
75
|
-
def additional_keys(self) -> list[str]:
|
|
76
|
-
return list(self.additional_properties.keys())
|
|
77
|
-
|
|
78
|
-
def __getitem__(self, key: str) -> Any:
|
|
79
|
-
return self.additional_properties[key]
|
|
80
|
-
|
|
81
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
82
|
-
self.additional_properties[key] = value
|
|
83
|
-
|
|
84
|
-
def __delitem__(self, key: str) -> None:
|
|
85
|
-
del self.additional_properties[key]
|
|
86
|
-
|
|
87
|
-
def __contains__(self, key: str) -> bool:
|
|
88
|
-
return key in self.additional_properties
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
from collections.abc import Mapping
|
|
2
|
-
from typing import Any, Literal, TypeVar, Union, cast
|
|
3
|
-
|
|
4
|
-
from attrs import define as _attrs_define
|
|
5
|
-
from attrs import field as _attrs_field
|
|
6
|
-
|
|
7
|
-
from ..types import UNSET, Unset
|
|
8
|
-
|
|
9
|
-
T = TypeVar("T", bound="PostApiScenarioEventsBodyType2MessagesItemType1")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@_attrs_define
|
|
13
|
-
class PostApiScenarioEventsBodyType2MessagesItemType1:
|
|
14
|
-
"""
|
|
15
|
-
Attributes:
|
|
16
|
-
id (str):
|
|
17
|
-
role (Literal['system']):
|
|
18
|
-
content (str):
|
|
19
|
-
name (Union[Unset, str]):
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
id: str
|
|
23
|
-
role: Literal["system"]
|
|
24
|
-
content: str
|
|
25
|
-
name: Union[Unset, str] = UNSET
|
|
26
|
-
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
27
|
-
|
|
28
|
-
def to_dict(self) -> dict[str, Any]:
|
|
29
|
-
id = self.id
|
|
30
|
-
|
|
31
|
-
role = self.role
|
|
32
|
-
|
|
33
|
-
content = self.content
|
|
34
|
-
|
|
35
|
-
name = self.name
|
|
36
|
-
|
|
37
|
-
field_dict: dict[str, Any] = {}
|
|
38
|
-
field_dict.update(self.additional_properties)
|
|
39
|
-
field_dict.update(
|
|
40
|
-
{
|
|
41
|
-
"id": id,
|
|
42
|
-
"role": role,
|
|
43
|
-
"content": content,
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
if name is not UNSET:
|
|
47
|
-
field_dict["name"] = name
|
|
48
|
-
|
|
49
|
-
return field_dict
|
|
50
|
-
|
|
51
|
-
@classmethod
|
|
52
|
-
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
53
|
-
d = dict(src_dict)
|
|
54
|
-
id = d.pop("id")
|
|
55
|
-
|
|
56
|
-
role = cast(Literal["system"], d.pop("role"))
|
|
57
|
-
if role != "system":
|
|
58
|
-
raise ValueError(f"role must match const 'system', got '{role}'")
|
|
59
|
-
|
|
60
|
-
content = d.pop("content")
|
|
61
|
-
|
|
62
|
-
name = d.pop("name", UNSET)
|
|
63
|
-
|
|
64
|
-
post_api_scenario_events_body_type_2_messages_item_type_1 = cls(
|
|
65
|
-
id=id,
|
|
66
|
-
role=role,
|
|
67
|
-
content=content,
|
|
68
|
-
name=name,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
post_api_scenario_events_body_type_2_messages_item_type_1.additional_properties = d
|
|
72
|
-
return post_api_scenario_events_body_type_2_messages_item_type_1
|
|
73
|
-
|
|
74
|
-
@property
|
|
75
|
-
def additional_keys(self) -> list[str]:
|
|
76
|
-
return list(self.additional_properties.keys())
|
|
77
|
-
|
|
78
|
-
def __getitem__(self, key: str) -> Any:
|
|
79
|
-
return self.additional_properties[key]
|
|
80
|
-
|
|
81
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
82
|
-
self.additional_properties[key] = value
|
|
83
|
-
|
|
84
|
-
def __delitem__(self, key: str) -> None:
|
|
85
|
-
del self.additional_properties[key]
|
|
86
|
-
|
|
87
|
-
def __contains__(self, key: str) -> bool:
|
|
88
|
-
return key in self.additional_properties
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
from collections.abc import Mapping
|
|
2
|
-
from typing import TYPE_CHECKING, Any, Literal, TypeVar, Union, cast
|
|
3
|
-
|
|
4
|
-
from attrs import define as _attrs_define
|
|
5
|
-
from attrs import field as _attrs_field
|
|
6
|
-
|
|
7
|
-
from ..types import UNSET, Unset
|
|
8
|
-
|
|
9
|
-
if TYPE_CHECKING:
|
|
10
|
-
from ..models.post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item import (
|
|
11
|
-
PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItem,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
T = TypeVar("T", bound="PostApiScenarioEventsBodyType2MessagesItemType2")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@_attrs_define
|
|
19
|
-
class PostApiScenarioEventsBodyType2MessagesItemType2:
|
|
20
|
-
"""
|
|
21
|
-
Attributes:
|
|
22
|
-
id (str):
|
|
23
|
-
role (Literal['assistant']):
|
|
24
|
-
content (Union[Unset, str]):
|
|
25
|
-
name (Union[Unset, str]):
|
|
26
|
-
tool_calls (Union[Unset, list['PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItem']]):
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
id: str
|
|
30
|
-
role: Literal["assistant"]
|
|
31
|
-
content: Union[Unset, str] = UNSET
|
|
32
|
-
name: Union[Unset, str] = UNSET
|
|
33
|
-
tool_calls: Union[Unset, list["PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItem"]] = UNSET
|
|
34
|
-
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
35
|
-
|
|
36
|
-
def to_dict(self) -> dict[str, Any]:
|
|
37
|
-
id = self.id
|
|
38
|
-
|
|
39
|
-
role = self.role
|
|
40
|
-
|
|
41
|
-
content = self.content
|
|
42
|
-
|
|
43
|
-
name = self.name
|
|
44
|
-
|
|
45
|
-
tool_calls: Union[Unset, list[dict[str, Any]]] = UNSET
|
|
46
|
-
if not isinstance(self.tool_calls, Unset):
|
|
47
|
-
tool_calls = []
|
|
48
|
-
for tool_calls_item_data in self.tool_calls:
|
|
49
|
-
tool_calls_item = tool_calls_item_data.to_dict()
|
|
50
|
-
tool_calls.append(tool_calls_item)
|
|
51
|
-
|
|
52
|
-
field_dict: dict[str, Any] = {}
|
|
53
|
-
field_dict.update(self.additional_properties)
|
|
54
|
-
field_dict.update(
|
|
55
|
-
{
|
|
56
|
-
"id": id,
|
|
57
|
-
"role": role,
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
if content is not UNSET:
|
|
61
|
-
field_dict["content"] = content
|
|
62
|
-
if name is not UNSET:
|
|
63
|
-
field_dict["name"] = name
|
|
64
|
-
if tool_calls is not UNSET:
|
|
65
|
-
field_dict["toolCalls"] = tool_calls
|
|
66
|
-
|
|
67
|
-
return field_dict
|
|
68
|
-
|
|
69
|
-
@classmethod
|
|
70
|
-
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
71
|
-
from ..models.post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item import (
|
|
72
|
-
PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItem,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
d = dict(src_dict)
|
|
76
|
-
id = d.pop("id")
|
|
77
|
-
|
|
78
|
-
role = cast(Literal["assistant"], d.pop("role"))
|
|
79
|
-
if role != "assistant":
|
|
80
|
-
raise ValueError(f"role must match const 'assistant', got '{role}'")
|
|
81
|
-
|
|
82
|
-
content = d.pop("content", UNSET)
|
|
83
|
-
|
|
84
|
-
name = d.pop("name", UNSET)
|
|
85
|
-
|
|
86
|
-
tool_calls = []
|
|
87
|
-
_tool_calls = d.pop("toolCalls", UNSET)
|
|
88
|
-
for tool_calls_item_data in _tool_calls or []:
|
|
89
|
-
tool_calls_item = PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItem.from_dict(
|
|
90
|
-
tool_calls_item_data
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
tool_calls.append(tool_calls_item)
|
|
94
|
-
|
|
95
|
-
post_api_scenario_events_body_type_2_messages_item_type_2 = cls(
|
|
96
|
-
id=id,
|
|
97
|
-
role=role,
|
|
98
|
-
content=content,
|
|
99
|
-
name=name,
|
|
100
|
-
tool_calls=tool_calls,
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
post_api_scenario_events_body_type_2_messages_item_type_2.additional_properties = d
|
|
104
|
-
return post_api_scenario_events_body_type_2_messages_item_type_2
|
|
105
|
-
|
|
106
|
-
@property
|
|
107
|
-
def additional_keys(self) -> list[str]:
|
|
108
|
-
return list(self.additional_properties.keys())
|
|
109
|
-
|
|
110
|
-
def __getitem__(self, key: str) -> Any:
|
|
111
|
-
return self.additional_properties[key]
|
|
112
|
-
|
|
113
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
114
|
-
self.additional_properties[key] = value
|
|
115
|
-
|
|
116
|
-
def __delitem__(self, key: str) -> None:
|
|
117
|
-
del self.additional_properties[key]
|
|
118
|
-
|
|
119
|
-
def __contains__(self, key: str) -> bool:
|
|
120
|
-
return key in self.additional_properties
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
from collections.abc import Mapping
|
|
2
|
-
from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast
|
|
3
|
-
|
|
4
|
-
from attrs import define as _attrs_define
|
|
5
|
-
from attrs import field as _attrs_field
|
|
6
|
-
|
|
7
|
-
if TYPE_CHECKING:
|
|
8
|
-
from ..models.post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item_function import (
|
|
9
|
-
PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItemFunction,
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
T = TypeVar("T", bound="PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItem")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@_attrs_define
|
|
17
|
-
class PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItem:
|
|
18
|
-
"""
|
|
19
|
-
Attributes:
|
|
20
|
-
id (str):
|
|
21
|
-
type_ (Literal['function']):
|
|
22
|
-
function (PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItemFunction):
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
id: str
|
|
26
|
-
type_: Literal["function"]
|
|
27
|
-
function: "PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItemFunction"
|
|
28
|
-
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
29
|
-
|
|
30
|
-
def to_dict(self) -> dict[str, Any]:
|
|
31
|
-
id = self.id
|
|
32
|
-
|
|
33
|
-
type_ = self.type_
|
|
34
|
-
|
|
35
|
-
function = self.function.to_dict()
|
|
36
|
-
|
|
37
|
-
field_dict: dict[str, Any] = {}
|
|
38
|
-
field_dict.update(self.additional_properties)
|
|
39
|
-
field_dict.update(
|
|
40
|
-
{
|
|
41
|
-
"id": id,
|
|
42
|
-
"type": type_,
|
|
43
|
-
"function": function,
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
return field_dict
|
|
48
|
-
|
|
49
|
-
@classmethod
|
|
50
|
-
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
51
|
-
from ..models.post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item_function import (
|
|
52
|
-
PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItemFunction,
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
d = dict(src_dict)
|
|
56
|
-
id = d.pop("id")
|
|
57
|
-
|
|
58
|
-
type_ = cast(Literal["function"], d.pop("type"))
|
|
59
|
-
if type_ != "function":
|
|
60
|
-
raise ValueError(f"type must match const 'function', got '{type_}'")
|
|
61
|
-
|
|
62
|
-
function = PostApiScenarioEventsBodyType2MessagesItemType2ToolCallsItemFunction.from_dict(d.pop("function"))
|
|
63
|
-
|
|
64
|
-
post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item = cls(
|
|
65
|
-
id=id,
|
|
66
|
-
type_=type_,
|
|
67
|
-
function=function,
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item.additional_properties = d
|
|
71
|
-
return post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item
|
|
72
|
-
|
|
73
|
-
@property
|
|
74
|
-
def additional_keys(self) -> list[str]:
|
|
75
|
-
return list(self.additional_properties.keys())
|
|
76
|
-
|
|
77
|
-
def __getitem__(self, key: str) -> Any:
|
|
78
|
-
return self.additional_properties[key]
|
|
79
|
-
|
|
80
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
81
|
-
self.additional_properties[key] = value
|
|
82
|
-
|
|
83
|
-
def __delitem__(self, key: str) -> None:
|
|
84
|
-
del self.additional_properties[key]
|
|
85
|
-
|
|
86
|
-
def __contains__(self, key: str) -> bool:
|
|
87
|
-
return key in self.additional_properties
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
from collections.abc import Mapping
|
|
2
|
-
from typing import Any, Literal, TypeVar, Union, cast
|
|
3
|
-
|
|
4
|
-
from attrs import define as _attrs_define
|
|
5
|
-
from attrs import field as _attrs_field
|
|
6
|
-
|
|
7
|
-
from ..types import UNSET, Unset
|
|
8
|
-
|
|
9
|
-
T = TypeVar("T", bound="PostApiScenarioEventsBodyType2MessagesItemType3")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@_attrs_define
|
|
13
|
-
class PostApiScenarioEventsBodyType2MessagesItemType3:
|
|
14
|
-
"""
|
|
15
|
-
Attributes:
|
|
16
|
-
id (str):
|
|
17
|
-
role (Literal['user']):
|
|
18
|
-
content (str):
|
|
19
|
-
name (Union[Unset, str]):
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
id: str
|
|
23
|
-
role: Literal["user"]
|
|
24
|
-
content: str
|
|
25
|
-
name: Union[Unset, str] = UNSET
|
|
26
|
-
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
27
|
-
|
|
28
|
-
def to_dict(self) -> dict[str, Any]:
|
|
29
|
-
id = self.id
|
|
30
|
-
|
|
31
|
-
role = self.role
|
|
32
|
-
|
|
33
|
-
content = self.content
|
|
34
|
-
|
|
35
|
-
name = self.name
|
|
36
|
-
|
|
37
|
-
field_dict: dict[str, Any] = {}
|
|
38
|
-
field_dict.update(self.additional_properties)
|
|
39
|
-
field_dict.update(
|
|
40
|
-
{
|
|
41
|
-
"id": id,
|
|
42
|
-
"role": role,
|
|
43
|
-
"content": content,
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
if name is not UNSET:
|
|
47
|
-
field_dict["name"] = name
|
|
48
|
-
|
|
49
|
-
return field_dict
|
|
50
|
-
|
|
51
|
-
@classmethod
|
|
52
|
-
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
53
|
-
d = dict(src_dict)
|
|
54
|
-
id = d.pop("id")
|
|
55
|
-
|
|
56
|
-
role = cast(Literal["user"], d.pop("role"))
|
|
57
|
-
if role != "user":
|
|
58
|
-
raise ValueError(f"role must match const 'user', got '{role}'")
|
|
59
|
-
|
|
60
|
-
content = d.pop("content")
|
|
61
|
-
|
|
62
|
-
name = d.pop("name", UNSET)
|
|
63
|
-
|
|
64
|
-
post_api_scenario_events_body_type_2_messages_item_type_3 = cls(
|
|
65
|
-
id=id,
|
|
66
|
-
role=role,
|
|
67
|
-
content=content,
|
|
68
|
-
name=name,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
post_api_scenario_events_body_type_2_messages_item_type_3.additional_properties = d
|
|
72
|
-
return post_api_scenario_events_body_type_2_messages_item_type_3
|
|
73
|
-
|
|
74
|
-
@property
|
|
75
|
-
def additional_keys(self) -> list[str]:
|
|
76
|
-
return list(self.additional_properties.keys())
|
|
77
|
-
|
|
78
|
-
def __getitem__(self, key: str) -> Any:
|
|
79
|
-
return self.additional_properties[key]
|
|
80
|
-
|
|
81
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
82
|
-
self.additional_properties[key] = value
|
|
83
|
-
|
|
84
|
-
def __delitem__(self, key: str) -> None:
|
|
85
|
-
del self.additional_properties[key]
|
|
86
|
-
|
|
87
|
-
def __contains__(self, key: str) -> bool:
|
|
88
|
-
return key in self.additional_properties
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
from collections.abc import Mapping
|
|
2
|
-
from typing import Any, Literal, TypeVar, cast
|
|
3
|
-
|
|
4
|
-
from attrs import define as _attrs_define
|
|
5
|
-
from attrs import field as _attrs_field
|
|
6
|
-
|
|
7
|
-
T = TypeVar("T", bound="PostApiScenarioEventsBodyType2MessagesItemType4")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@_attrs_define
|
|
11
|
-
class PostApiScenarioEventsBodyType2MessagesItemType4:
|
|
12
|
-
"""
|
|
13
|
-
Attributes:
|
|
14
|
-
id (str):
|
|
15
|
-
content (str):
|
|
16
|
-
role (Literal['tool']):
|
|
17
|
-
tool_call_id (str):
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
id: str
|
|
21
|
-
content: str
|
|
22
|
-
role: Literal["tool"]
|
|
23
|
-
tool_call_id: str
|
|
24
|
-
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
25
|
-
|
|
26
|
-
def to_dict(self) -> dict[str, Any]:
|
|
27
|
-
id = self.id
|
|
28
|
-
|
|
29
|
-
content = self.content
|
|
30
|
-
|
|
31
|
-
role = self.role
|
|
32
|
-
|
|
33
|
-
tool_call_id = self.tool_call_id
|
|
34
|
-
|
|
35
|
-
field_dict: dict[str, Any] = {}
|
|
36
|
-
field_dict.update(self.additional_properties)
|
|
37
|
-
field_dict.update(
|
|
38
|
-
{
|
|
39
|
-
"id": id,
|
|
40
|
-
"content": content,
|
|
41
|
-
"role": role,
|
|
42
|
-
"toolCallId": tool_call_id,
|
|
43
|
-
}
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
return field_dict
|
|
47
|
-
|
|
48
|
-
@classmethod
|
|
49
|
-
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
50
|
-
d = dict(src_dict)
|
|
51
|
-
id = d.pop("id")
|
|
52
|
-
|
|
53
|
-
content = d.pop("content")
|
|
54
|
-
|
|
55
|
-
role = cast(Literal["tool"], d.pop("role"))
|
|
56
|
-
if role != "tool":
|
|
57
|
-
raise ValueError(f"role must match const 'tool', got '{role}'")
|
|
58
|
-
|
|
59
|
-
tool_call_id = d.pop("toolCallId")
|
|
60
|
-
|
|
61
|
-
post_api_scenario_events_body_type_2_messages_item_type_4 = cls(
|
|
62
|
-
id=id,
|
|
63
|
-
content=content,
|
|
64
|
-
role=role,
|
|
65
|
-
tool_call_id=tool_call_id,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
post_api_scenario_events_body_type_2_messages_item_type_4.additional_properties = d
|
|
69
|
-
return post_api_scenario_events_body_type_2_messages_item_type_4
|
|
70
|
-
|
|
71
|
-
@property
|
|
72
|
-
def additional_keys(self) -> list[str]:
|
|
73
|
-
return list(self.additional_properties.keys())
|
|
74
|
-
|
|
75
|
-
def __getitem__(self, key: str) -> Any:
|
|
76
|
-
return self.additional_properties[key]
|
|
77
|
-
|
|
78
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
79
|
-
self.additional_properties[key] = value
|
|
80
|
-
|
|
81
|
-
def __delitem__(self, key: str) -> None:
|
|
82
|
-
del self.additional_properties[key]
|
|
83
|
-
|
|
84
|
-
def __contains__(self, key: str) -> bool:
|
|
85
|
-
return key in self.additional_properties
|
langwatch/prompts/formatter.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
from typing import Dict, Any, List
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class MissingPromptVariableError(Exception):
|
|
6
|
-
def __init__(self, missing_vars: List[str]):
|
|
7
|
-
super().__init__(f"Missing variables for prompt: {', '.join(missing_vars)}")
|
|
8
|
-
self.missing_vars = missing_vars
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class PromptFormatter:
|
|
12
|
-
"""Formats prompt templates with provided variables using {{ var }} syntax."""
|
|
13
|
-
|
|
14
|
-
def format(self, template: str, variables: Dict[str, Any]) -> str:
|
|
15
|
-
# First check for any missing variables
|
|
16
|
-
missing_vars = []
|
|
17
|
-
for match in re.finditer(r"{{\s*(\w+)\s*}}", template):
|
|
18
|
-
var_name = match.group(1)
|
|
19
|
-
if var_name not in variables:
|
|
20
|
-
missing_vars.append(var_name)
|
|
21
|
-
|
|
22
|
-
if missing_vars:
|
|
23
|
-
raise MissingPromptVariableError(missing_vars)
|
|
24
|
-
|
|
25
|
-
# Replace all variables with their values
|
|
26
|
-
result = template
|
|
27
|
-
for var, value in variables.items():
|
|
28
|
-
# Replace {{ var }} with the value
|
|
29
|
-
result = re.sub(r"{{\s*" + re.escape(var) + r"\s*}}", str(value), result)
|
|
30
|
-
|
|
31
|
-
return result
|
|
File without changes
|