mirror of
https://github.com/opendatalab/MinerU.git
synced 2026-03-27 11:08:32 +07:00
feat: enhance API call parameters with conditional extra_body for thinking mode
This commit is contained in:
@@ -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
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user