openai-sdk-helpers 0.6.6__py3-none-any.whl → 0.7.0__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.
@@ -103,6 +103,9 @@ class ResponseBase(Generic[T]):
103
103
  openai_settings : OpenAISettings or None, default None
104
104
  Fully configured OpenAI settings with API key and default model.
105
105
  Required for normal operation.
106
+ save_messages : bool, default True
107
+ Default behavior for persisting message history on response runs
108
+ and close calls.
106
109
 
107
110
  Attributes
108
111
  ----------
@@ -169,6 +172,7 @@ class ResponseBase(Generic[T]):
169
172
  data_path: Path | str | None = None,
170
173
  tool_handlers: dict[str, ToolHandlerRegistration] | None = None,
171
174
  openai_settings: OpenAISettings | None = None,
175
+ save_messages: bool = True,
172
176
  ) -> None:
173
177
  """Initialize a response session with OpenAI configuration.
174
178
 
@@ -204,6 +208,9 @@ class ResponseBase(Generic[T]):
204
208
  openai_settings : OpenAISettings or None, default None
205
209
  Fully configured OpenAI settings with API key and default model.
206
210
  Required for normal operation.
211
+ save_messages : bool, default True
212
+ Default behavior for persisting message history on response runs
213
+ and close calls.
207
214
 
208
215
  Raises
209
216
  ------
@@ -247,6 +254,7 @@ class ResponseBase(Generic[T]):
247
254
  self._data_path = get_data_path(self.__class__.__name__)
248
255
 
249
256
  self._instructions = instructions
257
+ self._save_messages = save_messages
250
258
  self._tools: list[dict[str, Any]] | None = None
251
259
  if tools is not None:
252
260
  self._tools = [
@@ -314,7 +322,7 @@ class ResponseBase(Generic[T]):
314
322
 
315
323
  self.messages = ResponseMessages()
316
324
  self.messages.add_system_message(content=system_content)
317
- if self._data_path is not None:
325
+ if self._data_path is not None and self._save_messages:
318
326
  self.save()
319
327
 
320
328
  @property
@@ -509,7 +517,6 @@ class ResponseBase(Generic[T]):
509
517
  content: str | list[str],
510
518
  files: str | list[str] | None = None,
511
519
  use_vector_store: bool = False,
512
- save_messages: bool = True,
513
520
  ) -> T | str:
514
521
  """Generate a response asynchronously from the OpenAI API.
515
522
 
@@ -532,9 +539,6 @@ class ResponseBase(Generic[T]):
532
539
  use_vector_store : bool, default False
533
540
  If True, non-image files are uploaded to a vector store
534
541
  for RAG-enabled search instead of inline base64 encoding.
535
- save_messages : bool, default True
536
- When True, persist the message history after each response or
537
- tool call.
538
542
 
539
543
  Returns
540
544
  -------
@@ -625,7 +629,7 @@ class ResponseBase(Generic[T]):
625
629
  self.messages.add_tool_message(
626
630
  content=response_output, output=tool_output
627
631
  )
628
- if save_messages:
632
+ if self._save_messages:
629
633
  self.save()
630
634
  except Exception as exc:
631
635
  log(
@@ -651,7 +655,7 @@ class ResponseBase(Generic[T]):
651
655
  self.messages.add_assistant_message(
652
656
  response_output, metadata=kwargs
653
657
  )
654
- if save_messages:
658
+ if self._save_messages:
655
659
  self.save()
656
660
  if hasattr(response, "output_text") and response.output_text:
657
661
  raw_text = response.output_text
@@ -688,7 +692,6 @@ class ResponseBase(Generic[T]):
688
692
  *,
689
693
  files: str | list[str] | None = None,
690
694
  use_vector_store: bool = False,
691
- save_messages: bool = True,
692
695
  ) -> T | str:
693
696
  """Execute run_async synchronously with proper event loop handling.
694
697
 
@@ -711,9 +714,6 @@ class ResponseBase(Generic[T]):
711
714
  use_vector_store : bool, default False
712
715
  If True, non-image files are uploaded to a vector store
713
716
  for RAG-enabled search instead of inline base64 encoding.
714
- save_messages : bool, default True
715
- When True, persist the message history after each response or
716
- tool call.
717
717
 
718
718
  Returns
719
719
  -------
@@ -749,7 +749,6 @@ class ResponseBase(Generic[T]):
749
749
  content=content,
750
750
  files=files,
751
751
  use_vector_store=use_vector_store,
752
- save_messages=save_messages,
753
752
  )
754
753
 
755
754
  try:
@@ -1003,7 +1002,8 @@ class ResponseBase(Generic[T]):
1003
1002
  ... response.close()
1004
1003
  """
1005
1004
  log(f"Closing session {self.uuid} for {self.__class__.__name__}")
1006
- self.save()
1005
+ if self._save_messages:
1006
+ self.save()
1007
1007
 
1008
1008
  # Clean up tracked Files API uploads
1009
1009
  try:
@@ -102,6 +102,9 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
102
102
  system_vector_store : list[str], optional
103
103
  Optional list of vector store names to attach as system context.
104
104
  Default is None.
105
+ save_messages : bool, optional
106
+ Default behavior for persisting message history on response runs
107
+ and close calls. Default is True.
105
108
  add_output_instructions : bool, optional
106
109
  Whether to append output structure instructions to the prompt.
107
110
  Default is False.
@@ -114,6 +117,7 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
114
117
  If name is not a non-empty string.
115
118
  If instructions is not a string or Path.
116
119
  If tools is provided and is not a sequence.
120
+ If save_messages is not a bool.
117
121
  If input_structure or output_structure is not a class.
118
122
  If input_structure or output_structure does not subclass StructureBase.
119
123
  ValueError
@@ -158,6 +162,7 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
158
162
  input_structure: Optional[Type[TIn]]
159
163
  output_structure: Optional[Type[TOut]]
160
164
  system_vector_store: Optional[list[str]] = None
165
+ save_messages: bool = True
161
166
  add_output_instructions: bool = False
162
167
  add_web_search_tool: bool = False
163
168
 
@@ -204,6 +209,8 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
204
209
 
205
210
  if self.tools is not None and not isinstance(self.tools, Sequence):
206
211
  raise TypeError("Configuration.tools must be a Sequence or None")
212
+ if not isinstance(self.save_messages, bool):
213
+ raise TypeError("Configuration.save_messages must be a bool")
207
214
 
208
215
  @property
209
216
  def get_resolved_instructions(self) -> str:
@@ -274,6 +281,7 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
274
281
  data_path=data_path,
275
282
  tool_handlers=tool_handlers,
276
283
  openai_settings=openai_settings,
284
+ save_messages=self.save_messages,
277
285
  )
278
286
 
279
287
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openai-sdk-helpers
3
- Version: 0.6.6
3
+ Version: 0.7.0
4
4
  Summary: Composable helpers for OpenAI SDK agents, prompts, and storage
5
5
  Author: openai-sdk-helpers maintainers
6
6
  License: MIT
@@ -43,8 +43,8 @@ openai_sdk_helpers/prompt/vector_planner.jinja,sha256=szzuJu6ZawYWuARgQn4DykBLig
43
43
  openai_sdk_helpers/prompt/vector_search.jinja,sha256=KPEYQDRKsUesadSyQcBBiqYQEDL1NLN6BQsqw-GcKMA,249
44
44
  openai_sdk_helpers/prompt/vector_writer.jinja,sha256=q5osfexGvt1xn8ZPtBWUP36n_1HK_Ziu8dkmCZDVamc,342
45
45
  openai_sdk_helpers/response/__init__.py,sha256=YFrGpnMIfatnLWXAZgZDMvDx7Yjsqjat8W9INxKuPxY,1728
46
- openai_sdk_helpers/response/base.py,sha256=tR_COd8VziI7y8bEtL6LysjQgpZQfeBNEUwswzp0QxU,38719
47
- openai_sdk_helpers/response/configuration.py,sha256=jxneKd7oj08D40ceOWETB3TeUHd7Cnz-ooQp0akI9fA,10465
46
+ openai_sdk_helpers/response/base.py,sha256=8_dMff2qoAKQQVh-kaVAUFX52NcV-KUM3XsBp8_nA90,38760
47
+ openai_sdk_helpers/response/configuration.py,sha256=dfM21mAf-m7jX-kgTIHoDzWg72USWJj7JxTIk2hPbZ0,10859
48
48
  openai_sdk_helpers/response/files.py,sha256=O--boEPdFGsf9pHXPuNtG0aVJG2ZzwR4L1CZDW0hBP4,14450
49
49
  openai_sdk_helpers/response/messages.py,sha256=qX3sW79rLuJEys28zyv5MovZikwGOaLevzdVN0VYMRE,10104
50
50
  openai_sdk_helpers/response/planner.py,sha256=AuNMZkd4TGnvybSJaf2iMbvfPINbusrWucWBk2uQN_g,340
@@ -92,8 +92,8 @@ openai_sdk_helpers/vector_storage/__init__.py,sha256=L5LxO09puh9_yBB9IDTvc1CvVkA
92
92
  openai_sdk_helpers/vector_storage/cleanup.py,sha256=sZ4ZSTlnjF52o9Cc8A9dTX37ZYXXDxS_fdIpoOBWvrg,3666
93
93
  openai_sdk_helpers/vector_storage/storage.py,sha256=t_ukacaXRa9EXE4-3BxsrB4Rjhu6nTu7NA9IjCJBIpQ,24259
94
94
  openai_sdk_helpers/vector_storage/types.py,sha256=jTCcOYMeOpZWvcse0z4T3MVs-RBOPC-fqWTBeQrgafU,1639
95
- openai_sdk_helpers-0.6.6.dist-info/METADATA,sha256=cyg4hIimWHNrkSxsEwWZGOOmaBFAWtSHfL9JkGQXHxw,24622
96
- openai_sdk_helpers-0.6.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
97
- openai_sdk_helpers-0.6.6.dist-info/entry_points.txt,sha256=gEOD1ZeXe8d2OP-KzUlG-b_9D9yUZTCt-GFW3EDbIIY,63
98
- openai_sdk_helpers-0.6.6.dist-info/licenses/LICENSE,sha256=CUhc1NrE50bs45tcXF7OcTQBKEvkUuLqeOHgrWQ5jaA,1067
99
- openai_sdk_helpers-0.6.6.dist-info/RECORD,,
95
+ openai_sdk_helpers-0.7.0.dist-info/METADATA,sha256=jNBRE-vvRrvRlg4hBF3ar-vYNhBMDNSWLaOB41PjoPw,24622
96
+ openai_sdk_helpers-0.7.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
97
+ openai_sdk_helpers-0.7.0.dist-info/entry_points.txt,sha256=gEOD1ZeXe8d2OP-KzUlG-b_9D9yUZTCt-GFW3EDbIIY,63
98
+ openai_sdk_helpers-0.7.0.dist-info/licenses/LICENSE,sha256=CUhc1NrE50bs45tcXF7OcTQBKEvkUuLqeOHgrWQ5jaA,1067
99
+ openai_sdk_helpers-0.7.0.dist-info/RECORD,,