praisonaiagents 0.0.68__py3-none-any.whl → 0.0.69__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.
- praisonaiagents/llm/llm.py +60 -29
- {praisonaiagents-0.0.68.dist-info → praisonaiagents-0.0.69.dist-info}/METADATA +1 -1
- {praisonaiagents-0.0.68.dist-info → praisonaiagents-0.0.69.dist-info}/RECORD +5 -5
- {praisonaiagents-0.0.68.dist-info → praisonaiagents-0.0.69.dist-info}/WHEEL +0 -0
- {praisonaiagents-0.0.68.dist-info → praisonaiagents-0.0.69.dist-info}/top_level.txt +0 -0
praisonaiagents/llm/llm.py
CHANGED
@@ -436,15 +436,37 @@ class LLM:
|
|
436
436
|
|
437
437
|
# Handle tool calls
|
438
438
|
if tool_calls and execute_tool_fn:
|
439
|
+
# Convert tool_calls to a serializable format for all providers
|
440
|
+
serializable_tool_calls = []
|
441
|
+
for tc in tool_calls:
|
442
|
+
if isinstance(tc, dict):
|
443
|
+
serializable_tool_calls.append(tc) # Already a dict
|
444
|
+
else:
|
445
|
+
# Convert object to dict
|
446
|
+
serializable_tool_calls.append({
|
447
|
+
"id": tc.id,
|
448
|
+
"type": getattr(tc, 'type', "function"),
|
449
|
+
"function": {
|
450
|
+
"name": tc.function.name,
|
451
|
+
"arguments": tc.function.arguments
|
452
|
+
}
|
453
|
+
})
|
439
454
|
messages.append({
|
440
455
|
"role": "assistant",
|
441
456
|
"content": response_text,
|
442
|
-
"tool_calls":
|
457
|
+
"tool_calls": serializable_tool_calls
|
443
458
|
})
|
444
459
|
|
445
460
|
for tool_call in tool_calls:
|
446
|
-
|
447
|
-
|
461
|
+
# Handle both object and dict access patterns
|
462
|
+
if isinstance(tool_call, dict):
|
463
|
+
function_name = tool_call["function"]["name"]
|
464
|
+
arguments = json.loads(tool_call["function"]["arguments"])
|
465
|
+
tool_call_id = tool_call["id"]
|
466
|
+
else:
|
467
|
+
function_name = tool_call.function.name
|
468
|
+
arguments = json.loads(tool_call.function.arguments)
|
469
|
+
tool_call_id = tool_call.id
|
448
470
|
|
449
471
|
logging.debug(f"[TOOL_EXEC_DEBUG] About to execute tool {function_name} with args: {arguments}")
|
450
472
|
tool_result = execute_tool_fn(function_name, arguments)
|
@@ -462,18 +484,11 @@ class LLM:
|
|
462
484
|
logging.debug(f"[TOOL_EXEC_DEBUG] About to display tool call with message: {display_message}")
|
463
485
|
display_tool_call(display_message, console=console)
|
464
486
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
else:
|
471
|
-
logging.debug("[TOOL_EXEC_DEBUG] Verbose mode off, not displaying tool call")
|
472
|
-
messages.append({
|
473
|
-
"role": "tool",
|
474
|
-
"tool_call_id": tool_call["id"],
|
475
|
-
"content": "Function returned an empty output"
|
476
|
-
})
|
487
|
+
messages.append({
|
488
|
+
"role": "tool",
|
489
|
+
"tool_call_id": tool_call_id,
|
490
|
+
"content": json.dumps(tool_result) if tool_result is not None else "Function returned an empty output"
|
491
|
+
})
|
477
492
|
|
478
493
|
# If reasoning_steps is True, do a single non-streaming call
|
479
494
|
if reasoning_steps:
|
@@ -930,15 +945,37 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
|
|
930
945
|
tool_calls = tool_response.choices[0].message.get("tool_calls")
|
931
946
|
|
932
947
|
if tool_calls:
|
948
|
+
# Convert tool_calls to a serializable format for all providers
|
949
|
+
serializable_tool_calls = []
|
950
|
+
for tc in tool_calls:
|
951
|
+
if isinstance(tc, dict):
|
952
|
+
serializable_tool_calls.append(tc) # Already a dict
|
953
|
+
else:
|
954
|
+
# Convert object to dict
|
955
|
+
serializable_tool_calls.append({
|
956
|
+
"id": tc.id,
|
957
|
+
"type": getattr(tc, 'type', "function"),
|
958
|
+
"function": {
|
959
|
+
"name": tc.function.name,
|
960
|
+
"arguments": tc.function.arguments
|
961
|
+
}
|
962
|
+
})
|
933
963
|
messages.append({
|
934
964
|
"role": "assistant",
|
935
965
|
"content": response_text,
|
936
|
-
"tool_calls":
|
966
|
+
"tool_calls": serializable_tool_calls
|
937
967
|
})
|
938
968
|
|
939
969
|
for tool_call in tool_calls:
|
940
|
-
|
941
|
-
|
970
|
+
# Handle both object and dict access patterns
|
971
|
+
if isinstance(tool_call, dict):
|
972
|
+
function_name = tool_call["function"]["name"]
|
973
|
+
arguments = json.loads(tool_call["function"]["arguments"])
|
974
|
+
tool_call_id = tool_call["id"]
|
975
|
+
else:
|
976
|
+
function_name = tool_call.function.name
|
977
|
+
arguments = json.loads(tool_call.function.arguments)
|
978
|
+
tool_call_id = tool_call.id
|
942
979
|
|
943
980
|
tool_result = await execute_tool_fn(function_name, arguments)
|
944
981
|
|
@@ -949,17 +986,11 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
|
|
949
986
|
else:
|
950
987
|
display_message += "Function returned no output"
|
951
988
|
display_tool_call(display_message, console=console)
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
else:
|
958
|
-
messages.append({
|
959
|
-
"role": "tool",
|
960
|
-
"tool_call_id": tool_call.id,
|
961
|
-
"content": "Function returned an empty output"
|
962
|
-
})
|
989
|
+
messages.append({
|
990
|
+
"role": "tool",
|
991
|
+
"tool_call_id": tool_call_id,
|
992
|
+
"content": json.dumps(tool_result) if tool_result is not None else "Function returned an empty output"
|
993
|
+
})
|
963
994
|
|
964
995
|
# Get response after tool calls
|
965
996
|
response_text = ""
|
@@ -10,7 +10,7 @@ praisonaiagents/knowledge/__init__.py,sha256=xL1Eh-a3xsHyIcU4foOWF-JdWYIYBALJH9b
|
|
10
10
|
praisonaiagents/knowledge/chunking.py,sha256=FzoNY0q8MkvG4gADqk4JcRhmH3lcEHbRdonDgitQa30,6624
|
11
11
|
praisonaiagents/knowledge/knowledge.py,sha256=fQNREDiwdoisfIxJBLVkteXgq_8Gbypfc3UaZbxf5QY,13210
|
12
12
|
praisonaiagents/llm/__init__.py,sha256=ttPQQJQq6Tah-0updoEXDZFKWtJAM93rBWRoIgxRWO8,689
|
13
|
-
praisonaiagents/llm/llm.py,sha256=
|
13
|
+
praisonaiagents/llm/llm.py,sha256=9UhKoTcInXfCFFmQfBEzs3G0t4dJ4yoEpQ5eUG9VC0Q,76574
|
14
14
|
praisonaiagents/mcp/__init__.py,sha256=IkYdrAK1bDQDm_0t3Wjt63Zwv3_IJgqz84Wqz9GH2iQ,111
|
15
15
|
praisonaiagents/mcp/mcp.py,sha256=BPPf5AIPXx28PaJJqOg6T3NRyymQH9YAD-Km7Ma9-KA,13681
|
16
16
|
praisonaiagents/memory/memory.py,sha256=I8dOTkrl1i-GgQbDcrFOsSruzJ7MiI6Ys37DK27wrUs,35537
|
@@ -39,7 +39,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
|
|
39
39
|
praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
|
40
40
|
praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
|
41
41
|
praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
|
42
|
-
praisonaiagents-0.0.
|
43
|
-
praisonaiagents-0.0.
|
44
|
-
praisonaiagents-0.0.
|
45
|
-
praisonaiagents-0.0.
|
42
|
+
praisonaiagents-0.0.69.dist-info/METADATA,sha256=ymaq8EM2AZeNlbT-ISjYgHXMHbnHpX53O_Hkcrb5KtA,856
|
43
|
+
praisonaiagents-0.0.69.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
44
|
+
praisonaiagents-0.0.69.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
|
45
|
+
praisonaiagents-0.0.69.dist-info/RECORD,,
|
File without changes
|
File without changes
|