praisonaiagents 0.0.115__py3-none-any.whl → 0.0.116__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.
@@ -364,6 +364,46 @@ class LLM:
364
364
 
365
365
  return messages, original_prompt
366
366
 
367
+ def _fix_array_schemas(self, schema: Dict) -> Dict:
368
+ """
369
+ Recursively fix array schemas by adding missing 'items' attribute.
370
+
371
+ This ensures compatibility with OpenAI's function calling format which
372
+ requires array types to specify the type of items they contain.
373
+
374
+ Args:
375
+ schema: The schema dictionary to fix
376
+
377
+ Returns:
378
+ dict: The fixed schema
379
+ """
380
+ if not isinstance(schema, dict):
381
+ return schema
382
+
383
+ # Create a copy to avoid modifying the original
384
+ fixed_schema = schema.copy()
385
+
386
+ # Fix array types at the current level
387
+ if fixed_schema.get("type") == "array" and "items" not in fixed_schema:
388
+ # Add a default items schema for arrays without it
389
+ fixed_schema["items"] = {"type": "string"}
390
+
391
+ # Recursively fix nested schemas in properties
392
+ if "properties" in fixed_schema and isinstance(fixed_schema["properties"], dict):
393
+ fixed_properties = {}
394
+ for prop_name, prop_schema in fixed_schema["properties"].items():
395
+ if isinstance(prop_schema, dict):
396
+ fixed_properties[prop_name] = self._fix_array_schemas(prop_schema)
397
+ else:
398
+ fixed_properties[prop_name] = prop_schema
399
+ fixed_schema["properties"] = fixed_properties
400
+
401
+ # Fix items schema if it exists
402
+ if "items" in fixed_schema and isinstance(fixed_schema["items"], dict):
403
+ fixed_schema["items"] = self._fix_array_schemas(fixed_schema["items"])
404
+
405
+ return fixed_schema
406
+
367
407
  def _format_tools_for_litellm(self, tools: Optional[List[Any]]) -> Optional[List[Dict]]:
368
408
  """Format tools for LiteLLM - handles all tool formats.
369
409
 
@@ -389,7 +429,11 @@ class LLM:
389
429
  # Validate nested dictionary structure before accessing
390
430
  if 'function' in tool and isinstance(tool['function'], dict) and 'name' in tool['function']:
391
431
  logging.debug(f"Using pre-formatted OpenAI tool: {tool['function']['name']}")
392
- formatted_tools.append(tool)
432
+ # Fix array schemas in the tool parameters
433
+ fixed_tool = tool.copy()
434
+ if 'parameters' in fixed_tool['function']:
435
+ fixed_tool['function']['parameters'] = self._fix_array_schemas(fixed_tool['function']['parameters'])
436
+ formatted_tools.append(fixed_tool)
393
437
  else:
394
438
  logging.debug(f"Skipping malformed OpenAI tool: missing function or name")
395
439
  # Handle lists of tools (e.g. from MCP.to_openai_tool())
@@ -399,7 +443,11 @@ class LLM:
399
443
  # Validate nested dictionary structure before accessing
400
444
  if 'function' in subtool and isinstance(subtool['function'], dict) and 'name' in subtool['function']:
401
445
  logging.debug(f"Using pre-formatted OpenAI tool from list: {subtool['function']['name']}")
402
- formatted_tools.append(subtool)
446
+ # Fix array schemas in the tool parameters
447
+ fixed_tool = subtool.copy()
448
+ if 'parameters' in fixed_tool['function']:
449
+ fixed_tool['function']['parameters'] = self._fix_array_schemas(fixed_tool['function']['parameters'])
450
+ formatted_tools.append(fixed_tool)
403
451
  else:
404
452
  logging.debug(f"Skipping malformed OpenAI tool in list: missing function or name")
405
453
  elif callable(tool):
@@ -2153,7 +2201,7 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
2153
2201
  "function": {
2154
2202
  "name": function_name,
2155
2203
  "description": docstring.split('\n\n')[0] if docstring else "No description available",
2156
- "parameters": parameters
2204
+ "parameters": self._fix_array_schemas(parameters)
2157
2205
  }
2158
2206
  }
2159
2207
  logging.debug(f"Generated tool definition: {tool_def}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: praisonaiagents
3
- Version: 0.0.115
3
+ Version: 0.0.116
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
6
  Requires-Python: >=3.10
@@ -16,7 +16,7 @@ praisonaiagents/knowledge/__init__.py,sha256=xL1Eh-a3xsHyIcU4foOWF-JdWYIYBALJH9b
16
16
  praisonaiagents/knowledge/chunking.py,sha256=G6wyHa7_8V0_7VpnrrUXbEmUmptlT16ISJYaxmkSgmU,7678
17
17
  praisonaiagents/knowledge/knowledge.py,sha256=OKPar-XGyAp1ndmbOOdCgqFnTCqpOThYVSIZRxZyP58,15683
18
18
  praisonaiagents/llm/__init__.py,sha256=6lTeQ8jWi1-KiwjCDCmkHo2e-bRLq2dP0s5iJWqjO3s,1421
19
- praisonaiagents/llm/llm.py,sha256=z7o4tlKO0NJCqaXlnlwtPT768YjAB6tqNe_lg2KMTkk,111271
19
+ praisonaiagents/llm/llm.py,sha256=-IS6gEHYVsGDxlJjrHpsnon8b9bTrHm5qhdklMqepdo,113618
20
20
  praisonaiagents/llm/openai_client.py,sha256=0JvjCDHoH8I8kIt5vvObARkGdVaPWdTIv_FoEQ5EQPA,48973
21
21
  praisonaiagents/mcp/__init__.py,sha256=ibbqe3_7XB7VrIcUcetkZiUZS1fTVvyMy_AqCSFG8qc,240
22
22
  praisonaiagents/mcp/mcp.py,sha256=-fFx4MHffnN2woLnnV7Pzx3-1SFkn2j8Gp5F5ZIwKJ0,19698
@@ -53,7 +53,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
53
53
  praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
54
54
  praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
55
55
  praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
56
- praisonaiagents-0.0.115.dist-info/METADATA,sha256=LyLTXOuvVh59N40ZXt12UNSg25lfes40kEHun890Acg,1669
57
- praisonaiagents-0.0.115.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
- praisonaiagents-0.0.115.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
59
- praisonaiagents-0.0.115.dist-info/RECORD,,
56
+ praisonaiagents-0.0.116.dist-info/METADATA,sha256=5V4etTHb1-_EmiMICrUBgF4byjyNhrdC8Ona3pW8aPs,1669
57
+ praisonaiagents-0.0.116.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
+ praisonaiagents-0.0.116.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
59
+ praisonaiagents-0.0.116.dist-info/RECORD,,