baml-py 0.207.0__cp38-abi3-macosx_10_12_x86_64.whl → 0.208.0__cp38-abi3-macosx_10_12_x86_64.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.abi3.so CHANGED
Binary file
baml_py/baml_py.pyi CHANGED
@@ -335,6 +335,7 @@ class Collector:
335
335
  @property
336
336
  def usage(self) -> Usage: ...
337
337
  def id(self, function_log_id: str) -> Optional[FunctionLog]: ...
338
+ def clear(self) -> None: ...
338
339
  # For debugging
339
340
  @staticmethod
340
341
  def __function_call_count() -> int: ...
@@ -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.050)
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
- if event.is_ok():
167
- yield self.__partial_coerce(event)
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: baml-py
3
- Version: 0.207.0
3
+ Version: 0.208.0
4
4
  License-File: LICENSE
5
5
  Summary: BAML python bindings (pyproject.toml)
6
6
  Author-email: Boundary <contact@boundaryml.com>
@@ -0,0 +1,16 @@
1
+ baml_py-0.208.0.dist-info/METADATA,sha256=KucNdXX5xgHgSKWD_bil02ywbPiZpx04Ap2xDQozZlk,304
2
+ baml_py-0.208.0.dist-info/WHEEL,sha256=qq8T5RNN4nLzVDHWhr9aubnbXTyL36gsBivIyKvr8Qc,104
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=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
5
+ baml_py/__init__.py,sha256=_tXffmw8Be3rMDR8Zfivr1Gp-wL7baJ-guSoIRaOsBY,943
6
+ baml_py/baml_py.abi3.so,sha256=zGJGqnUxaynHxHR5-vDkQ0SbhK8SOxXPhNtChdpIYt8,49977808
7
+ baml_py/baml_py.pyi,sha256=FdvYxwEooT96gj8PoWbCRwW2quzyiXqL4SJXZpG2SFg,16919
8
+ baml_py/ctx_manager.py,sha256=JwWLvxFT05BnYiguzB-k-g47r7mft74L3mYt8e3qtus,6081
9
+ baml_py/errors.py,sha256=cpD5OlBuKIX8IbImwM_VgHzTz0gJqZJMhnEulXEajAE,431
10
+ baml_py/internal_monkeypatch.py,sha256=nuYufMyJQ3Nh3pWd1E7js_in2EZisFYzAD3N4KbCuVg,3598
11
+ baml_py/logging.py,sha256=zM-yKPJ3LF4qpIptYQVr5zw_Gjimy3deWlTt4dOzVp0,190
12
+ baml_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ baml_py/safe_import.py,sha256=ELnT9Jp1Z9ZqLZkbfmqYZ0vJpF-5dc2yshpryqn1UXE,2884
14
+ baml_py/stream.py,sha256=jcVYi3d6OXqrm39ne7ZMmLlTVIkDAuaFoerPhGs_ceg,8243
15
+ baml_py/type_builder.py,sha256=wDrMuEr2-9r2rjFbNOXIGf2g-zdd6y3n7jlb8cFNHZc,5615
16
+ baml_py-0.208.0.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- baml_py-0.207.0.dist-info/METADATA,sha256=MTrGM0Kr6NNjLawoGnPFvAtQGZl8sj75dusIdi6H4CI,304
2
- baml_py-0.207.0.dist-info/WHEEL,sha256=qq8T5RNN4nLzVDHWhr9aubnbXTyL36gsBivIyKvr8Qc,104
3
- baml_py-0.207.0.dist-info/entry_points.txt,sha256=C5Qb3JdnQK_6tOFKhrAJnEJsMSQzSoluojZp7aDNZGk,86
4
- baml_py-0.207.0.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
5
- baml_py/__init__.py,sha256=_tXffmw8Be3rMDR8Zfivr1Gp-wL7baJ-guSoIRaOsBY,943
6
- baml_py/baml_py.abi3.so,sha256=YdkZa30Vlor4TRPYXQ-uDeFo43zcGl6MMlmgvrw8BWs,47835800
7
- baml_py/baml_py.pyi,sha256=zxoG-X_D_H4txwzDlgMltTIDWpyNRxn0Os1ll1BjEWk,16886
8
- baml_py/ctx_manager.py,sha256=JwWLvxFT05BnYiguzB-k-g47r7mft74L3mYt8e3qtus,6081
9
- baml_py/errors.py,sha256=cpD5OlBuKIX8IbImwM_VgHzTz0gJqZJMhnEulXEajAE,431
10
- baml_py/internal_monkeypatch.py,sha256=JDwBPw4S8veD3nvJ13lFw8P5p29UOmDvvkgOy8eKA58,2106
11
- baml_py/logging.py,sha256=zM-yKPJ3LF4qpIptYQVr5zw_Gjimy3deWlTt4dOzVp0,190
12
- baml_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- baml_py/safe_import.py,sha256=ELnT9Jp1Z9ZqLZkbfmqYZ0vJpF-5dc2yshpryqn1UXE,2884
14
- baml_py/stream.py,sha256=pNfXDOa-6u4cjANaq071I6AevUx9N7DhDORc18Vh03k,6881
15
- baml_py/type_builder.py,sha256=wDrMuEr2-9r2rjFbNOXIGf2g-zdd6y3n7jlb8cFNHZc,5615
16
- baml_py-0.207.0.dist-info/RECORD,,