pycoze 0.1.335__py3-none-any.whl → 0.1.336__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.
- pycoze/bot/chat_base.py +5 -2
- pycoze/bot/prompt.md +2 -2
- pycoze/bot/tools.py +14 -10
- {pycoze-0.1.335.dist-info → pycoze-0.1.336.dist-info}/METADATA +1 -1
- {pycoze-0.1.335.dist-info → pycoze-0.1.336.dist-info}/RECORD +8 -8
- {pycoze-0.1.335.dist-info → pycoze-0.1.336.dist-info}/LICENSE +0 -0
- {pycoze-0.1.335.dist-info → pycoze-0.1.336.dist-info}/WHEEL +0 -0
- {pycoze-0.1.335.dist-info → pycoze-0.1.336.dist-info}/top_level.txt +0 -0
pycoze/bot/chat_base.py
CHANGED
@@ -206,7 +206,7 @@ async def handle_user_inputs(conversation_history, user_input, cwd, abilities, h
|
|
206
206
|
)
|
207
207
|
continue
|
208
208
|
|
209
|
-
ok, result = ToolExecutor.execute_tool(cwd, tool_request, abilities)
|
209
|
+
ok, is_json_dumps, result = ToolExecutor.execute_tool(cwd, tool_request, abilities)
|
210
210
|
if ok:
|
211
211
|
info("assistant", "✅\n")
|
212
212
|
else:
|
@@ -217,7 +217,10 @@ async def handle_user_inputs(conversation_history, user_input, cwd, abilities, h
|
|
217
217
|
+ "\n\nResult: "
|
218
218
|
+ result
|
219
219
|
)
|
220
|
-
|
220
|
+
if is_json_dumps:
|
221
|
+
info("assistant", "```json\n" + result + "\n```\n\n")
|
222
|
+
else:
|
223
|
+
info("assistant", "```text\n" + result + "\n```\n\n")
|
221
224
|
conversation_history.append(
|
222
225
|
{"role": "assistant", "content": assistant_content}
|
223
226
|
)
|
pycoze/bot/prompt.md
CHANGED
pycoze/bot/tools.py
CHANGED
@@ -2,13 +2,13 @@ import os
|
|
2
2
|
import re
|
3
3
|
import subprocess
|
4
4
|
import fnmatch
|
5
|
-
from typing import Dict
|
5
|
+
from typing import Dict, List
|
6
6
|
from .message import info
|
7
7
|
from .lib import get_formatted_filelist_str, read_local_file, resolve_relative_path
|
8
8
|
from pycoze import ai
|
9
9
|
from pycoze.api import window, web
|
10
10
|
import traceback
|
11
|
-
|
11
|
+
import json
|
12
12
|
|
13
13
|
|
14
14
|
class InvalidToolError(Exception):
|
@@ -254,13 +254,13 @@ class ToolExecutor:
|
|
254
254
|
}
|
255
255
|
|
256
256
|
@classmethod
|
257
|
-
def execute_tool(cls, cwd:str, tool_request, abilities) ->
|
257
|
+
def execute_tool(cls, cwd:str, tool_request, abilities) -> List[bool, bool, any]:
|
258
258
|
"""执行工具"""
|
259
259
|
try:
|
260
260
|
tool_name = list(tool_request.keys())[0]
|
261
261
|
params = tool_request[tool_name]
|
262
262
|
if not tool_name:
|
263
|
-
return False, "Error: Tool type is empty"
|
263
|
+
return False, False, "Error: Tool type is empty"
|
264
264
|
if tool_name in cls.TOOL_MAP:
|
265
265
|
tool_class = cls.TOOL_MAP[tool_name]
|
266
266
|
elif tool_name in [a.__name__ for a in abilities]:
|
@@ -269,13 +269,17 @@ class ToolExecutor:
|
|
269
269
|
result = func(**params)
|
270
270
|
except Exception as e:
|
271
271
|
print("Execute tool error:", traceback.format_exc())
|
272
|
-
return False, traceback.format_exc()
|
273
|
-
|
272
|
+
return False, False, traceback.format_exc()
|
273
|
+
try:
|
274
|
+
result = json.dumps(result, indent=4)
|
275
|
+
except:
|
276
|
+
return True, False, str(result)
|
277
|
+
return True, True,str(result)
|
274
278
|
else:
|
275
|
-
return False, f"Unknown tool: {tool_name}, the first key of output json ({tool_name}) will be recognized as a tool, so do not output other json except for executing tools."
|
279
|
+
return False, False, f"Unknown tool: {tool_name}, the first key of output json ({tool_name}) will be recognized as a tool, so do not output other json except for executing tools."
|
276
280
|
tool = tool_class(params, cwd)
|
277
281
|
if not tool.validate():
|
278
|
-
return False, "Tool parameter validation failed."
|
279
|
-
return True, tool.execute()
|
282
|
+
return False, False, "Tool parameter validation failed."
|
283
|
+
return True, False, tool.execute()
|
280
284
|
except Exception as e:
|
281
|
-
return False, f"Tool execution failed: {str(e)}"
|
285
|
+
return False, False, f"Tool execution failed: {str(e)}"
|
@@ -13,11 +13,11 @@ pycoze/api/lib/web.py,sha256=GWgtiTJOolKOX2drXcwuyqTcbo5FQVxa1NuBGcNyjyc,223
|
|
13
13
|
pycoze/api/lib/window.py,sha256=bTkQCzQZ7i3pYXB70bUSTBNJ9C4TW_X3yMae1VkquGk,1944
|
14
14
|
pycoze/bot/__init__.py,sha256=rL3Q-ycczRpSFfKn84fg3QBl5k22WpyeIU5qOEjEby8,79
|
15
15
|
pycoze/bot/chat.py,sha256=s12X8iOZa8MK-5VUd9JfzIA-gLxY80FJfphcfEx3b_s,3414
|
16
|
-
pycoze/bot/chat_base.py,sha256=
|
16
|
+
pycoze/bot/chat_base.py,sha256=7x1PhprjImWfzItm-1r3pwJyPEvXaQv8OKfqCPUwodw,9403
|
17
17
|
pycoze/bot/lib.py,sha256=smigeWuhl8esHE-Y5l_9bpjJkEJ5OqrxTyPcO8JIubM,7224
|
18
18
|
pycoze/bot/message.py,sha256=Zq-_k8HztBMOUIs3hbOvWvwHBNopn4UJJBliCROIGcc,718
|
19
|
-
pycoze/bot/prompt.md,sha256=
|
20
|
-
pycoze/bot/tools.py,sha256=
|
19
|
+
pycoze/bot/prompt.md,sha256=OBxwUY6yiwEmusnUHhwixWYByrWX3BpwfxG_Gfas8UM,15783
|
20
|
+
pycoze/bot/tools.py,sha256=oInV6JaVzjat9AvSpk7-zQapPR8LzrYR9zIs133ua-s,9931
|
21
21
|
pycoze/reference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
pycoze/reference/bot.py,sha256=pxHVYo0G3P3YZ--vBYbMEiEyBoxxPwaO5dMTf9WFMSc,2014
|
23
23
|
pycoze/reference/lib.py,sha256=ixiexCA6XWAda_G2ZVDSbFqTJmbkTvYLN47-nc5zyFU,3530
|
@@ -33,8 +33,8 @@ pycoze/utils/arg.py,sha256=jop1tBfe5hYkHW1NSpCeaZBEznkgguBscj_7M2dWfrs,503
|
|
33
33
|
pycoze/utils/env.py,sha256=5pWlXfM1F5ZU9hhv1rHlDEanjEW5wf0nbyez9bNRqqA,559
|
34
34
|
pycoze/utils/socket.py,sha256=bZbFFRH4mfThzRqt55BAAGQ6eICx_ja4x8UGGrUdAm8,2428
|
35
35
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
36
|
-
pycoze-0.1.
|
37
|
-
pycoze-0.1.
|
38
|
-
pycoze-0.1.
|
39
|
-
pycoze-0.1.
|
40
|
-
pycoze-0.1.
|
36
|
+
pycoze-0.1.336.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
37
|
+
pycoze-0.1.336.dist-info/METADATA,sha256=gt5s7WaW0VCwFrNxgGFARZuU6_PsS0Gk-qyMLyaAac4,854
|
38
|
+
pycoze-0.1.336.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
39
|
+
pycoze-0.1.336.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
40
|
+
pycoze-0.1.336.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|