pycoze 0.1.315__py3-none-any.whl → 0.1.317__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 +6 -2
- pycoze/bot/tools.py +27 -8
- {pycoze-0.1.315.dist-info → pycoze-0.1.317.dist-info}/METADATA +1 -1
- {pycoze-0.1.315.dist-info → pycoze-0.1.317.dist-info}/RECORD +7 -7
- {pycoze-0.1.315.dist-info → pycoze-0.1.317.dist-info}/LICENSE +0 -0
- {pycoze-0.1.315.dist-info → pycoze-0.1.317.dist-info}/WHEEL +0 -0
- {pycoze-0.1.315.dist-info → pycoze-0.1.317.dist-info}/top_level.txt +0 -0
pycoze/bot/chat_base.py
CHANGED
@@ -206,14 +206,18 @@ async def handle_user_inputs(conversation_history, user_input, cwd, abilities, b
|
|
206
206
|
)
|
207
207
|
continue
|
208
208
|
|
209
|
-
result = ToolExecutor.execute_tool(cwd, tool_request, abilities)
|
209
|
+
ok, result = ToolExecutor.execute_tool(cwd, tool_request, abilities)
|
210
|
+
if ok:
|
211
|
+
info("assistant", "✅\n")
|
212
|
+
else:
|
213
|
+
info("assistant", "❌\n")
|
210
214
|
assistant_content = (
|
211
215
|
"Executing tool: "
|
212
216
|
+ dumps_markdown_json(tool_request)
|
213
217
|
+ "\n\nResult: "
|
214
218
|
+ result
|
215
219
|
)
|
216
|
-
info("assistant", "
|
220
|
+
info("assistant", "```text\n" + result + "\n```\n\n")
|
217
221
|
conversation_history.append(
|
218
222
|
{"role": "assistant", "content": assistant_content}
|
219
223
|
)
|
pycoze/bot/tools.py
CHANGED
@@ -8,6 +8,25 @@ from .lib import get_formatted_filelist_str, read_local_file, resolve_relative_p
|
|
8
8
|
from pycoze import ai
|
9
9
|
from pycoze.api import window, web
|
10
10
|
import traceback
|
11
|
+
import inspect
|
12
|
+
import asyncio
|
13
|
+
|
14
|
+
async def handle_async_func(func, params):
|
15
|
+
return await func(**params)
|
16
|
+
|
17
|
+
def handle_generator_func(func, params):
|
18
|
+
return list(func(**params))
|
19
|
+
|
20
|
+
def handle_normal_func(func, params):
|
21
|
+
return func(**params)
|
22
|
+
|
23
|
+
def call_func(func, params):
|
24
|
+
if inspect.isgeneratorfunction(func):
|
25
|
+
return handle_generator_func(func, params)
|
26
|
+
elif inspect.iscoroutinefunction(func):
|
27
|
+
return asyncio.run(handle_async_func(func, params))
|
28
|
+
else:
|
29
|
+
return handle_normal_func(func, params)
|
11
30
|
|
12
31
|
|
13
32
|
class InvalidToolError(Exception):
|
@@ -259,21 +278,21 @@ class ToolExecutor:
|
|
259
278
|
tool_name = list(tool_request.keys())[0]
|
260
279
|
params = tool_request[tool_name]
|
261
280
|
if not tool_name:
|
262
|
-
return "Error: Tool type is empty"
|
281
|
+
return False, "Error: Tool type is empty"
|
263
282
|
if tool_name in cls.TOOL_MAP:
|
264
283
|
tool_class = cls.TOOL_MAP[tool_name]
|
265
284
|
elif tool_name in [a.__name__ for a in abilities]:
|
266
285
|
func = [a for a in abilities if a.__name__ == tool_name][0]
|
267
286
|
try:
|
268
|
-
result = func
|
287
|
+
result = call_func(func, params)
|
269
288
|
except Exception as e:
|
270
|
-
return traceback.format_exc()
|
271
|
-
return str(result)
|
289
|
+
return False, traceback.format_exc()
|
290
|
+
return True, str(result)
|
272
291
|
else:
|
273
|
-
return 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."
|
292
|
+
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."
|
274
293
|
tool = tool_class(params, cwd)
|
275
294
|
if not tool.validate():
|
276
|
-
return "Tool parameter validation failed."
|
277
|
-
return tool.execute()
|
295
|
+
return False, "Tool parameter validation failed."
|
296
|
+
return True, tool.execute()
|
278
297
|
except Exception as e:
|
279
|
-
return f"Tool execution failed: {str(e)}"
|
298
|
+
return 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=cYMXFe0hgN0CTcI5BiUtte2eTZwgYLKq1vBDQ-eqB5c,3246
|
16
|
-
pycoze/bot/chat_base.py,sha256=
|
16
|
+
pycoze/bot/chat_base.py,sha256=czmOKUum3Rwo4lAOJtfslxaF8RKauWzj26s_WMmQa48,9180
|
17
17
|
pycoze/bot/lib.py,sha256=IIihXPODCbM29TlxS0lhm2Fw3GWm2MzUeAn9LGa86lg,6889
|
18
18
|
pycoze/bot/message.py,sha256=Zq-_k8HztBMOUIs3hbOvWvwHBNopn4UJJBliCROIGcc,718
|
19
19
|
pycoze/bot/prompt.md,sha256=ehjdvZ-se9NaH0OSiDEvrFE9kvdj9MTZlWZUTxPY780,15743
|
20
|
-
pycoze/bot/tools.py,sha256=
|
20
|
+
pycoze/bot/tools.py,sha256=GKEkauxP0f7eSD-d2occKcip0swihFV2TAI5xxaPrV8,10187
|
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=6jvowP2LqjyV21ppRhmtxHxnQJHCbHmlpbj9btV2RQ4,2191
|
@@ -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.317.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
37
|
+
pycoze-0.1.317.dist-info/METADATA,sha256=oNdRRbYnG8Wneh6Y_b3SsSubGokqEarNQWs-_bzzZRA,854
|
38
|
+
pycoze-0.1.317.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
39
|
+
pycoze-0.1.317.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
40
|
+
pycoze-0.1.317.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|