pycoze 0.1.299__tar.gz → 0.1.301__tar.gz
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-0.1.299 → pycoze-0.1.301}/PKG-INFO +1 -1
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/api/__init__.py +5 -2
- pycoze-0.1.301/pycoze/api/lib/web.py +11 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/reference/bot.py +5 -7
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/reference/lib.py +4 -5
- pycoze-0.1.301/pycoze/reference/tool.py +35 -0
- pycoze-0.1.301/pycoze/reference/workflow.py +45 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/PKG-INFO +1 -1
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/SOURCES.txt +3 -2
- {pycoze-0.1.299 → pycoze-0.1.301}/setup.py +1 -1
- pycoze-0.1.299/pycoze/reference/tool.py +0 -49
- pycoze-0.1.299/pycoze/reference/workflow.py +0 -59
- {pycoze-0.1.299 → pycoze-0.1.301}/LICENSE +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/README.md +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/chat.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/text_to_image_prompt.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/think.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/vram_reserve.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/api/lib/__init__.py +0 -0
- /pycoze-0.1.299/pycoze/api/lib/tab_cls.py → /pycoze-0.1.301/pycoze/api/lib/tab.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/api/lib/view.py +0 -0
- /pycoze-0.1.299/pycoze/api/lib/window_cls.py → /pycoze-0.1.301/pycoze/api/lib/window.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent_types/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent_types/const.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/assistant.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/chat.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent_chat.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/bot.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/reference/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/base.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/color.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/typ.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/ui_def.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/__init__.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/arg.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/env.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/socket.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/text_or_file.py +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/dependency_links.txt +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/top_level.txt +0 -0
- {pycoze-0.1.299 → pycoze-0.1.301}/setup.cfg +0 -0
@@ -1,13 +1,16 @@
|
|
1
|
-
from .lib.
|
2
|
-
from .lib.
|
1
|
+
from .lib.window import WindowCls
|
2
|
+
from .lib.tab import TabCls
|
3
|
+
from .lib.web import WebCls
|
3
4
|
|
4
5
|
class Api:
|
5
6
|
def __init__(self) -> None:
|
6
7
|
self.window = WindowCls()
|
7
8
|
self.tab = TabCls()
|
9
|
+
self.web = WebCls()
|
8
10
|
|
9
11
|
api = Api()
|
10
12
|
window = api.window
|
11
13
|
tab = api.tab
|
14
|
+
web = api.web
|
12
15
|
|
13
16
|
# from ps_view import ViewCls, WebsiteViewCls, FileViewCls, DirectoryViewCls, WorkflowCls
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import os
|
2
|
-
from langchain.agents import tool as to_agent_tool
|
3
2
|
from .lib import ModuleManager, wrapped_func
|
4
3
|
import json
|
5
4
|
from pycoze import utils
|
@@ -9,7 +8,7 @@ bot_index = 0
|
|
9
8
|
params = utils.params
|
10
9
|
|
11
10
|
|
12
|
-
def ref_bot(bot_id,
|
11
|
+
def ref_bot(bot_id, workspace_path=None):
|
13
12
|
global bot_index
|
14
13
|
if workspace_path is None:
|
15
14
|
workspace_path = params["workspacePath"]
|
@@ -51,11 +50,10 @@ def {random_name}(command:str) -> str:
|
|
51
50
|
return result
|
52
51
|
"""
|
53
52
|
exec(function_code)
|
54
|
-
tool =
|
55
|
-
tool
|
56
|
-
|
57
|
-
|
58
|
-
return tool if as_agent_tool else tool.func
|
53
|
+
tool = eval(random_name)
|
54
|
+
tool = wrapped_func(tool, module_path)
|
55
|
+
|
56
|
+
return tool
|
59
57
|
except Exception as e:
|
60
58
|
print(f"Error loading bot {bot_id}: {e}")
|
61
59
|
return None
|
@@ -48,20 +48,19 @@ class ModuleManager:
|
|
48
48
|
del sys.modules[key]
|
49
49
|
|
50
50
|
|
51
|
-
def wrapped_func(
|
52
|
-
original_tool_function = item.func
|
51
|
+
def wrapped_func(func, module_path):
|
53
52
|
|
54
53
|
def _wrapped(*args, **kwargs):
|
55
54
|
try:
|
56
|
-
print(f"调用了 {
|
55
|
+
print(f"调用了 {func.__name__}")
|
57
56
|
except:
|
58
57
|
print(f"called unknown")
|
59
58
|
with ChangeDirectoryAndPath(module_path):
|
60
|
-
result =
|
59
|
+
result = func(*args, **kwargs)
|
61
60
|
try:
|
62
61
|
if isinstance(result, types.GeneratorType):
|
63
62
|
result = list(result)
|
64
|
-
print(f"{
|
63
|
+
print(f"{func.__name__} 调用完毕,结果为:", result)
|
65
64
|
except:
|
66
65
|
pass
|
67
66
|
return result
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import os
|
2
|
+
import importlib
|
3
|
+
from .lib import ModuleManager, wrapped_func
|
4
|
+
from pycoze import utils
|
5
|
+
|
6
|
+
|
7
|
+
params = utils.params
|
8
|
+
|
9
|
+
|
10
|
+
def ref_tools(tool_id, workspace_path=None):
|
11
|
+
if workspace_path is None:
|
12
|
+
workspace_path = params["workspacePath"]
|
13
|
+
tool_base_path = os.path.join(workspace_path, "User/Local/tool")
|
14
|
+
module_path = os.path.join(tool_base_path, tool_id)
|
15
|
+
module_path = os.path.normpath(os.path.abspath(module_path))
|
16
|
+
|
17
|
+
if not os.path.exists(module_path):
|
18
|
+
print(f"Tool {tool_id} not found")
|
19
|
+
return []
|
20
|
+
|
21
|
+
try:
|
22
|
+
with ModuleManager(module_path) as manager:
|
23
|
+
module = importlib.import_module("tool")
|
24
|
+
export_tools = getattr(module, "export_tools")
|
25
|
+
|
26
|
+
except Exception as e:
|
27
|
+
print(f"Error loading tool {tool_id}: {e}")
|
28
|
+
return []
|
29
|
+
|
30
|
+
for tool in export_tools:
|
31
|
+
tool = wrapped_func(tool, module_path)
|
32
|
+
if tool.__doc__ is None:
|
33
|
+
tool.__doc__ = "This tool is used to " + tool.name + "."
|
34
|
+
|
35
|
+
return [tool.func for tool in export_tools]
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import os
|
2
|
+
import importlib
|
3
|
+
from .lib import ModuleManager, wrapped_func
|
4
|
+
from pycoze import utils
|
5
|
+
|
6
|
+
|
7
|
+
params = utils.params
|
8
|
+
|
9
|
+
|
10
|
+
def _ref_workflows(workflow_id, workspace_path=None):
|
11
|
+
if workspace_path is None:
|
12
|
+
workspace_path = params["workspacePath"]
|
13
|
+
tool_base_path = os.path.join(workspace_path, "User/Local/workflow")
|
14
|
+
module_path = os.path.join(tool_base_path, workflow_id)
|
15
|
+
module_path = os.path.normpath(os.path.abspath(module_path))
|
16
|
+
|
17
|
+
if not os.path.exists(module_path):
|
18
|
+
print(f"Workflow {workflow_id} not found")
|
19
|
+
return []
|
20
|
+
|
21
|
+
try:
|
22
|
+
with ModuleManager(module_path) as manager:
|
23
|
+
module = importlib.import_module("tool")
|
24
|
+
export_tools = getattr(module, "export_tools")
|
25
|
+
|
26
|
+
except Exception as e:
|
27
|
+
print(f"Error loading workflow {workflow_id}: {e}")
|
28
|
+
return []
|
29
|
+
|
30
|
+
for tool in export_tools:
|
31
|
+
tool = wrapped_func(tool, module_path)
|
32
|
+
if tool.__doc__ is None:
|
33
|
+
tool.__doc__ = "This tool is used to " + tool.name + "."
|
34
|
+
|
35
|
+
return [tool.func for tool in export_tools]
|
36
|
+
|
37
|
+
|
38
|
+
def ref_workflow(workflow_id, workspace_path=None):
|
39
|
+
tools = _ref_workflows(
|
40
|
+
workflow_id, workspace_path=workspace_path
|
41
|
+
)
|
42
|
+
if len(tools) > 0:
|
43
|
+
return tools[0]
|
44
|
+
else:
|
45
|
+
return None
|
@@ -14,9 +14,10 @@ pycoze/ai/llm/text_to_image_prompt.py
|
|
14
14
|
pycoze/ai/llm/think.py
|
15
15
|
pycoze/api/__init__.py
|
16
16
|
pycoze/api/lib/__init__.py
|
17
|
-
pycoze/api/lib/
|
17
|
+
pycoze/api/lib/tab.py
|
18
18
|
pycoze/api/lib/view.py
|
19
|
-
pycoze/api/lib/
|
19
|
+
pycoze/api/lib/web.py
|
20
|
+
pycoze/api/lib/window.py
|
20
21
|
pycoze/bot/__init__.py
|
21
22
|
pycoze/bot/agent_chat.py
|
22
23
|
pycoze/bot/bot.py
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import importlib
|
3
|
-
from langchain.agents import tool as to_agent_tool
|
4
|
-
import types
|
5
|
-
import langchain_core
|
6
|
-
from .lib import ModuleManager, wrapped_func
|
7
|
-
from pycoze import utils
|
8
|
-
|
9
|
-
|
10
|
-
params = utils.params
|
11
|
-
|
12
|
-
|
13
|
-
def ref_tools(tool_id, as_agent_tool=False, workspace_path=None):
|
14
|
-
if workspace_path is None:
|
15
|
-
workspace_path = params["workspacePath"]
|
16
|
-
tool_base_path = os.path.join(workspace_path, "User/Local/tool")
|
17
|
-
module_path = os.path.join(tool_base_path, tool_id)
|
18
|
-
module_path = os.path.normpath(os.path.abspath(module_path))
|
19
|
-
|
20
|
-
if not os.path.exists(module_path):
|
21
|
-
print(f"Tool {tool_id} not found")
|
22
|
-
return []
|
23
|
-
|
24
|
-
try:
|
25
|
-
with ModuleManager(module_path) as manager:
|
26
|
-
module = importlib.import_module("tool")
|
27
|
-
export_tools = getattr(module, "export_tools")
|
28
|
-
valid_tools = []
|
29
|
-
for tool in export_tools:
|
30
|
-
assert isinstance(
|
31
|
-
tool, langchain_core.tools.StructuredTool
|
32
|
-
) or isinstance(
|
33
|
-
tool, types.FunctionType
|
34
|
-
), f"Tool is not a StructuredTool or function: {tool}"
|
35
|
-
if not isinstance(tool, langchain_core.tools.StructuredTool):
|
36
|
-
tool = to_agent_tool(tool)
|
37
|
-
valid_tools.append(tool)
|
38
|
-
export_tools = valid_tools
|
39
|
-
|
40
|
-
except Exception as e:
|
41
|
-
print(f"Error loading tool {tool_id}: {e}")
|
42
|
-
return []
|
43
|
-
|
44
|
-
for tool in export_tools:
|
45
|
-
tool.func = wrapped_func(tool, module_path)
|
46
|
-
if tool.description is None:
|
47
|
-
tool.description = "This tool is used to " + tool.name + "."
|
48
|
-
|
49
|
-
return export_tools if as_agent_tool else [tool.func for tool in export_tools]
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import importlib
|
3
|
-
from langchain.agents import tool as to_agent_tool
|
4
|
-
import types
|
5
|
-
import langchain_core
|
6
|
-
from .lib import ModuleManager, wrapped_func
|
7
|
-
from pycoze import utils
|
8
|
-
|
9
|
-
|
10
|
-
params = utils.params
|
11
|
-
|
12
|
-
|
13
|
-
def _ref_workflows(workflow_id, as_agent_tool=False, workspace_path=None):
|
14
|
-
if workspace_path is None:
|
15
|
-
workspace_path = params["workspacePath"]
|
16
|
-
tool_base_path = os.path.join(workspace_path, "User/Local/workflow")
|
17
|
-
module_path = os.path.join(tool_base_path, workflow_id)
|
18
|
-
module_path = os.path.normpath(os.path.abspath(module_path))
|
19
|
-
|
20
|
-
if not os.path.exists(module_path):
|
21
|
-
print(f"Workflow {workflow_id} not found")
|
22
|
-
return []
|
23
|
-
|
24
|
-
try:
|
25
|
-
with ModuleManager(module_path) as manager:
|
26
|
-
module = importlib.import_module("tool")
|
27
|
-
export_tools = getattr(module, "export_tools")
|
28
|
-
valid_tools = []
|
29
|
-
for tool in export_tools:
|
30
|
-
assert isinstance(
|
31
|
-
tool, langchain_core.tools.StructuredTool
|
32
|
-
) or isinstance(
|
33
|
-
tool, types.FunctionType
|
34
|
-
), f"Tool is not a StructuredTool or function: {tool}"
|
35
|
-
if not isinstance(tool, langchain_core.tools.StructuredTool):
|
36
|
-
tool = to_agent_tool(tool)
|
37
|
-
valid_tools.append(tool)
|
38
|
-
export_tools = valid_tools
|
39
|
-
|
40
|
-
except Exception as e:
|
41
|
-
print(f"Error loading workflow {workflow_id}: {e}")
|
42
|
-
return []
|
43
|
-
|
44
|
-
for tool in export_tools:
|
45
|
-
tool.func = wrapped_func(tool, module_path)
|
46
|
-
if tool.description is None:
|
47
|
-
tool.description = "This tool is used to " + tool.name + "."
|
48
|
-
|
49
|
-
return export_tools if as_agent_tool else [tool.func for tool in export_tools]
|
50
|
-
|
51
|
-
|
52
|
-
def ref_workflow(workflow_id, as_agent_tool=False, workspace_path=None):
|
53
|
-
tools = _ref_workflows(
|
54
|
-
workflow_id, as_agent_tool=as_agent_tool, workspace_path=workspace_path
|
55
|
-
)
|
56
|
-
if len(tools) > 0:
|
57
|
-
return tools[0]
|
58
|
-
else:
|
59
|
-
return None
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|