pycoze 0.1.337__py3-none-any.whl → 0.1.339__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/tools.py +1 -1
- pycoze/reference/__init__.py +4 -0
- pycoze/reference/lib.py +16 -6
- {pycoze-0.1.337.dist-info → pycoze-0.1.339.dist-info}/METADATA +1 -1
- {pycoze-0.1.337.dist-info → pycoze-0.1.339.dist-info}/RECORD +8 -8
- {pycoze-0.1.337.dist-info → pycoze-0.1.339.dist-info}/LICENSE +0 -0
- {pycoze-0.1.337.dist-info → pycoze-0.1.339.dist-info}/WHEEL +0 -0
- {pycoze-0.1.337.dist-info → pycoze-0.1.339.dist-info}/top_level.txt +0 -0
pycoze/bot/tools.py
CHANGED
@@ -271,7 +271,7 @@ class ToolExecutor:
|
|
271
271
|
print("Execute tool error:", traceback.format_exc())
|
272
272
|
return False, False, traceback.format_exc()
|
273
273
|
try:
|
274
|
-
result = json.dumps(result, indent=4)
|
274
|
+
result = json.dumps(result, indent=4, ensure_ascii=False)
|
275
275
|
except:
|
276
276
|
return True, False, str(result)
|
277
277
|
return True, True,str(result)
|
pycoze/reference/__init__.py
CHANGED
pycoze/reference/lib.py
CHANGED
@@ -6,7 +6,6 @@ import inspect
|
|
6
6
|
import asyncio
|
7
7
|
import nest_asyncio
|
8
8
|
|
9
|
-
# 应用 nest_asyncio 补丁,以允许在已经运行的事件循环中再次运行事件循环
|
10
9
|
nest_asyncio.apply()
|
11
10
|
|
12
11
|
def call_func(func, args=None, kwargs=None):
|
@@ -17,19 +16,30 @@ def call_func(func, args=None, kwargs=None):
|
|
17
16
|
|
18
17
|
if inspect.isgeneratorfunction(func):
|
19
18
|
return list(func(*args, **kwargs))
|
19
|
+
elif inspect.isasyncgenfunction(func):
|
20
|
+
async def collect_async_gen():
|
21
|
+
return [item async for item in func(*args, **kwargs)]
|
22
|
+
|
23
|
+
try:
|
24
|
+
loop = asyncio.get_running_loop()
|
25
|
+
except RuntimeError:
|
26
|
+
return asyncio.run(collect_async_gen())
|
27
|
+
else:
|
28
|
+
async def run_async_gen():
|
29
|
+
return await collect_async_gen()
|
30
|
+
future = asyncio.ensure_future(run_async_gen())
|
31
|
+
while not future.done():
|
32
|
+
loop.run_until_complete(asyncio.sleep(0.1)) # 避免阻塞
|
33
|
+
return future.result()
|
20
34
|
elif inspect.iscoroutinefunction(func):
|
21
35
|
coro = func(*args, **kwargs) if inspect.iscoroutinefunction(func) else func
|
22
36
|
try:
|
23
|
-
# 尝试获取当前运行的事件循环
|
24
37
|
loop = asyncio.get_running_loop()
|
25
38
|
except RuntimeError:
|
26
|
-
# 如果没有运行的事件循环,使用 asyncio.run()
|
27
39
|
return asyncio.run(coro)
|
28
40
|
else:
|
29
|
-
# 如果事件循环已经在运行,直接调度协程并等待结果
|
30
41
|
async def run_coro():
|
31
42
|
return await coro
|
32
|
-
# 在当前事件循环中调度任务并等待完成
|
33
43
|
future = asyncio.ensure_future(run_coro())
|
34
44
|
while not future.done():
|
35
45
|
loop.run_until_complete(asyncio.sleep(0.1)) # 避免阻塞
|
@@ -96,7 +106,7 @@ def wrapped_func(func, module_path):
|
|
96
106
|
print(f"调用 {func.__name__} 时发生错误: {str(e)}")
|
97
107
|
raise
|
98
108
|
|
99
|
-
print(f"{func.__name__}
|
109
|
+
print(f"{func.__name__} 调用完毕")
|
100
110
|
|
101
111
|
return result
|
102
112
|
|
@@ -17,10 +17,10 @@ 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
19
|
pycoze/bot/prompt.md,sha256=OBxwUY6yiwEmusnUHhwixWYByrWX3BpwfxG_Gfas8UM,15783
|
20
|
-
pycoze/bot/tools.py,sha256=
|
21
|
-
pycoze/reference/__init__.py,sha256=
|
20
|
+
pycoze/bot/tools.py,sha256=23iDk0_myJcQDOErKm4LRGr1Foane1n_RNNKJPAmgdY,9953
|
21
|
+
pycoze/reference/__init__.py,sha256=zgqGqvmA9HaqytEM33B6vi0kQVk8IiCwJaXa22xsFz8,114
|
22
22
|
pycoze/reference/bot.py,sha256=pxHVYo0G3P3YZ--vBYbMEiEyBoxxPwaO5dMTf9WFMSc,2014
|
23
|
-
pycoze/reference/lib.py,sha256=
|
23
|
+
pycoze/reference/lib.py,sha256=T-oBOKxkus5dTouc0oDgfRzUyi6aTyY-FF4yX7SzF5M,3755
|
24
24
|
pycoze/reference/tool.py,sha256=h7G3KSoZYWq5IJu6E0-shIQ3XiJeJsgSM85GxEnhF98,1107
|
25
25
|
pycoze/reference/workflow.py,sha256=whQtw_FAxvlSbjow1oNFLdytPjjRs_pDBbQmNjaX6zc,1340
|
26
26
|
pycoze/ui/__init__.py,sha256=uaXet23wUk64TcZjpBX8qOx4aUhwA_ucrmcxy7Q4Qr4,929
|
@@ -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.339.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
37
|
+
pycoze-0.1.339.dist-info/METADATA,sha256=O64qlDEj4hFRWceBrrZId2enMEoPIzOwAGsaroifsSY,854
|
38
|
+
pycoze-0.1.339.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
39
|
+
pycoze-0.1.339.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
40
|
+
pycoze-0.1.339.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|