baml-py 0.207.1__cp38-abi3-win_amd64.whl → 0.208.0__cp38-abi3-win_amd64.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.
- baml_py/baml_py.pyd +0 -0
- baml_py/baml_py.pyi +1 -0
- baml_py/internal_monkeypatch.py +18 -3
- baml_py/stream.py +45 -7
- {baml_py-0.207.1.dist-info → baml_py-0.208.0.dist-info}/METADATA +1 -1
- baml_py-0.208.0.dist-info/RECORD +16 -0
- baml_py-0.207.1.dist-info/RECORD +0 -16
- {baml_py-0.207.1.dist-info → baml_py-0.208.0.dist-info}/WHEEL +0 -0
- {baml_py-0.207.1.dist-info → baml_py-0.208.0.dist-info}/entry_points.txt +0 -0
- {baml_py-0.207.1.dist-info → baml_py-0.208.0.dist-info}/licenses/LICENSE +0 -0
baml_py/baml_py.pyd
CHANGED
Binary file
|
baml_py/baml_py.pyi
CHANGED
baml_py/internal_monkeypatch.py
CHANGED
@@ -8,42 +8,57 @@ from typing import Optional
|
|
8
8
|
|
9
9
|
class BamlClientHttpError(BamlClientError):
|
10
10
|
"""Raised for HTTP-related client errors."""
|
11
|
-
def __init__(self, client_name: str, message: str, status_code: int):
|
11
|
+
def __init__(self, client_name: str, message: str, status_code: int, detailed_message: str):
|
12
12
|
super().__init__(message)
|
13
13
|
self.client_name = client_name
|
14
14
|
self.status_code = status_code
|
15
15
|
self.message = message
|
16
|
+
self.detailed_message = detailed_message
|
16
17
|
|
17
18
|
def __str__(self):
|
19
|
+
if self.detailed_message:
|
20
|
+
return f"BamlClientHttpError(client_name={self.client_name}, message={self.message}, status_code={self.status_code}, detailed_message={self.detailed_message})"
|
18
21
|
return f"BamlClientHttpError(client_name={self.client_name}, message={self.message}, status_code={self.status_code})"
|
19
22
|
|
20
23
|
def __repr__(self):
|
24
|
+
if self.detailed_message:
|
25
|
+
return f"BamlClientHttpError(client_name={self.client_name}, message={self.message}, status_code={self.status_code}, detailed_message={self.detailed_message})"
|
21
26
|
return f"BamlClientHttpError(client_name={self.client_name}, message={self.message}, status_code={self.status_code})"
|
22
27
|
|
23
28
|
|
24
29
|
class BamlValidationError(BamlError):
|
25
|
-
def __init__(self, prompt: str, message: str, raw_output: str):
|
30
|
+
def __init__(self, prompt: str, message: str, raw_output: str, detailed_message: str):
|
26
31
|
super().__init__(message)
|
27
32
|
self.prompt = prompt
|
28
33
|
self.message = message
|
29
34
|
self.raw_output = raw_output
|
35
|
+
self.detailed_message = detailed_message
|
30
36
|
|
31
37
|
def __str__(self):
|
38
|
+
if self.detailed_message:
|
39
|
+
return f"BamlValidationError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt}, detailed_message={self.detailed_message})"
|
32
40
|
return f"BamlValidationError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt})"
|
33
41
|
|
34
42
|
def __repr__(self):
|
43
|
+
if self.detailed_message:
|
44
|
+
return f"BamlValidationError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt}, detailed_message={self.detailed_message})"
|
35
45
|
return f"BamlValidationError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt})"
|
36
46
|
|
37
47
|
class BamlClientFinishReasonError(BamlError):
|
38
|
-
def __init__(self, prompt: str, message: str, raw_output: str, finish_reason: Optional[str]):
|
48
|
+
def __init__(self, prompt: str, message: str, raw_output: str, finish_reason: Optional[str], detailed_message: str):
|
39
49
|
super().__init__(message)
|
40
50
|
self.prompt = prompt
|
41
51
|
self.message = message
|
42
52
|
self.raw_output = raw_output
|
43
53
|
self.finish_reason = finish_reason
|
54
|
+
self.detailed_message = detailed_message
|
44
55
|
|
45
56
|
def __str__(self):
|
57
|
+
if self.detailed_message:
|
58
|
+
return f"BamlClientFinishReasonError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt}, finish_reason={self.finish_reason}, detailed_message={self.detailed_message})"
|
46
59
|
return f"BamlClientFinishReasonError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt}, finish_reason={self.finish_reason})"
|
47
60
|
|
48
61
|
def __repr__(self):
|
62
|
+
if self.detailed_message:
|
63
|
+
return f"BamlClientFinishReasonError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt}, finish_reason={self.finish_reason}, detailed_message={self.detailed_message})"
|
49
64
|
return f"BamlClientFinishReasonError(message={self.message}, raw_output={self.raw_output}, prompt={self.prompt}, finish_reason={self.finish_reason})"
|
baml_py/stream.py
CHANGED
@@ -81,12 +81,32 @@ class BamlStream(Generic[PartialOutputType, FinalOutputType]):
|
|
81
81
|
while True:
|
82
82
|
try:
|
83
83
|
event = self.__event_queue.get_nowait()
|
84
|
-
if event is None:
|
85
|
-
break
|
86
|
-
if event.is_ok():
|
87
|
-
yield self.__partial_coerce(event)
|
88
84
|
except queue.Empty:
|
89
|
-
await asyncio.sleep(0.
|
85
|
+
await asyncio.sleep(0.010)
|
86
|
+
continue
|
87
|
+
|
88
|
+
if event is None:
|
89
|
+
break
|
90
|
+
|
91
|
+
# Drain the queue to coalesce and keep only the most recent successful event.
|
92
|
+
latest_ok: Optional[FunctionResult] = event if event.is_ok() else None
|
93
|
+
done_seen = False
|
94
|
+
while True:
|
95
|
+
try:
|
96
|
+
nxt = self.__event_queue.get_nowait()
|
97
|
+
if nxt is None:
|
98
|
+
done_seen = True
|
99
|
+
break
|
100
|
+
if nxt.is_ok():
|
101
|
+
latest_ok = nxt
|
102
|
+
except queue.Empty:
|
103
|
+
break
|
104
|
+
|
105
|
+
if latest_ok is not None:
|
106
|
+
yield self.__partial_coerce(latest_ok)
|
107
|
+
|
108
|
+
if done_seen:
|
109
|
+
break
|
90
110
|
except Exception as e:
|
91
111
|
raise e
|
92
112
|
finally:
|
@@ -163,8 +183,26 @@ class BamlSyncStream(Generic[PartialOutputType, FinalOutputType]):
|
|
163
183
|
event = self.__event_queue.get()
|
164
184
|
if event is None:
|
165
185
|
break
|
166
|
-
|
167
|
-
|
186
|
+
|
187
|
+
# Drain the queue to coalesce and keep only the most recent successful event.
|
188
|
+
latest_ok: Optional[FunctionResult] = event if event.is_ok() else None
|
189
|
+
done_seen = False
|
190
|
+
while True:
|
191
|
+
try:
|
192
|
+
nxt = self.__event_queue.get_nowait()
|
193
|
+
if nxt is None:
|
194
|
+
done_seen = True
|
195
|
+
break
|
196
|
+
if nxt.is_ok():
|
197
|
+
latest_ok = nxt
|
198
|
+
except queue.Empty:
|
199
|
+
break
|
200
|
+
|
201
|
+
if latest_ok is not None:
|
202
|
+
yield self.__partial_coerce(latest_ok)
|
203
|
+
|
204
|
+
if done_seen:
|
205
|
+
break
|
168
206
|
except Exception as e:
|
169
207
|
raise e
|
170
208
|
finally:
|
@@ -0,0 +1,16 @@
|
|
1
|
+
baml_py-0.208.0.dist-info/METADATA,sha256=X4Kj5f65Bbxj2Cm0uavOCDWwrn7nWjbUaLTrduDkIdg,305
|
2
|
+
baml_py-0.208.0.dist-info/WHEEL,sha256=7bfl5v0wbVhXZba613g0x-n2obNNfpQuN8I1cQ4oaU8,94
|
3
|
+
baml_py-0.208.0.dist-info/entry_points.txt,sha256=C5Qb3JdnQK_6tOFKhrAJnEJsMSQzSoluojZp7aDNZGk,86
|
4
|
+
baml_py-0.208.0.dist-info/licenses/LICENSE,sha256=WtjCEwlcVzkh1ziO35P2qfVEkLjr87Flro7xlHz3CEY,11556
|
5
|
+
baml_py/__init__.py,sha256=iya4VPU6rBDBAjRnRVTjr0lsagfUV289picJ8HGZA34,991
|
6
|
+
baml_py/baml_py.pyd,sha256=yrIFfOv7DhmSX1cT1RChfIQditt6NnyXfSlREZqpuF4,56374272
|
7
|
+
baml_py/baml_py.pyi,sha256=P3NiOckhJwhdYN98yTiEyUh5kZ_nwNPHVQrRvnsMV2I,17475
|
8
|
+
baml_py/ctx_manager.py,sha256=KLsEi-clqnabNKR-R2hCoBd3SxY5uxZqBl1AFgfejng,6268
|
9
|
+
baml_py/errors.py,sha256=IVgxDwBuB_4S2WxYq3DMko_OVY2clNxNallEMDSwFAQ,453
|
10
|
+
baml_py/internal_monkeypatch.py,sha256=aiEc9WaQ0UEi84evpuY3E_xkrmsysFsMLH504urL_u4,3662
|
11
|
+
baml_py/logging.py,sha256=x5sJibE7KfT4YsnNgmyXbhzHu4xOwLtc4trbYHsYmzc,193
|
12
|
+
baml_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
+
baml_py/safe_import.py,sha256=gV6nMqBx-O6INutLxGSdfKzgtICx4WjXV40uz_NKwhQ,2971
|
14
|
+
baml_py/stream.py,sha256=RiKSTf8tKMVVm2b1y7ZPkoFhGJ1LsxEYHAQ1Xy6w8Vs,8468
|
15
|
+
baml_py/type_builder.py,sha256=qTEQSU3aZn-D9r_KS0z2sI6yo0XXbXA0h6gxN4nqcrU,5804
|
16
|
+
baml_py-0.208.0.dist-info/RECORD,,
|
baml_py-0.207.1.dist-info/RECORD
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
baml_py-0.207.1.dist-info/METADATA,sha256=C2Ep_vE1jRdunXGoa7Vde1QI5CI1vCkdsX314gGLO_M,305
|
2
|
-
baml_py-0.207.1.dist-info/WHEEL,sha256=7bfl5v0wbVhXZba613g0x-n2obNNfpQuN8I1cQ4oaU8,94
|
3
|
-
baml_py-0.207.1.dist-info/entry_points.txt,sha256=C5Qb3JdnQK_6tOFKhrAJnEJsMSQzSoluojZp7aDNZGk,86
|
4
|
-
baml_py-0.207.1.dist-info/licenses/LICENSE,sha256=WtjCEwlcVzkh1ziO35P2qfVEkLjr87Flro7xlHz3CEY,11556
|
5
|
-
baml_py/__init__.py,sha256=iya4VPU6rBDBAjRnRVTjr0lsagfUV289picJ8HGZA34,991
|
6
|
-
baml_py/baml_py.pyd,sha256=lYDbvnZzk4ZaQRIu2GZBdZaiUO6DB472zHYCeurDELE,54031360
|
7
|
-
baml_py/baml_py.pyi,sha256=gg13h4UKKXzSMg9OrgHL0Gm06qG36LBCxLdIrco-_SA,17441
|
8
|
-
baml_py/ctx_manager.py,sha256=KLsEi-clqnabNKR-R2hCoBd3SxY5uxZqBl1AFgfejng,6268
|
9
|
-
baml_py/errors.py,sha256=IVgxDwBuB_4S2WxYq3DMko_OVY2clNxNallEMDSwFAQ,453
|
10
|
-
baml_py/internal_monkeypatch.py,sha256=eX9LK0xtZqVpWYhCEqLPqYmP2NKzharE5j64h7CFFxI,2155
|
11
|
-
baml_py/logging.py,sha256=x5sJibE7KfT4YsnNgmyXbhzHu4xOwLtc4trbYHsYmzc,193
|
12
|
-
baml_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
baml_py/safe_import.py,sha256=gV6nMqBx-O6INutLxGSdfKzgtICx4WjXV40uz_NKwhQ,2971
|
14
|
-
baml_py/stream.py,sha256=cY9biE_V3SqOEQFqWTttW3wPOh7RhOHOD1fDifEylR8,7068
|
15
|
-
baml_py/type_builder.py,sha256=qTEQSU3aZn-D9r_KS0z2sI6yo0XXbXA0h6gxN4nqcrU,5804
|
16
|
-
baml_py-0.207.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|