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.
Files changed (49) hide show
  1. {pycoze-0.1.299 → pycoze-0.1.301}/PKG-INFO +1 -1
  2. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/api/__init__.py +5 -2
  3. pycoze-0.1.301/pycoze/api/lib/web.py +11 -0
  4. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/reference/bot.py +5 -7
  5. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/reference/lib.py +4 -5
  6. pycoze-0.1.301/pycoze/reference/tool.py +35 -0
  7. pycoze-0.1.301/pycoze/reference/workflow.py +45 -0
  8. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/PKG-INFO +1 -1
  9. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/SOURCES.txt +3 -2
  10. {pycoze-0.1.299 → pycoze-0.1.301}/setup.py +1 -1
  11. pycoze-0.1.299/pycoze/reference/tool.py +0 -49
  12. pycoze-0.1.299/pycoze/reference/workflow.py +0 -59
  13. {pycoze-0.1.299 → pycoze-0.1.301}/LICENSE +0 -0
  14. {pycoze-0.1.299 → pycoze-0.1.301}/README.md +0 -0
  15. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/__init__.py +0 -0
  16. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/__init__.py +0 -0
  17. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/__init__.py +0 -0
  18. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/chat.py +0 -0
  19. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/text_to_image_prompt.py +0 -0
  20. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/llm/think.py +0 -0
  21. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ai/vram_reserve.py +0 -0
  22. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/api/lib/__init__.py +0 -0
  23. /pycoze-0.1.299/pycoze/api/lib/tab_cls.py → /pycoze-0.1.301/pycoze/api/lib/tab.py +0 -0
  24. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/api/lib/view.py +0 -0
  25. /pycoze-0.1.299/pycoze/api/lib/window_cls.py → /pycoze-0.1.301/pycoze/api/lib/window.py +0 -0
  26. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/__init__.py +0 -0
  27. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/__init__.py +0 -0
  28. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent.py +0 -0
  29. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent_types/__init__.py +0 -0
  30. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent_types/const.py +0 -0
  31. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +0 -0
  32. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/assistant.py +0 -0
  33. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent/chat.py +0 -0
  34. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/agent_chat.py +0 -0
  35. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/bot/bot.py +0 -0
  36. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/reference/__init__.py +0 -0
  37. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/__init__.py +0 -0
  38. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/base.py +0 -0
  39. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/color.py +0 -0
  40. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/typ.py +0 -0
  41. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/ui/ui_def.py +0 -0
  42. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/__init__.py +0 -0
  43. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/arg.py +0 -0
  44. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/env.py +0 -0
  45. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/socket.py +0 -0
  46. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze/utils/text_or_file.py +0 -0
  47. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/dependency_links.txt +0 -0
  48. {pycoze-0.1.299 → pycoze-0.1.301}/pycoze.egg-info/top_level.txt +0 -0
  49. {pycoze-0.1.299 → pycoze-0.1.301}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pycoze
3
- Version: 0.1.299
3
+ Version: 0.1.301
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -1,13 +1,16 @@
1
- from .lib.window_cls import WindowCls
2
- from .lib.tab_cls import TabCls
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
@@ -0,0 +1,11 @@
1
+ from pycoze import utils
2
+
3
+
4
+ socket = utils.socket
5
+
6
+
7
+ class WebCls:
8
+ def get_simplified_webpage(self, url: str) -> str:
9
+ return socket.post_and_recv_result(
10
+ "getSimplifiedWebpage", {"url": url}
11
+ )
@@ -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, as_agent_tool=False, workspace_path=None):
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 = to_agent_tool(eval(random_name))
55
- tool.func = wrapped_func(tool, module_path)
56
- if tool.description is None:
57
- tool.description = "This tool is used to " + tool.name + "."
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(item, module_path):
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"调用了 {item.name}")
55
+ print(f"调用了 {func.__name__}")
57
56
  except:
58
57
  print(f"called unknown")
59
58
  with ChangeDirectoryAndPath(module_path):
60
- result = original_tool_function(*args, **kwargs)
59
+ result = func(*args, **kwargs)
61
60
  try:
62
61
  if isinstance(result, types.GeneratorType):
63
62
  result = list(result)
64
- print(f"{item.name} 调用完毕,结果为:", result)
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pycoze
3
- Version: 0.1.299
3
+ Version: 0.1.301
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -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/tab_cls.py
17
+ pycoze/api/lib/tab.py
18
18
  pycoze/api/lib/view.py
19
- pycoze/api/lib/window_cls.py
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
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="pycoze",
5
- version="0.1.299",
5
+ version="0.1.301",
6
6
  packages=find_packages(),
7
7
  install_requires=[],
8
8
  author="Yuan Jie Xiong",
@@ -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