pycoze 0.1.223__tar.gz → 0.1.224__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pycoze-0.1.223 → pycoze-0.1.224}/PKG-INFO +1 -1
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ai/__init__.py +1 -1
- pycoze-0.1.223/pycoze/ai/llm/think.py → pycoze-0.1.224/pycoze/ai/llm/chat.py +8 -8
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ai/llm/text_to_image_prompt.py +1 -1
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze.egg-info/PKG-INFO +1 -1
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze.egg-info/SOURCES.txt +1 -1
- {pycoze-0.1.223 → pycoze-0.1.224}/setup.py +1 -1
- {pycoze-0.1.223 → pycoze-0.1.224}/LICENSE +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/README.md +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ai/llm/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ai/vram_reserve.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/automation/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/automation/browser/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/automation/browser/edge_driver_manager.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent/agent.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent/agent_types/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent/agent_types/const.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent/assistant.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent/chat.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/agent_chat.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/bot/bot.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/reference/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/reference/bot.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/reference/lib.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/reference/tool.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/reference/workflow.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ui/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ui/base.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ui/color.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ui/typ.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/ui/ui_def.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/utils/__init__.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/utils/arg.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/utils/env.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze/utils/text_or_file.py +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze.egg-info/dependency_links.txt +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/pycoze.egg-info/top_level.txt +0 -0
- {pycoze-0.1.223 → pycoze-0.1.224}/setup.cfg +0 -0
@@ -1,2 +1,2 @@
|
|
1
1
|
from .vram_reserve import reserve_vram, reserve_vram_retry, unreserve_vram
|
2
|
-
from .llm import
|
2
|
+
from .llm 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
|
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
|
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
|
-
|
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 =
|
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
|
-
|
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 =
|
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(
|
128
|
-
for chunk in
|
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"))
|
@@ -9,8 +9,8 @@ pycoze.egg-info/top_level.txt
|
|
9
9
|
pycoze/ai/__init__.py
|
10
10
|
pycoze/ai/vram_reserve.py
|
11
11
|
pycoze/ai/llm/__init__.py
|
12
|
+
pycoze/ai/llm/chat.py
|
12
13
|
pycoze/ai/llm/text_to_image_prompt.py
|
13
|
-
pycoze/ai/llm/think.py
|
14
14
|
pycoze/automation/__init__.py
|
15
15
|
pycoze/automation/browser/__init__.py
|
16
16
|
pycoze/automation/browser/edge_driver_manager.py
|
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
|