pycoze 0.1.320__py3-none-any.whl → 0.1.322__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 +2 -1
- pycoze/reference/lib.py +7 -10
- {pycoze-0.1.320.dist-info → pycoze-0.1.322.dist-info}/METADATA +1 -1
- {pycoze-0.1.320.dist-info → pycoze-0.1.322.dist-info}/RECORD +7 -7
- {pycoze-0.1.320.dist-info → pycoze-0.1.322.dist-info}/LICENSE +0 -0
- {pycoze-0.1.320.dist-info → pycoze-0.1.322.dist-info}/WHEEL +0 -0
- {pycoze-0.1.320.dist-info → pycoze-0.1.322.dist-info}/top_level.txt +0 -0
pycoze/bot/tools.py
CHANGED
@@ -4,10 +4,11 @@ import subprocess
|
|
4
4
|
import fnmatch
|
5
5
|
from typing import Dict
|
6
6
|
from .message import info
|
7
|
-
from .lib import get_formatted_filelist_str, read_local_file, resolve_relative_path
|
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
|
+
from pycoze.reference.lib import call_func
|
11
12
|
|
12
13
|
|
13
14
|
|
pycoze/reference/lib.py
CHANGED
@@ -7,14 +7,6 @@ import inspect
|
|
7
7
|
import asyncio
|
8
8
|
|
9
9
|
def call_func(func, args=None, kwargs=None):
|
10
|
-
"""
|
11
|
-
调用函数并处理普通函数、生成器函数和协程函数。
|
12
|
-
|
13
|
-
:param func: 要调用的函数
|
14
|
-
:param args: 位置参数(可选)
|
15
|
-
:param kwargs: 关键字参数(可选)
|
16
|
-
:return: 函数调用的结果
|
17
|
-
"""
|
18
10
|
if args is None:
|
19
11
|
args = ()
|
20
12
|
if kwargs is None:
|
@@ -23,8 +15,13 @@ def call_func(func, args=None, kwargs=None):
|
|
23
15
|
if inspect.isgeneratorfunction(func):
|
24
16
|
return list(func(*args, **kwargs))
|
25
17
|
elif inspect.iscoroutinefunction(func):
|
26
|
-
|
27
|
-
|
18
|
+
# 确保 func 是协程函数,而不是协程对象
|
19
|
+
coro = func(*args, **kwargs) if inspect.iscoroutinefunction(func) else func
|
20
|
+
try:
|
21
|
+
return asyncio.run(coro)
|
22
|
+
except RuntimeError:
|
23
|
+
loop = asyncio.get_event_loop()
|
24
|
+
return loop.run_until_complete(coro)
|
28
25
|
else:
|
29
26
|
return func(*args, **kwargs)
|
30
27
|
|
@@ -17,10 +17,10 @@ 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=R2GFWPjmgnvjMW24Ur7Fx9muA9tfZtykfERVjge_yiQ,9762
|
21
21
|
pycoze/reference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
pycoze/reference/bot.py,sha256=pxHVYo0G3P3YZ--vBYbMEiEyBoxxPwaO5dMTf9WFMSc,2014
|
23
|
-
pycoze/reference/lib.py,sha256=
|
23
|
+
pycoze/reference/lib.py,sha256=4NzmcevIyC1i3lzSPP5tJ1n1o-HZuilthiZpZYxrocU,2931
|
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.322.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
37
|
+
pycoze-0.1.322.dist-info/METADATA,sha256=WAfFg3nmxNdtgFDzv7eB7c2jSwkN3Gk1M7jVVZhgU70,854
|
38
|
+
pycoze-0.1.322.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
39
|
+
pycoze-0.1.322.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
40
|
+
pycoze-0.1.322.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|