pycoze 0.1.438__tar.gz → 0.1.440__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 (43) hide show
  1. {pycoze-0.1.438 → pycoze-0.1.440}/PKG-INFO +1 -1
  2. pycoze-0.1.440/pycoze/api/lib/web.py +65 -0
  3. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/bot/lib.py +2 -4
  4. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze.egg-info/PKG-INFO +1 -1
  5. {pycoze-0.1.438 → pycoze-0.1.440}/setup.py +1 -1
  6. pycoze-0.1.438/pycoze/api/lib/web.py +0 -16
  7. {pycoze-0.1.438 → pycoze-0.1.440}/LICENSE +0 -0
  8. {pycoze-0.1.438 → pycoze-0.1.440}/README.md +0 -0
  9. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/__init__.py +0 -0
  10. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ai/__init__.py +0 -0
  11. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ai/llm/__init__.py +0 -0
  12. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ai/llm/chat.py +0 -0
  13. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ai/llm/text_to_image_prompt.py +0 -0
  14. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/api/__init__.py +0 -0
  15. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/api/lib/__init__.py +0 -0
  16. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/api/lib/tab.py +0 -0
  17. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/api/lib/view.py +0 -0
  18. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/api/lib/window.py +0 -0
  19. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/bot/__init__.py +0 -0
  20. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/bot/chat.py +0 -0
  21. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/bot/chat_base.py +0 -0
  22. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/bot/message.py +0 -0
  23. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/bot/prompt.md +0 -0
  24. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/bot/tools.py +0 -0
  25. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/reference/__init__.py +0 -0
  26. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/reference/bot.py +0 -0
  27. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/reference/lib.py +0 -0
  28. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/reference/tool.py +0 -0
  29. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/reference/workflow.py +0 -0
  30. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ui/__init__.py +0 -0
  31. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ui/base.py +0 -0
  32. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ui/color.py +0 -0
  33. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ui/typ.py +0 -0
  34. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/ui/ui_def.py +0 -0
  35. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/utils/__init__.py +0 -0
  36. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/utils/arg.py +0 -0
  37. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/utils/env.py +0 -0
  38. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/utils/socket.py +0 -0
  39. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze/utils/text_or_file.py +0 -0
  40. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze.egg-info/SOURCES.txt +0 -0
  41. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze.egg-info/dependency_links.txt +0 -0
  42. {pycoze-0.1.438 → pycoze-0.1.440}/pycoze.egg-info/top_level.txt +0 -0
  43. {pycoze-0.1.438 → pycoze-0.1.440}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pycoze
3
- Version: 0.1.438
3
+ Version: 0.1.440
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -0,0 +1,65 @@
1
+ from pycoze import utils
2
+ from bs4 import BeautifulSoup, Comment
3
+
4
+
5
+ socket = utils.socket
6
+
7
+
8
+ class WebCls:
9
+ def get_simplified_webpage(self, url: str) -> str:
10
+ return socket.post_and_recv_result(
11
+ "getSimplifiedWebpage", {"url": url}
12
+ )
13
+
14
+ def get_simplified_html(self, html: str, selector=None) -> str:
15
+ soup = BeautifulSoup(html, 'html.parser')
16
+
17
+ # 如果指定了selector,则只提取该元素的内容
18
+ if selector:
19
+ element = soup.select_one(selector)
20
+ if element:
21
+ soup = BeautifulSoup(str(element), 'html.parser')
22
+
23
+ # 定义需要移除的标签
24
+ tags_to_remove = ['script', 'style', 'noscript', 'meta', 'link']
25
+ for tag in tags_to_remove:
26
+ for element in soup(tag):
27
+ element.decompose()
28
+
29
+ # 移除注释
30
+ for element in soup.find_all(string=lambda text: isinstance(text, Comment)):
31
+ element.extract()
32
+
33
+ # 定义需要保留的交互属性
34
+ INTERACTIVE_ATTRIBUTES = {
35
+ 'a': ['href', 'onclick'],
36
+ 'button': ['onclick'],
37
+ 'img': ['src', 'onload'],
38
+ 'form': ['action', 'onsubmit'],
39
+ 'input': ['type', 'onclick', 'onchange'],
40
+ '*': ['onclick', 'onload', 'onchange', 'onsubmit', 'onmouseover']
41
+ }
42
+
43
+ # 遍历所有标签,保留交互属性并移除其他属性
44
+ for element in soup.find_all(True):
45
+ tag_name = element.name
46
+ allowed_attrs = INTERACTIVE_ATTRIBUTES.get(tag_name, []) + INTERACTIVE_ATTRIBUTES['*']
47
+ attrs = list(element.attrs.keys())
48
+ for attr in attrs:
49
+ if attr not in allowed_attrs:
50
+ del element[attr]
51
+
52
+ # 如果是<img>标签,检查src是否为Base64
53
+ if tag_name == 'img' and 'src' in element.attrs and element['src'].startswith('data:'):
54
+ del element['src']
55
+
56
+ # 处理文本内容,超过1000字符则截取
57
+ if element.string and len(element.string) > 1000:
58
+ element.string = element.string[:1000] + '...'
59
+
60
+ # 移除标签之间的多余空白
61
+ for element in soup.find_all(True):
62
+ if not element.get_text(strip=True):
63
+ element.string = ''
64
+
65
+ return str(soup)
@@ -66,10 +66,8 @@ def get_system_prompt(abilities, bot_setting):
66
66
  cd_prompt = "When executing outside the working directory, include the CD command, such as cd /path/to/directory && ls."
67
67
  system = platform.system()
68
68
 
69
- print("bot_setting", bot_setting)
70
- print("abilities", abilities)
69
+
71
70
  abilities_str = "\n".join([function_to_string(a) for a in abilities])
72
- print("abilities_str", abilities_str)
73
71
 
74
72
  context = {
75
73
  "prompt": bot_setting["prompt"],
@@ -96,7 +94,7 @@ def get_system_prompt(abilities, bot_setting):
96
94
  if key != "folder_context" and bot_setting["systemAbility"][key] == True:
97
95
  has_any_tool = True
98
96
  break
99
-
97
+
100
98
  context["has_any_tool"] = has_any_tool
101
99
  system_prompt = template.render(context)
102
100
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pycoze
3
- Version: 0.1.438
3
+ Version: 0.1.440
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="pycoze",
5
- version="0.1.438",
5
+ version="0.1.440",
6
6
  packages=find_packages(),
7
7
  install_requires=[],
8
8
  author="Yuan Jie Xiong",
@@ -1,16 +0,0 @@
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
- )
12
-
13
- def get_simplified_html(self, html: str) -> str:
14
- return socket.post_and_recv_result(
15
- "getSimplifiedHtml", {"html": html}
16
- )
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