unique_toolkit 1.45.6__py3-none-any.whl → 1.45.7__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.
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import logging
2
3
  from typing import Any, NamedTuple, Sequence
3
4
 
@@ -196,12 +197,23 @@ def _prepare_responses_params_util(
196
197
  log_exc_info=False,
197
198
  logger=logger,
198
199
  )
199
- def _attempt_extract_reasoning_from_options(options: dict) -> Reasoning | None:
200
- reasoning = None
200
+ def _attempt_extract_reasoning_from_options(
201
+ options: dict[str, Any],
202
+ ) -> Reasoning | None:
203
+ reasoning: dict[str, Any] | str | None = None
201
204
 
202
205
  # Responses API
203
206
  if "reasoning" in options:
204
207
  reasoning = options["reasoning"]
208
+ # Handle case where reasoning is stored as JSON string (UI limitation)
209
+ if isinstance(reasoning, str):
210
+ try:
211
+ reasoning = json.loads(reasoning)
212
+ except (json.JSONDecodeError, TypeError):
213
+ logger.warning(
214
+ f"Failed to parse reasoning as JSON string: {reasoning}. "
215
+ "Continuing with raw value."
216
+ )
205
217
 
206
218
  # Completions API
207
219
  elif "reasoning_effort" in options:
@@ -222,20 +234,28 @@ def _attempt_extract_reasoning_from_options(options: dict) -> Reasoning | None:
222
234
  logger=logger,
223
235
  )
224
236
  def _attempt_extract_verbosity_from_options(
225
- options: dict,
237
+ options: dict[str, Any],
226
238
  ) -> ResponseTextConfigParam | None:
227
- reasoning = None
239
+ if "verbosity" in options:
240
+ return TypeAdapter(ResponseTextConfigParam).validate_python(
241
+ {"verbosity": options["verbosity"]}
242
+ )
228
243
 
229
244
  # Responses API
230
245
  if "text" in options:
231
- reasoning = options["text"]
232
-
233
- # Completions API
234
- elif "verbosity" in options:
235
- reasoning = {"verbosity": options["verbosity"]}
236
-
237
- if reasoning is not None:
238
- return TypeAdapter(ResponseTextConfigParam).validate_python(reasoning)
246
+ text_config: dict[str, Any] | str = options["text"]
247
+ # Handle case where text is stored as JSON string (UI limitation)
248
+ if isinstance(text_config, str):
249
+ try:
250
+ text_config = json.loads(text_config)
251
+ return TypeAdapter(ResponseTextConfigParam).validate_python(text_config)
252
+ except (json.JSONDecodeError, TypeError):
253
+ logger.warning(
254
+ f"Failed to parse text as JSON string: {text_config}. "
255
+ "Continuing with raw value."
256
+ )
257
+ if isinstance(text_config, dict):
258
+ return TypeAdapter(ResponseTextConfigParam).validate_python(text_config)
239
259
 
240
260
  return None
241
261
 
@@ -283,42 +303,26 @@ def _prepare_responses_args(
283
303
 
284
304
  openai_options: unique_sdk.Integrated.CreateStreamResponsesOpenaiParams = {}
285
305
 
286
- if params.temperature is not None:
287
- openai_options["temperature"] = params.temperature
288
-
289
- if params.reasoning is not None:
290
- openai_options["reasoning"] = params.reasoning
291
-
292
- if params.text is not None:
293
- openai_options["text"] = params.text
294
-
295
- if include is not None:
296
- openai_options["include"] = include
297
-
298
- if instructions is not None:
299
- openai_options["instructions"] = instructions
300
-
301
- if max_output_tokens is not None:
302
- openai_options["max_output_tokens"] = max_output_tokens
303
-
304
- if metadata is not None:
305
- openai_options["metadata"] = metadata
306
-
307
- if parallel_tool_calls is not None:
308
- openai_options["parallel_tool_calls"] = parallel_tool_calls
309
-
310
- if tool_choice is not None:
311
- openai_options["tool_choice"] = tool_choice
312
-
313
- if params.tools is not None:
314
- openai_options["tools"] = params.tools
315
-
316
- if top_p is not None:
317
- openai_options["top_p"] = top_p
306
+ explicit_options = {
307
+ "temperature": params.temperature,
308
+ "reasoning": params.reasoning,
309
+ "text": params.text,
310
+ "include": include,
311
+ "instructions": instructions,
312
+ "max_output_tokens": max_output_tokens,
313
+ "metadata": metadata,
314
+ "parallel_tool_calls": parallel_tool_calls,
315
+ "tool_choice": tool_choice,
316
+ "tools": params.tools,
317
+ "top_p": top_p,
318
+ }
319
+
320
+ openai_options.update({k: v for k, v in explicit_options.items() if v is not None}) # type: ignore[arg-type]
318
321
 
319
322
  # allow any other openai.resources.responses.Response.create options
320
323
  if other_options is not None:
321
- openai_options.update(other_options) # type: ignore
324
+ for k, v in other_options.items():
325
+ openai_options.setdefault(k, v) # type: ignore
322
326
 
323
327
  options["options"] = openai_options
324
328
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 1.45.6
3
+ Version: 1.45.7
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Cedric Klinkert
@@ -125,8 +125,13 @@ All notable changes to this project will be documented in this file.
125
125
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
126
126
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
127
127
 
128
+ ## [1.45.7] - 2026-01-30
129
+ - Add JSON string parsing support for reasoning and text parameters in responses API (UI compatibility)
130
+ - Fix variable name bug in `_attempt_extract_verbosity_from_options` function
131
+ - Improve `other_options` handling to prevent overwriting explicitly set parameters
132
+
128
133
  ## [1.45.6] - 2026-01-30
129
- - hallucination evaluator: Use original response to retrieve referenced chunk
134
+ - hallucination evaluator: Use original response to retrieve referenced chunk
130
135
 
131
136
  ## [1.45.5] - 2026-01-29
132
137
  - Add HTML rendering support for code interpreter generated files
@@ -195,7 +195,7 @@ unique_toolkit/chat/constants.py,sha256=05kq6zjqUVB2d6_P7s-90nbljpB3ryxwCI-CAz0r
195
195
  unique_toolkit/chat/deprecated/service.py,sha256=CYwzXi7OB0RjHd73CO2jq8SlpdBmDYLatzPFkb5sA0k,6529
196
196
  unique_toolkit/chat/functions.py,sha256=rF-WGMW1TXqeatHJSD5uGKwO7BGSEIFlS0VJwfE60O0,47874
197
197
  unique_toolkit/chat/rendering.py,sha256=c8YiV9oADRrJQ5A_QBJ4_UFc0NZ-2vVaa7tupoMusso,880
198
- unique_toolkit/chat/responses_api.py,sha256=K_3lY8PUmey2io_enx_WY3hxE7TmMZueeIBG2hYa8KY,14466
198
+ unique_toolkit/chat/responses_api.py,sha256=r_jywsfVI-Kyzm6R-jFmSQQoFdUSel9mmoNnQYe9cls,15156
199
199
  unique_toolkit/chat/schemas.py,sha256=FJGFkTw7SKU_R9l_vWbcANMfBo978KH2X9psq6OIFfg,7048
200
200
  unique_toolkit/chat/service.py,sha256=6D00OL4QrGafbOhTaC5zNXaNgg7gS5W_2ePVa4LhqpE,4439
201
201
  unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,1445
@@ -254,7 +254,7 @@ unique_toolkit/short_term_memory/service.py,sha256=5PeVBu1ZCAfyDb2HLVvlmqSbyzBBu
254
254
  unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
255
255
  unique_toolkit/smart_rules/compile.py,sha256=Ozhh70qCn2yOzRWr9d8WmJeTo7AQurwd3tStgBMPFLA,1246
256
256
  unique_toolkit/test_utilities/events.py,sha256=_mwV2bs5iLjxS1ynDCjaIq-gjjKhXYCK-iy3dRfvO3g,6410
257
- unique_toolkit-1.45.6.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
258
- unique_toolkit-1.45.6.dist-info/METADATA,sha256=Ojrf6ABO88IO5h892iywEweJuc9p67MWzHMXa--40gE,49243
259
- unique_toolkit-1.45.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
260
- unique_toolkit-1.45.6.dist-info/RECORD,,
257
+ unique_toolkit-1.45.7.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
258
+ unique_toolkit-1.45.7.dist-info/METADATA,sha256=XahMDmU86Br2OPEJtdcQ6-6y65jFGzFj7QuD2SZGbSE,49534
259
+ unique_toolkit-1.45.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
260
+ unique_toolkit-1.45.7.dist-info/RECORD,,