npcpy 1.3.11__py3-none-any.whl → 1.3.12__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.
- npcpy/serve.py +40 -9
- {npcpy-1.3.11.dist-info → npcpy-1.3.12.dist-info}/METADATA +1 -1
- {npcpy-1.3.11.dist-info → npcpy-1.3.12.dist-info}/RECORD +6 -6
- {npcpy-1.3.11.dist-info → npcpy-1.3.12.dist-info}/WHEEL +0 -0
- {npcpy-1.3.11.dist-info → npcpy-1.3.12.dist-info}/licenses/LICENSE +0 -0
- {npcpy-1.3.11.dist-info → npcpy-1.3.12.dist-info}/top_level.txt +0 -0
npcpy/serve.py
CHANGED
|
@@ -572,7 +572,7 @@ def fetch_messages_for_conversation(conversation_id):
|
|
|
572
572
|
try:
|
|
573
573
|
with engine.connect() as conn:
|
|
574
574
|
query = text("""
|
|
575
|
-
SELECT role, content, timestamp
|
|
575
|
+
SELECT role, content, timestamp, tool_calls, tool_results
|
|
576
576
|
FROM conversation_history
|
|
577
577
|
WHERE conversation_id = :conversation_id
|
|
578
578
|
ORDER BY timestamp ASC
|
|
@@ -580,14 +580,45 @@ def fetch_messages_for_conversation(conversation_id):
|
|
|
580
580
|
result = conn.execute(query, {"conversation_id": conversation_id})
|
|
581
581
|
messages = result.fetchall()
|
|
582
582
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
583
|
+
parsed_messages = []
|
|
584
|
+
for message in messages:
|
|
585
|
+
role = message[0]
|
|
586
|
+
content = message[1]
|
|
587
|
+
|
|
588
|
+
msg_dict = {
|
|
589
|
+
"role": role,
|
|
590
|
+
"content": content,
|
|
591
|
+
"timestamp": message[2],
|
|
588
592
|
}
|
|
589
|
-
|
|
590
|
-
|
|
593
|
+
|
|
594
|
+
# Handle tool messages - extract tool_call_id from content JSON
|
|
595
|
+
if role == "tool" and content:
|
|
596
|
+
try:
|
|
597
|
+
content_parsed = json.loads(content) if isinstance(content, str) else content
|
|
598
|
+
if isinstance(content_parsed, dict):
|
|
599
|
+
if "tool_call_id" in content_parsed:
|
|
600
|
+
msg_dict["tool_call_id"] = content_parsed["tool_call_id"]
|
|
601
|
+
if "tool_name" in content_parsed:
|
|
602
|
+
msg_dict["name"] = content_parsed["tool_name"]
|
|
603
|
+
if "content" in content_parsed:
|
|
604
|
+
msg_dict["content"] = content_parsed["content"]
|
|
605
|
+
except (json.JSONDecodeError, TypeError):
|
|
606
|
+
pass
|
|
607
|
+
|
|
608
|
+
# Parse tool_calls JSON if present (for assistant messages)
|
|
609
|
+
if message[3]:
|
|
610
|
+
try:
|
|
611
|
+
msg_dict["tool_calls"] = json.loads(message[3]) if isinstance(message[3], str) else message[3]
|
|
612
|
+
except (json.JSONDecodeError, TypeError):
|
|
613
|
+
pass
|
|
614
|
+
# Parse tool_results JSON if present
|
|
615
|
+
if message[4]:
|
|
616
|
+
try:
|
|
617
|
+
msg_dict["tool_results"] = json.loads(message[4]) if isinstance(message[4], str) else message[4]
|
|
618
|
+
except (json.JSONDecodeError, TypeError):
|
|
619
|
+
pass
|
|
620
|
+
parsed_messages.append(msg_dict)
|
|
621
|
+
return parsed_messages
|
|
591
622
|
except Exception as e:
|
|
592
623
|
print(f"Error fetching messages for conversation: {e}")
|
|
593
624
|
return []
|
|
@@ -3935,7 +3966,7 @@ def stream():
|
|
|
3935
3966
|
input_values=tool_args if isinstance(tool_args, dict) else {},
|
|
3936
3967
|
npc=npc_object
|
|
3937
3968
|
)
|
|
3938
|
-
tool_content = str(jinx_ctx)
|
|
3969
|
+
tool_content = str(jinx_ctx.get('output', '')) if isinstance(jinx_ctx, dict) else str(jinx_ctx)
|
|
3939
3970
|
except Exception as e:
|
|
3940
3971
|
tool_content = f"Jinx execution error: {str(e)}"
|
|
3941
3972
|
else:
|
|
@@ -7,7 +7,7 @@ npcpy/npc_array.py,sha256=fVTxcMiXV-lvltmuwaRnTU9D3ikPq3-7k5wzp7MA5OY,40224
|
|
|
7
7
|
npcpy/npc_compiler.py,sha256=9U6_F7qweURaL2nQgrF7I9OQEmYjOENmkBV-YChr3oM,118402
|
|
8
8
|
npcpy/npc_sysenv.py,sha256=VH7le3xwxHvO55ZYCG1e-gj8X5YTSIqbIiU6ifSqhss,38917
|
|
9
9
|
npcpy/npcs.py,sha256=eExuVsbTfrRobTRRptRpDm46jCLWUgbvy4_U7IUQo-c,744
|
|
10
|
-
npcpy/serve.py,sha256=
|
|
10
|
+
npcpy/serve.py,sha256=0jV4O-6j7efFDk1T_rrx-ZUom1c-dh0zNANlYMMKDYI,231461
|
|
11
11
|
npcpy/tools.py,sha256=A5_oVmZkzGnI3BI-NmneuxeXQq-r29PbpAZP4nV4jrc,5303
|
|
12
12
|
npcpy/data/__init__.py,sha256=1tcoChR-Hjn905JDLqaW9ElRmcISCTJdE7BGXPlym2Q,642
|
|
13
13
|
npcpy/data/audio.py,sha256=o4auV8DQrAmZ4y84U3SofiwEuq5-ZBjGEZipQ9zPpGQ,22816
|
|
@@ -53,8 +53,8 @@ npcpy/work/browser.py,sha256=p2PeaoZdAXipFuAgKCCB3aXXLE_p3yIRqC87KlZKZWc,679
|
|
|
53
53
|
npcpy/work/desktop.py,sha256=F3I8mUtJp6LAkXodsh8hGZIncoads6c_2Utty-0EdDA,2986
|
|
54
54
|
npcpy/work/plan.py,sha256=QyUwg8vElWiHuoS-xK4jXTxxHvkMD3VkaCEsCmrEPQk,8300
|
|
55
55
|
npcpy/work/trigger.py,sha256=P1Y8u1wQRsS2WACims_2IdkBEar-iBQix-2TDWoW0OM,9948
|
|
56
|
-
npcpy-1.3.
|
|
57
|
-
npcpy-1.3.
|
|
58
|
-
npcpy-1.3.
|
|
59
|
-
npcpy-1.3.
|
|
60
|
-
npcpy-1.3.
|
|
56
|
+
npcpy-1.3.12.dist-info/licenses/LICENSE,sha256=j0YPvce7Ng9e32zYOu0EmXjXeJ0Nwawd0RA3uSGGH4E,1070
|
|
57
|
+
npcpy-1.3.12.dist-info/METADATA,sha256=PowYAWEVkhhzpbRWFKJcntLCy8zseMTIccfLlTb7Cw0,37885
|
|
58
|
+
npcpy-1.3.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
59
|
+
npcpy-1.3.12.dist-info/top_level.txt,sha256=g1pbSvrOOncB74Bg5-J0Olg4V0A5VzDw-Xz5YObq8BU,6
|
|
60
|
+
npcpy-1.3.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|