universal-function-zsd 1.8.0__tar.gz → 1.8.2__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.
- {universal_function_zsd-1.8.0/src/universal_function_zsd.egg-info → universal_function_zsd-1.8.2}/PKG-INFO +1 -1
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/pyproject.toml +1 -1
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/src/universal_function_zsd/universal_function.py +27 -7
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2/src/universal_function_zsd.egg-info}/PKG-INFO +1 -1
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/LICENSE +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/MANIFEST.in +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/README.md +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/setup.cfg +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/src/universal_function_zsd/__init__.py +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/src/universal_function_zsd/universal_parameter.py +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/src/universal_function_zsd.egg-info/SOURCES.txt +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/src/universal_function_zsd.egg-info/dependency_links.txt +0 -0
- {universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/src/universal_function_zsd.egg-info/top_level.txt +0 -0
|
@@ -833,8 +833,7 @@ def get_llm_response(
|
|
|
833
833
|
sys_prompt: str,
|
|
834
834
|
base_prompt: str,
|
|
835
835
|
max_tokens: int,
|
|
836
|
-
|
|
837
|
-
enable_thinking: bool = False,
|
|
836
|
+
extra_body: dict = None,
|
|
838
837
|
if_stream: bool = False,
|
|
839
838
|
temperature: float = 0.1,
|
|
840
839
|
top_p: float = 0.95,
|
|
@@ -845,10 +844,8 @@ def get_llm_response(
|
|
|
845
844
|
if sys_prompt:
|
|
846
845
|
messages_input.append({"role": "system", "content": sys_prompt})
|
|
847
846
|
messages_input.append({"role": "user", "content": base_prompt})
|
|
848
|
-
extra_body
|
|
849
|
-
|
|
850
|
-
# 百炼支持enable_thinking;qianfan千帆不支持该参数
|
|
851
|
-
extra_body["enable_thinking"] = enable_thinking
|
|
847
|
+
if extra_body is None:
|
|
848
|
+
extra_body = {}
|
|
852
849
|
for attempt_idx in range(retry_times + 1):
|
|
853
850
|
try:
|
|
854
851
|
response = llm_client.chat.completions.create(
|
|
@@ -871,4 +868,27 @@ def get_llm_response(
|
|
|
871
868
|
continue
|
|
872
869
|
else:
|
|
873
870
|
return ''
|
|
874
|
-
return ''
|
|
871
|
+
return ''
|
|
872
|
+
|
|
873
|
+
def extract_dict(text):
|
|
874
|
+
code_block_pattern = re.compile(r"```(?:json)?\s*\n?([\s\S]*?)\n?```")
|
|
875
|
+
match = code_block_pattern.search(text)
|
|
876
|
+
if match:
|
|
877
|
+
raw = match.group(1)
|
|
878
|
+
else:
|
|
879
|
+
# Step2:兜底,提取从第一个 { / [ 到最后一个 } / ]
|
|
880
|
+
start_idx = min(
|
|
881
|
+
idx for idx in [text.find("{"), text.find("[")] if idx != -1
|
|
882
|
+
)
|
|
883
|
+
end_idx = max(
|
|
884
|
+
idx for idx in [text.rfind("}"), text.rfind("]")] if idx != -1
|
|
885
|
+
)
|
|
886
|
+
raw = text[start_idx:end_idx + 1]
|
|
887
|
+
|
|
888
|
+
# Step3:清洗非法控制字符(保留 \t \r \n)
|
|
889
|
+
clean_json = re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f]', '', raw)
|
|
890
|
+
try:
|
|
891
|
+
return json.loads(clean_json)
|
|
892
|
+
except json.JSONDecodeError as e:
|
|
893
|
+
logger.warning(f"JSON解析失败:{e}, 原始的清洗后文本:{clean_json}")
|
|
894
|
+
return None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{universal_function_zsd-1.8.0 → universal_function_zsd-1.8.2}/src/universal_function_zsd/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|