pycoze 0.1.3__tar.gz → 0.1.5__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.3 → pycoze-0.1.5}/PKG-INFO +3 -2
- pycoze-0.1.5/README.md +14 -0
- pycoze-0.1.5/pycoze/__init__.py +3 -0
- pycoze-0.1.5/pycoze/ui/__init__.py +1 -0
- pycoze-0.1.5/pycoze/ui/base.py +45 -0
- pycoze-0.1.5/pycoze/ui/color.py +34 -0
- pycoze-0.1.5/pycoze/ui/typ.py +56 -0
- pycoze-0.1.5/pycoze/ui/ui_def.py +108 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/utils/arg.py +5 -3
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze.egg-info/PKG-INFO +3 -2
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze.egg-info/SOURCES.txt +5 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/setup.py +1 -1
- pycoze-0.1.3/README.md +0 -13
- pycoze-0.1.3/pycoze/__init__.py +0 -2
- {pycoze-0.1.3 → pycoze-0.1.5}/LICENSE +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/__init__.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/__init__.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/agent.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/agent_types/__init__.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/agent_types/react_agent.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/agent_types/react_prompt.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/assistant.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/agent/chat.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/base.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/bot/bot.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/module.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze/utils/__init__.py +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze.egg-info/dependency_links.txt +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/pycoze.egg-info/top_level.txt +0 -0
- {pycoze-0.1.3 → pycoze-0.1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pycoze
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
4
4
|
Summary: Package for pycoze only!
|
5
5
|
Author: Yuan Jie Xiong
|
6
6
|
Author-email: aiqqqqqqq@qq.com
|
@@ -21,6 +21,7 @@ Package for pycoze only!
|
|
21
21
|
<!-- pip install twine -->
|
22
22
|
|
23
23
|
<!-- 递增版本 -->
|
24
|
-
<!--
|
24
|
+
<!-- 修改src\renderer\layout\init\const.ts中的库版本要求 -->
|
25
|
+
<!-- 删除build和dist和pycoze.egg-info文件夹 -->
|
25
26
|
<!-- python setup.py sdist bdist_wheel -->
|
26
27
|
<!-- twine upload dist/* -->
|
pycoze-0.1.5/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# PYCOZE
|
2
|
+
|
3
|
+
Package for pycoze only!
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
<!-- For author only -->
|
8
|
+
<!-- pip install twine -->
|
9
|
+
|
10
|
+
<!-- 递增版本 -->
|
11
|
+
<!-- 修改src\renderer\layout\init\const.ts中的库版本要求 -->
|
12
|
+
<!-- 删除build和dist和pycoze.egg-info文件夹 -->
|
13
|
+
<!-- python setup.py sdist bdist_wheel -->
|
14
|
+
<!-- twine upload dist/* -->
|
@@ -0,0 +1 @@
|
|
1
|
+
from .ui_def import get_ui, get_ui_text, label, number, text, textarea, password, color, checkbox, single_select, multi_select, file, folder, folder_tree, image, audio, video, seed
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import json
|
2
|
+
from pycoze import utils
|
3
|
+
import json
|
4
|
+
import inspect
|
5
|
+
|
6
|
+
|
7
|
+
params_file = utils.read_arg('params_file', True)
|
8
|
+
with open(params_file, 'r', encoding='utf-8') as f:
|
9
|
+
params = json.load(f)
|
10
|
+
|
11
|
+
|
12
|
+
def get_ui():
|
13
|
+
stack = inspect.stack()
|
14
|
+
stack_files = list(reversed([s.filename.replace('\\', '/') for s in stack]))
|
15
|
+
match_item = None
|
16
|
+
for f in stack_files:
|
17
|
+
for v in params["uiRecords"]:
|
18
|
+
if v["uiFile"] == f:
|
19
|
+
match_item = v
|
20
|
+
break
|
21
|
+
if match_item:
|
22
|
+
break
|
23
|
+
|
24
|
+
if not match_item:
|
25
|
+
raise Exception("uiRecords not found for file")
|
26
|
+
|
27
|
+
by = match_item["by"]
|
28
|
+
|
29
|
+
for i in range(10):
|
30
|
+
try:
|
31
|
+
if by == 'file':
|
32
|
+
json_file = match_item["Jsonfile"]
|
33
|
+
with open(json_file, "r", encoding='utf-8') as f:
|
34
|
+
return json.load(f)
|
35
|
+
else:
|
36
|
+
assert by == 'node'
|
37
|
+
workflow_file = match_item["workflowFile"]
|
38
|
+
node_id = match_item["nodeId"]
|
39
|
+
with open(workflow_file, "r", encoding='utf-8') as f:
|
40
|
+
cells = json.load(f)["graph"]["cells"]
|
41
|
+
node = [cell for cell in cells if cell["id"] == node_id][0]
|
42
|
+
return json.loads(node["data"]["ui"])
|
43
|
+
except Exception as e:
|
44
|
+
if i == 9:
|
45
|
+
raise e
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from enum import Enum
|
2
|
+
|
3
|
+
class ColorFormat(Enum):
|
4
|
+
HEX = "hex"
|
5
|
+
RGB = "rgb"
|
6
|
+
HSL = "hsl"
|
7
|
+
|
8
|
+
|
9
|
+
def hex_to_rgb(hex_color):
|
10
|
+
# Convert HEX to RGB
|
11
|
+
hex_color = hex_color.lstrip('#')
|
12
|
+
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
13
|
+
|
14
|
+
|
15
|
+
def rgb_to_hsl(rgb):
|
16
|
+
r, g, b = rgb[0] / 255.0, rgb[1] / 255.0, rgb[2] / 255.0
|
17
|
+
max_val = max(r, g, b)
|
18
|
+
min_val = min(r, g, b)
|
19
|
+
lightness = (max_val + min_val) / 2 # 直接用l容易混淆
|
20
|
+
|
21
|
+
if max_val == min_val:
|
22
|
+
h, s = 0, 0
|
23
|
+
else:
|
24
|
+
d = max_val - min_val
|
25
|
+
s = d / (2 - max_val - min_val) if lightness > 0.5 else d / (max_val + min_val)
|
26
|
+
if max_val == r:
|
27
|
+
h = (g - b) / d + (6 if g < b else 0)
|
28
|
+
elif max_val == g:
|
29
|
+
h = (b - r) / d + 2
|
30
|
+
else:
|
31
|
+
h = (r - g) / d + 4
|
32
|
+
h /= 6
|
33
|
+
|
34
|
+
return h, s, lightness
|
@@ -0,0 +1,56 @@
|
|
1
|
+
def to_bool(v):
|
2
|
+
if v in ["True", "true", True]:
|
3
|
+
return True
|
4
|
+
elif v in ["False", "false", False]:
|
5
|
+
return False
|
6
|
+
else:
|
7
|
+
return None
|
8
|
+
|
9
|
+
|
10
|
+
def toType(val, typ):
|
11
|
+
val_type = type(val)
|
12
|
+
if typ in [str, float]:
|
13
|
+
return typ(val) if val_type != list else [typ(item) for item in val]
|
14
|
+
elif typ == int:
|
15
|
+
try:
|
16
|
+
return typ(val) if val_type != list else [typ(item) for item in val]
|
17
|
+
except:
|
18
|
+
return float(val) if val_type != list else [float(item) for item in val]
|
19
|
+
elif typ == bool:
|
20
|
+
return to_bool(val) if val_type != list else [to_bool(item) for item in val]
|
21
|
+
|
22
|
+
|
23
|
+
def useDefaultType(val, default):
|
24
|
+
val_type = type(val)
|
25
|
+
default_type = type(default)
|
26
|
+
|
27
|
+
# 根据 default 的类型进行转换
|
28
|
+
if default_type in [str, int, float, bool]:
|
29
|
+
try:
|
30
|
+
val = toType(val, default_type)
|
31
|
+
if val_type == list:
|
32
|
+
try:
|
33
|
+
val = val[0]
|
34
|
+
except:
|
35
|
+
return default
|
36
|
+
except:
|
37
|
+
return None
|
38
|
+
elif default_type == list:
|
39
|
+
try:
|
40
|
+
if len(default) > 0:
|
41
|
+
if val_type != list:
|
42
|
+
val = [useDefaultType(val, default[0])]
|
43
|
+
# 判断 default 列表中元素的类型,假设所有元素类型相同
|
44
|
+
if len(val) > 0:
|
45
|
+
element_type = type(default[0])
|
46
|
+
if type(val[0]) is element_type:
|
47
|
+
val = toType(val, element_type)
|
48
|
+
else:
|
49
|
+
val = []
|
50
|
+
else:
|
51
|
+
if val_type != list:
|
52
|
+
val = [val]
|
53
|
+
except:
|
54
|
+
return None
|
55
|
+
return val
|
56
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
from .base import get_ui
|
2
|
+
from .typ import useDefaultType
|
3
|
+
from typing import Union, List
|
4
|
+
from .color import hex_to_rgb, rgb_to_hsl, ColorFormat
|
5
|
+
import sys
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
def useDefault(name, default):
|
10
|
+
ui_data = get_ui()
|
11
|
+
if name not in ui_data:
|
12
|
+
return default
|
13
|
+
return useDefaultType(ui_data[name], default)
|
14
|
+
|
15
|
+
|
16
|
+
def get_ui_text():
|
17
|
+
ui = get_ui()
|
18
|
+
output = ''
|
19
|
+
for key, value in ui.items():
|
20
|
+
output += f'{key}: {value}\n'
|
21
|
+
return output
|
22
|
+
|
23
|
+
|
24
|
+
def label(name, tip="", hide_if="", style="", cls=""):
|
25
|
+
pass
|
26
|
+
|
27
|
+
|
28
|
+
def number(name,
|
29
|
+
default,
|
30
|
+
min=-sys.maxsize - 1,
|
31
|
+
max=sys.maxsize,
|
32
|
+
step=1,
|
33
|
+
tip="",
|
34
|
+
hide_if="",
|
35
|
+
style="",
|
36
|
+
cls="") -> Union[int, float]: # 注意Python3.9不兼容int|float
|
37
|
+
return useDefault(name, default)
|
38
|
+
|
39
|
+
|
40
|
+
def text(name, default, tip="", hide_if="", style="", cls="") -> str:
|
41
|
+
return useDefault(name, default)
|
42
|
+
|
43
|
+
|
44
|
+
def textarea(name, default, tip="", hide_if="", style="", cls="") -> str:
|
45
|
+
return useDefault(name, default)
|
46
|
+
|
47
|
+
|
48
|
+
def password(name, default, tip="", hide_if="", style="", cls="") -> str:
|
49
|
+
return useDefault(name, default)
|
50
|
+
|
51
|
+
|
52
|
+
def color(name, default, color_format: ColorFormat = "hex", tip="", hide_if="", style="", cls="") -> str:
|
53
|
+
rgbhex = useDefault(name, default)
|
54
|
+
if color_format == "hex":
|
55
|
+
return rgbhex
|
56
|
+
elif color_format == "rgb":
|
57
|
+
return hex_to_rgb(rgbhex)
|
58
|
+
elif color_format == "hsl":
|
59
|
+
return rgb_to_hsl(hex_to_rgb(rgbhex))
|
60
|
+
return rgbhex
|
61
|
+
|
62
|
+
|
63
|
+
def checkbox(name, default, tip="", hide_if="", style="", cls="") -> bool:
|
64
|
+
return useDefault(name, default)
|
65
|
+
|
66
|
+
|
67
|
+
def single_select(name, default: Union[str, int, float, bool], options, tip="", hide_if="", style="", cls=""):
|
68
|
+
return useDefault(name, default)
|
69
|
+
|
70
|
+
|
71
|
+
def multi_select(name,
|
72
|
+
default: Union[List[str], List[int], List[float], List[bool]],
|
73
|
+
options,
|
74
|
+
tip="",
|
75
|
+
hide_if="",
|
76
|
+
style="",
|
77
|
+
cls=""):
|
78
|
+
return useDefault(name, default)
|
79
|
+
|
80
|
+
|
81
|
+
def file(name, default: Union[str, List[str]], is_multiple: bool, tip="", hide_if="", style="", cls="") -> str:
|
82
|
+
return useDefault(name, default)
|
83
|
+
|
84
|
+
|
85
|
+
def folder(name, default: Union[str, List[str]], is_multiple: bool, tip="", hide_if="", style="", cls="") -> str:
|
86
|
+
return useDefault(name, default)
|
87
|
+
|
88
|
+
|
89
|
+
def folder_tree(name, root="", default: List[str] = None, tip="", hide_if="", style="", cls="") -> dict:
|
90
|
+
return get_ui()[name]
|
91
|
+
|
92
|
+
|
93
|
+
def image(name, default: Union[str, List[str]], is_multiple: bool=False, tip="", hide_if="", style="", cls="") -> str:
|
94
|
+
return useDefault(name, default)
|
95
|
+
|
96
|
+
|
97
|
+
def audio(name, default: Union[str, List[str]], is_multiple: bool=False, tip="", hide_if="", style="", cls="") -> str:
|
98
|
+
return useDefault(name, default)
|
99
|
+
|
100
|
+
|
101
|
+
def video(name, default: Union[str, List[str]], is_multiple: bool=False, tip="", hide_if="", style="", cls="") -> str:
|
102
|
+
return useDefault(name, default)
|
103
|
+
|
104
|
+
|
105
|
+
def seed(name, default=0, tip="", hide_if="", style="", cls="") -> int:
|
106
|
+
return useDefault(name, default)
|
107
|
+
|
108
|
+
|
@@ -1,13 +1,15 @@
|
|
1
1
|
import argparse
|
2
|
+
import sys
|
2
3
|
|
3
4
|
|
4
|
-
def read_arg(param
|
5
|
+
def read_arg(param, is_path=False):
|
6
|
+
args = sys.argv[1:]
|
5
7
|
parser = argparse.ArgumentParser()
|
6
8
|
parser.add_argument(param, nargs='?', help=f'Parameter {param}')
|
7
|
-
args = parser.
|
9
|
+
args = parser.parse_known_args(args)[0]
|
8
10
|
value = getattr(args, param.lstrip('-'))
|
9
11
|
# 如果是路径并且有引号,去掉引号
|
10
12
|
if is_path and value and value.startswith('"') and value.endswith('"'):
|
11
13
|
value = value[1:-1]
|
12
14
|
|
13
|
-
return value
|
15
|
+
return value
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pycoze
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
4
4
|
Summary: Package for pycoze only!
|
5
5
|
Author: Yuan Jie Xiong
|
6
6
|
Author-email: aiqqqqqqq@qq.com
|
@@ -21,6 +21,7 @@ Package for pycoze only!
|
|
21
21
|
<!-- pip install twine -->
|
22
22
|
|
23
23
|
<!-- 递增版本 -->
|
24
|
-
<!--
|
24
|
+
<!-- 修改src\renderer\layout\init\const.ts中的库版本要求 -->
|
25
|
+
<!-- 删除build和dist和pycoze.egg-info文件夹 -->
|
25
26
|
<!-- python setup.py sdist bdist_wheel -->
|
26
27
|
<!-- twine upload dist/* -->
|
@@ -18,5 +18,10 @@ pycoze/bot/agent/agent_types/__init__.py
|
|
18
18
|
pycoze/bot/agent/agent_types/openai_func_call_agent.py
|
19
19
|
pycoze/bot/agent/agent_types/react_agent.py
|
20
20
|
pycoze/bot/agent/agent_types/react_prompt.py
|
21
|
+
pycoze/ui/__init__.py
|
22
|
+
pycoze/ui/base.py
|
23
|
+
pycoze/ui/color.py
|
24
|
+
pycoze/ui/typ.py
|
25
|
+
pycoze/ui/ui_def.py
|
21
26
|
pycoze/utils/__init__.py
|
22
27
|
pycoze/utils/arg.py
|
pycoze-0.1.3/README.md
DELETED
pycoze-0.1.3/pycoze/__init__.py
DELETED
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
|