Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
3c2937a
1
Parent(s):
bcfeecd
微调代码结构
Browse files- presets.py +7 -0
- utils.py +1 -7
presets.py
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
# -*- coding:utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
# 错误信息
|
3 |
standard_error_msg = "☹️发生了错误:" # 错误信息的标准前缀
|
4 |
error_retrieve_prompt = "请检查网络连接,或者API-Key是否有效。" # 获取对话时发生错误
|
|
|
1 |
# -*- coding:utf-8 -*-
|
2 |
+
|
3 |
+
# ChatGPT 设置
|
4 |
+
initial_prompt = "You are a helpful assistant."
|
5 |
+
API_URL = "https://api.openai.com/v1/chat/completions"
|
6 |
+
HISTORY_DIR = "history"
|
7 |
+
TEMPLATES_DIR = "templates"
|
8 |
+
|
9 |
# 错误信息
|
10 |
standard_error_msg = "☹️发生了错误:" # 错误信息的标准前缀
|
11 |
error_retrieve_prompt = "请检查网络连接,或者API-Key是否有效。" # 获取对话时发生错误
|
utils.py
CHANGED
@@ -26,12 +26,6 @@ if TYPE_CHECKING:
|
|
26 |
data: List[List[str | int | bool]]
|
27 |
|
28 |
|
29 |
-
initial_prompt = "You are a helpful assistant."
|
30 |
-
API_URL = "https://api.openai.com/v1/chat/completions"
|
31 |
-
HISTORY_DIR = "history"
|
32 |
-
TEMPLATES_DIR = "templates"
|
33 |
-
|
34 |
-
|
35 |
def count_token(message):
|
36 |
encoding = tiktoken.get_encoding("cl100k_base")
|
37 |
input_str = f"role: {message['role']}, content: {message['content']}"
|
@@ -46,7 +40,7 @@ def parse_text(text):
|
|
46 |
for line in text.split("\n"):
|
47 |
if line.strip().startswith("```"):
|
48 |
in_code_block = not in_code_block
|
49 |
-
else:
|
50 |
if re.match(r'(\*|-|\d+\.)\s', line):
|
51 |
if not in_list:
|
52 |
in_list = True
|
|
|
26 |
data: List[List[str | int | bool]]
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def count_token(message):
|
30 |
encoding = tiktoken.get_encoding("cl100k_base")
|
31 |
input_str = f"role: {message['role']}, content: {message['content']}"
|
|
|
40 |
for line in text.split("\n"):
|
41 |
if line.strip().startswith("```"):
|
42 |
in_code_block = not in_code_block
|
43 |
+
else:
|
44 |
if re.match(r'(\*|-|\d+\.)\s', line):
|
45 |
if not in_list:
|
46 |
in_list = True
|