pro-craft 0.1.6__py3-none-any.whl → 0.1.8__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.
Potentially problematic release.
This version of pro-craft might be problematic. Click here for more details.
- pro_craft/prompt_helper_async.py +31 -1
- {pro_craft-0.1.6.dist-info → pro_craft-0.1.8.dist-info}/METADATA +1 -1
- {pro_craft-0.1.6.dist-info → pro_craft-0.1.8.dist-info}/RECORD +5 -5
- {pro_craft-0.1.6.dist-info → pro_craft-0.1.8.dist-info}/WHEEL +0 -0
- {pro_craft-0.1.6.dist-info → pro_craft-0.1.8.dist-info}/top_level.txt +0 -0
pro_craft/prompt_helper_async.py
CHANGED
|
@@ -23,6 +23,33 @@ from datetime import datetime
|
|
|
23
23
|
from pro_craft.utils import extract_
|
|
24
24
|
logger = Log.logger
|
|
25
25
|
editing_log = logger.debug
|
|
26
|
+
import re
|
|
27
|
+
|
|
28
|
+
def fix_broken_json_string(broken_json_str):
|
|
29
|
+
# 移除 BOM
|
|
30
|
+
broken_json_str = broken_json_str.lstrip('\ufeff')
|
|
31
|
+
# 移除大部分非法 ASCII 控制字符
|
|
32
|
+
broken_json_str = re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f]', '', broken_json_str)
|
|
33
|
+
|
|
34
|
+
# 尝试找到 "content": " 和它对应的结束 "
|
|
35
|
+
# 这是一个挑战,因为中间有未转义的换行。
|
|
36
|
+
# 我们会寻找 "content": ",然后捕获从那以后直到最后一个 " 的所有内容,并替换其中的裸换行。
|
|
37
|
+
|
|
38
|
+
# 注意:这个正则假设 "content" 的值是最后一个键值对,并且直到字符串末尾的 " 才结束
|
|
39
|
+
# 并且假设其他字段都是合法的单行字符串
|
|
40
|
+
fixed_json_str = re.sub(
|
|
41
|
+
r'("content":\s*")(.+?)"\s*}', # 匹配 "content": ",然后捕获所有内容直到最后一个 " }
|
|
42
|
+
lambda m: m.group(1) + m.group(2).replace('\n', '\\n').replace('\r', '\\r') + '"\n}',
|
|
43
|
+
broken_json_str,
|
|
44
|
+
flags=re.DOTALL # 允许 . 匹配换行
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# 修正可能的最后一行丢失的 }
|
|
48
|
+
if not fixed_json_str.strip().endswith('}'):
|
|
49
|
+
fixed_json_str += '\n}' # 补上结束的 }
|
|
50
|
+
|
|
51
|
+
return fixed_json_str
|
|
52
|
+
|
|
26
53
|
|
|
27
54
|
class IntellectType(Enum):
|
|
28
55
|
train = "train"
|
|
@@ -524,7 +551,10 @@ class AsyncIntel():
|
|
|
524
551
|
)
|
|
525
552
|
|
|
526
553
|
try:
|
|
527
|
-
|
|
554
|
+
|
|
555
|
+
json_str = extract_(ai_result,r'json')
|
|
556
|
+
# json_str = fix_broken_json_string(json_str)
|
|
557
|
+
ai_result = json.loads(json_str)
|
|
528
558
|
OutputFormat(**ai_result)
|
|
529
559
|
except ValidationError as e:
|
|
530
560
|
log_ = "记忆卡片合并 - 大模型生成的格式未通过校验"
|
|
@@ -5,7 +5,7 @@ pro_craft/evals.py,sha256=1T86jur4k3cLk43j1GyAW4JS0nPNfl6P0ZOQmu-SgpA,1928
|
|
|
5
5
|
pro_craft/file_manager.py,sha256=2j7lCt9L4mtvAy8_76ibTthXLwKKmVatWIB3DSvQM7U,3805
|
|
6
6
|
pro_craft/log.py,sha256=MZf9jCZsiRoAq8v4FxVnJqeSXxgzAiiKf7mxz6bFtwM,4263
|
|
7
7
|
pro_craft/prompt_helper.py,sha256=SFIhju0Y3rRdb-T1WocUgz7qCocq1Ja2zlaEZo1RM3o,23832
|
|
8
|
-
pro_craft/prompt_helper_async.py,sha256=
|
|
8
|
+
pro_craft/prompt_helper_async.py,sha256=z0W4uDoxqCSBYlKtkXU1l_E1TUFz_9wMUWhV0rAGhNo,26408
|
|
9
9
|
pro_craft/server.py,sha256=fPAosQIU0d7gxICiALl8u6QwbLI4cawVFyoRYebRES0,2827
|
|
10
10
|
pro_craft/utils.py,sha256=27A3CFhbRsEAP5GY6oxAz2M-beiIuPgCNSjQUyzOVW0,5685
|
|
11
11
|
pro_craft/code_helper/coder.py,sha256=NXglF1KiPtGe4HZN0MZvFJ8p9Iyd5kzIt72DQGgRwXA,24715
|
|
@@ -17,7 +17,7 @@ pro_craft/server/mcp/math.py,sha256=OOzGXx64nK4bOVlu33PtVddcCQ9ilqA3Em9yxjSX9cg,
|
|
|
17
17
|
pro_craft/server/mcp/resource.py,sha256=z94jP3qZofO-1lZCM3TuOfLajw41HARs1ojXab1ymas,776
|
|
18
18
|
pro_craft/server/mcp/weather.py,sha256=RAGuf4sgjlTQSfRRZ1Fo18JnuMQRS_Db9p6AqBQrl8E,455
|
|
19
19
|
pro_craft/server/router/recommended.py,sha256=IAZFdmb8HSl2_TOJeuv5uOKIX47XyX4p4sEwxG-0vt0,9968
|
|
20
|
-
pro_craft-0.1.
|
|
21
|
-
pro_craft-0.1.
|
|
22
|
-
pro_craft-0.1.
|
|
23
|
-
pro_craft-0.1.
|
|
20
|
+
pro_craft-0.1.8.dist-info/METADATA,sha256=i7V4hsLUgvdbdeFGW4FqsnqqxPMY9Hb6JjU6g4_7O0s,1768
|
|
21
|
+
pro_craft-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
22
|
+
pro_craft-0.1.8.dist-info/top_level.txt,sha256=yqYDHArnYMWpeCxkmGRwlL6sJtxiOUnYylLDx9EOgFg,10
|
|
23
|
+
pro_craft-0.1.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|