pycoze 0.1.223__py3-none-any.whl → 0.1.225__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/ai/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  from .vram_reserve import reserve_vram, reserve_vram_retry, unreserve_vram
2
- from .llm import think, think_stream, extract, yes_or_no, extract_code
2
+ from .llm import chat, chat_stream, extract, yes_or_no, extract_code, text_to_image_prompt
pycoze/ai/llm/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  from .text_to_image_prompt import text_to_image_prompt
2
- from .think import think, think_stream, extract, yes_or_no, extract_code
2
+ from .chat import chat, chat_stream, extract, yes_or_no, extract_code
@@ -13,7 +13,7 @@ def never_retry_on_rate_limit_error(exception):
13
13
  return not isinstance(exception, openai.RateLimitError)
14
14
 
15
15
  @retry(retry_on_exception=never_retry_on_rate_limit_error, wait_exponential_multiplier=500, stop_max_attempt_number=5)
16
- def think(user_text, history, temperature=0.2, stop=None, **kwargs):
16
+ def chat(user_text, history, temperature=0.2, stop=None, **kwargs):
17
17
  user_msg = {"role": "user", "content": user_text}
18
18
  cfg = utils.read_json_file("llm.json")
19
19
 
@@ -33,7 +33,7 @@ def think(user_text, history, temperature=0.2, stop=None, **kwargs):
33
33
 
34
34
 
35
35
  @retry(retry_on_exception=never_retry_on_rate_limit_error, wait_exponential_multiplier=500, stop_max_attempt_number=5)
36
- def think_stream(user_text, history, temperature=0.2, stop=None, **kwargs):
36
+ def chat_stream(user_text, history, temperature=0.2, stop=None, **kwargs):
37
37
  user_msg = {"role": "user", "content": user_text}
38
38
  cfg = utils.read_json_file("llm.json")
39
39
 
@@ -73,7 +73,7 @@ def extract(response_data, text: str, temperature=0, **kwargs):
73
73
  json_text += f' "{res[0]}": {res[1]}{comma}\n'
74
74
 
75
75
  # Combine the provided text with the formatted JSON schema
76
- think_text = f"""
76
+ chat_text = f"""
77
77
  The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```" tags:
78
78
  ```json
79
79
  {{
@@ -85,7 +85,7 @@ Request:
85
85
  {text}
86
86
  """
87
87
  # text放后面,当翻译等情况时,不会把"The output should"之类翻译了,导致错误
88
- markdown = think(think_text, [], temperature=temperature, **kwargs)
88
+ markdown = chat(chat_text, [], temperature=temperature, **kwargs)
89
89
  pattern = r'```json(.*?)```'
90
90
  matches = re.findall(pattern, markdown, re.DOTALL)
91
91
  if matches:
@@ -109,10 +109,10 @@ def yes_or_no(question, temperature=0, **kwargs):
109
109
  @retry(retry_on_exception=never_retry_on_rate_limit_error, wait_exponential_multiplier=500, stop_max_attempt_number=3)
110
110
  def extract_code(text: str, temperature=0, language="python", markdown_word='python', **kwargs):
111
111
  """print(extract_code("sum 1~100"))"""
112
- think_text = text + f"""
112
+ chat_text = text + f"""
113
113
  The output should be a complete and usable {language} code snippet, including the leading and trailing "```{markdown_word}" and "```":
114
114
  """
115
- markdown = think(think_text, [], temperature=temperature, **kwargs)
115
+ markdown = chat(chat_text, [], temperature=temperature, **kwargs)
116
116
  # 使用正则表达式匹配围绕在```{markdown_word} 和 ```之间的文本
117
117
  pattern = rf'```{markdown_word}(.*?)```'
118
118
  matches = re.findall(pattern, markdown, re.DOTALL)
@@ -124,8 +124,8 @@ The output should be a complete and usable {language} code snippet, including th
124
124
 
125
125
 
126
126
  if __name__ == "__main__":
127
- print(think("你好", []))
128
- for chunk in think_stream("你好", []):
127
+ print(chat("你好", []))
128
+ for chunk in chat_stream("你好", []):
129
129
  print(chunk)
130
130
  print(extract({"name": "lowercase"}, "hello XiaoMing"))
131
131
  print(extract_code("sum 1~100"))
@@ -1,5 +1,5 @@
1
1
  import re
2
- from .think import yes_or_no, extract
2
+ from .chat import yes_or_no, extract
3
3
 
4
4
 
5
5
  def contains_chinese(text):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.223
3
+ Version: 0.1.225
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -1,9 +1,9 @@
1
1
  pycoze/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pycoze/ai/__init__.py,sha256=NhIqfUR_01rlZ8hsxi4aUwQ78tiMGmcUluiB5E4Xy6M,145
2
+ pycoze/ai/__init__.py,sha256=uhG4Z3HSTp_o6H4ouNy8gW1hzcU0B8zDB0nJgbmnHpk,165
3
3
  pycoze/ai/vram_reserve.py,sha256=brgXP42yj3yaZRgW8pfgc4Jg9EivAhcbp5W4igVHcow,4256
4
- pycoze/ai/llm/__init__.py,sha256=Pc7eYhrzkZqNXNPKkbd1tyoizdlGm9a60J9NGr1v3RQ,128
5
- pycoze/ai/llm/text_to_image_prompt.py,sha256=WnC7AoPxvEGrSftTdUytMwEr7-ETZjLy4ztUi9s7Ouo,3334
6
- pycoze/ai/llm/think.py,sha256=sUgTBdGzcZtL3r-Wx8M3lDuVUmDVz8g3qC0VU8uiKAI,5143
4
+ pycoze/ai/llm/__init__.py,sha256=B4apuRE3PDputKTELVYWNP-V5GhdAOBq9BTjzP1Ne3c,125
5
+ pycoze/ai/llm/chat.py,sha256=izriC7nCp5qeJRqcUVQBVqTHiH6MJS77ROzGBJufdNI,5133
6
+ pycoze/ai/llm/text_to_image_prompt.py,sha256=NdfhPTOTSR4whGgd10UtyQjzQCat0wdcX94OLSt4gUU,3333
7
7
  pycoze/automation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  pycoze/automation/browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  pycoze/automation/browser/edge_driver_manager.py,sha256=gpgseunph5owZH6EskSYthuhey2SU3UP204gY0yIcuI,3022
@@ -31,8 +31,8 @@ pycoze/utils/__init__.py,sha256=Gi5EnrWZGMD2JRejgV4c_VLCXyvA2wwBFI_niDF5MUE,110
31
31
  pycoze/utils/arg.py,sha256=GtfGbMTMdaK75Fwh6MpUe1pCA5X6Ep4LFG7a72YrzjI,525
32
32
  pycoze/utils/env.py,sha256=W04lhvTHhAAC6EldP6kk2xrctqtu8K6kl1vDLZDNeh8,561
33
33
  pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
34
- pycoze-0.1.223.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
35
- pycoze-0.1.223.dist-info/METADATA,sha256=0FkJta7KAhCl11FGPipeoyHMHcHWGfXJmkxtaHPa9NM,726
36
- pycoze-0.1.223.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
37
- pycoze-0.1.223.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
38
- pycoze-0.1.223.dist-info/RECORD,,
34
+ pycoze-0.1.225.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
35
+ pycoze-0.1.225.dist-info/METADATA,sha256=N4r76t8hsUkcTCQzuJ_M1WM1L6-rG6V6qUqi5DzrK9M,726
36
+ pycoze-0.1.225.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
37
+ pycoze-0.1.225.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
38
+ pycoze-0.1.225.dist-info/RECORD,,