Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: enhance API call parameters with conditional extra_body for thinking mode

myhloli11a1f04b0f12
diff --git a/mineru.template.json b/mineru.template.json
index 4cf1c152..09596fde 100644
--- a/mineru.template.json
+++ b/mineru.template.json
@@ -18,6 +18,7 @@
"api_key": "your_api_key",
"base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"model": "qwen3-next-80b-a3b-instruct",
+ "enable_thinking": false,
"enable": false
}
},
diff --git a/mineru/utils/llm_aided.py b/mineru/utils/llm_aided.py
index 26285db0..bfb53eb4 100644
--- a/mineru/utils/llm_aided.py
+++ b/mineru/utils/llm_aided.py
@@ -84,16 +84,21 @@ Corrected title list:
max_retries = 3
dict_completion = None
+ # 构建 API 调用参数
+ api_params = {
+ "model": title_aided_config["model"],
+ "messages": [{'role': 'user', 'content': title_optimize_prompt}],
+ "temperature": 0.7,
+ "stream": True,
+ }
+
+ # 只有配置中明确指定时才添加 extra_body
+ if "enable_thinking" in title_aided_config:
+ api_params["extra_body"] = {"enable_thinking": title_aided_config["enable_thinking"]}
+
while retry_count < max_retries:
try:
- completion = client.chat.completions.create(
- model=title_aided_config["model"],
- messages=[
- {'role': 'user', 'content': title_optimize_prompt}],
- extra_body={"enable_thinking": False},
- temperature=0.7,
- stream=True,
- )
+ completion = client.chat.completions.create(**api_params)
content_pieces = []
for chunk in completion:
if chunk.choices and chunk.choices[0].delta.content is not None: