dhisana 0.0.1.dev267__py3-none-any.whl → 0.0.1.dev268__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.
@@ -330,22 +330,12 @@ async def _get_structured_output_with_web_search(
330
330
  "- After gathering information, provide your response in the required JSON format."
331
331
  )
332
332
 
333
- input_messages = [
333
+ # Build conversation history that we'll extend with tool calls/results
334
+ conversation_history = [
334
335
  {"role": "system", "content": system_content},
335
336
  {"role": "user", "content": prompt},
336
337
  ]
337
338
 
338
- base_request = {
339
- "input": input_messages,
340
- "model": model,
341
- "text": {"format": json_schema_format},
342
- "tools": tools,
343
- "store": False,
344
- }
345
-
346
- if model.startswith("o"):
347
- base_request["reasoning"] = {"effort": effort}
348
-
349
339
  max_tool_iterations = 10
350
340
  tool_iteration = 0
351
341
  completion = None
@@ -353,10 +343,22 @@ async def _get_structured_output_with_web_search(
353
343
  while tool_iteration < max_tool_iterations:
354
344
  tool_iteration += 1
355
345
 
346
+ # Build request with current conversation history
347
+ request = {
348
+ "input": conversation_history,
349
+ "model": model,
350
+ "text": {"format": json_schema_format},
351
+ "tools": tools,
352
+ "store": False,
353
+ }
354
+
355
+ if model.startswith("o"):
356
+ request["reasoning"] = {"effort": effort}
357
+
356
358
  # Retry logic for rate limits
357
359
  for attempt in range(2):
358
360
  try:
359
- completion = await client_async.responses.create(**base_request)
361
+ completion = await client_async.responses.create(**request)
360
362
  break
361
363
  except (RateLimitError, OpenAIError) as e:
362
364
  is_rl = (
@@ -386,46 +388,39 @@ async def _get_structured_output_with_web_search(
386
388
  # No tool calls, we have the final response
387
389
  break
388
390
 
389
- # Execute tool calls and prepare for next iteration
391
+ # Execute tool calls and add to conversation history
390
392
  logging.info(f"Processing {len(tool_calls)} web search tool call(s) in iteration {tool_iteration}")
391
393
 
392
- # Use previous_response_id for conversation threading
393
- if hasattr(completion, "id") and completion.id:
394
- base_request = {
395
- "model": model,
396
- "text": {"format": json_schema_format},
397
- "tools": tools,
398
- "store": False,
399
- "previous_response_id": completion.id,
400
- "input": [],
401
- }
402
- if model.startswith("o"):
403
- base_request["reasoning"] = {"effort": effort}
394
+ for tc in tool_calls:
395
+ func_name = getattr(tc, "name", "")
396
+ call_id = getattr(tc, "call_id", "")
397
+ args_str = getattr(tc, "arguments", "{}")
404
398
 
405
- for tc in tool_calls:
406
- func_name = getattr(tc, "name", "")
407
- call_id = getattr(tc, "call_id", "")
408
- args_str = getattr(tc, "arguments", "{}")
409
-
410
- try:
411
- args = json.loads(args_str) if args_str else {}
412
- except json.JSONDecodeError:
413
- args = {}
414
-
415
- # Execute the tool
416
- tool_result = await _execute_web_search_tool(func_name, args, tool_config)
417
-
418
- # Add tool result to input
419
- base_request["input"].append({
420
- "type": "function_call_output",
421
- "call_id": call_id,
422
- "output": tool_result
423
- })
424
-
425
- logging.info(f"Executed web search tool {func_name}, result length: {len(tool_result)}")
426
- else:
427
- logging.warning("No response ID available, breaking tool call loop")
428
- break
399
+ try:
400
+ args = json.loads(args_str) if args_str else {}
401
+ except json.JSONDecodeError:
402
+ args = {}
403
+
404
+ # Add the tool call to conversation history
405
+ conversation_history.append({
406
+ "type": "function_call",
407
+ "id": call_id,
408
+ "call_id": call_id,
409
+ "name": func_name,
410
+ "arguments": args_str,
411
+ })
412
+
413
+ # Execute the tool
414
+ tool_result = await _execute_web_search_tool(func_name, args, tool_config)
415
+
416
+ # Add tool result to conversation history
417
+ conversation_history.append({
418
+ "type": "function_call_output",
419
+ "call_id": call_id,
420
+ "output": tool_result,
421
+ })
422
+
423
+ logging.info(f"Executed web search tool {func_name}, result length: {len(tool_result)}")
429
424
 
430
425
  # Parse and return the final response
431
426
  return _parse_completion_response(completion, response_format, cache_key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dhisana
3
- Version: 0.0.1.dev267
3
+ Version: 0.0.1.dev268
4
4
  Summary: A Python SDK for Dhisana AI Platform
5
5
  Home-page: https://github.com/dhisana-ai/dhisana-python-sdk
6
6
  Author: Admin
@@ -45,7 +45,7 @@ dhisana/utils/generate_flow.py,sha256=QMn6bWo0nH0fBvy2Ebub1XfH5udnVAqsPsbIqCtQPX
45
45
  dhisana/utils/generate_leads_salesnav.py,sha256=FG7q6GSm9IywZ9TgQnn5_N3QNfiI-Qk2gaO_3GS99nY,12236
46
46
  dhisana/utils/generate_linkedin_connect_message.py,sha256=QxsxDiT-3eQOqAAbW13d0HGJXV36WYPvC-7Zsw_2VTI,10208
47
47
  dhisana/utils/generate_linkedin_response_message.py,sha256=mWoSs5p2JSTIoFZFGm86x1kgs67J7dHPvGKZPzcdGdU,14569
48
- dhisana/utils/generate_structured_output_internal.py,sha256=N1C-LhczMiJhNaDECeFJIY1vc9ta6cwkLWKxvdK4v7M,31266
48
+ dhisana/utils/generate_structured_output_internal.py,sha256=g3g685JxOnxoObvY_ILSiJ38584QmZJ9WofDBGBcSJ8,31056
49
49
  dhisana/utils/google_custom_search.py,sha256=5rQ4uAF-hjFpd9ooJkd6CjRvSmhZHhqM0jfHItsbpzk,10071
50
50
  dhisana/utils/google_oauth_tools.py,sha256=ReG5lCpXL3_e_s0yn6ai4U7B4-feOWHJVtbv_c0g0rE,28525
51
51
  dhisana/utils/google_workspace_tools.py,sha256=fuV0UcvAqF9drLzj7-p6D5zh7d5jMXl1jNJTICk4XOo,50224
@@ -95,8 +95,8 @@ dhisana/workflow/agent.py,sha256=esv7_i_XuMkV2j1nz_UlsHov_m6X5WZZiZm_tG4OBHU,565
95
95
  dhisana/workflow/flow.py,sha256=xWE3qQbM7j2B3FH8XnY3zOL_QXX4LbTW4ArndnEYJE0,1638
96
96
  dhisana/workflow/task.py,sha256=HlWz9mtrwLYByoSnePOemBUBrMEcj7KbgNjEE1oF5wo,1830
97
97
  dhisana/workflow/test.py,sha256=E7lRnXK0PguTNzyasHytLzTJdkqIPxG5_4qk4hMEeKc,3399
98
- dhisana-0.0.1.dev267.dist-info/METADATA,sha256=zAT6piCTBLFYagzP8-Vuogwo1s1meUG3ch_nk8yLiwg,1190
99
- dhisana-0.0.1.dev267.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
- dhisana-0.0.1.dev267.dist-info/entry_points.txt,sha256=jujxteZmNI9EkEaK-pOCoWuBujU8TCevdkfl9ZcKHek,49
101
- dhisana-0.0.1.dev267.dist-info/top_level.txt,sha256=NETTHt6YifG_P7XtRHbQiXZlgSFk9Qh9aR-ng1XTf4s,8
102
- dhisana-0.0.1.dev267.dist-info/RECORD,,
98
+ dhisana-0.0.1.dev268.dist-info/METADATA,sha256=8qz6BDU9YaSqUcBCWrW30PB5Mc6io2BCalfA58uQA2s,1190
99
+ dhisana-0.0.1.dev268.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
+ dhisana-0.0.1.dev268.dist-info/entry_points.txt,sha256=jujxteZmNI9EkEaK-pOCoWuBujU8TCevdkfl9ZcKHek,49
101
+ dhisana-0.0.1.dev268.dist-info/top_level.txt,sha256=NETTHt6YifG_P7XtRHbQiXZlgSFk9Qh9aR-ng1XTf4s,8
102
+ dhisana-0.0.1.dev268.dist-info/RECORD,,