Spaces:
Running
Running
nacho commited on
Commit ·
2f8e65f
1
Parent(s): a74d5c4
feat: 支持极速思考模式 (deepseek-fast)
Browse files- deepseek_browser.py +14 -4
- main.py +2 -0
- static/index.html +3 -2
deepseek_browser.py
CHANGED
|
@@ -286,7 +286,17 @@ class DeepSeekBrowser:
|
|
| 286 |
|
| 287 |
async def switch_model(self, model: str):
|
| 288 |
try:
|
| 289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
thinking_btn = self.page.locator(
|
| 291 |
'button:has-text("深度思考"), div:has-text("深度思考"), '
|
| 292 |
'button:has-text("专家模式"), div:has-text("专家模式"), '
|
|
@@ -373,7 +383,7 @@ class DeepSeekBrowser:
|
|
| 373 |
const bodyText = scope.innerText || '';
|
| 374 |
if (!result.answer || (!result.thinking && (bodyText.includes('深度思考') || bodyText.includes('思考过程')))) {
|
| 375 |
const lines = bodyText.split('\\n').map(l => l.trim()).filter(Boolean);
|
| 376 |
-
const skip = ['智能搜索', '快速模式', '专家模式',
|
| 377 |
'内容由 AI 生成', '开启新对话', '暂无历史对话'];
|
| 378 |
|
| 379 |
let isThinking = false;
|
|
@@ -383,11 +393,11 @@ class DeepSeekBrowser:
|
|
| 383 |
for (const l of lines) {
|
| 384 |
if (skip.some(s => l === s)) continue;
|
| 385 |
|
| 386 |
-
if (l === '深度思考' || l === '思考过程' || l.startsWith('深度思考...')) {
|
| 387 |
isThinking = true;
|
| 388 |
continue;
|
| 389 |
}
|
| 390 |
-
if (l.startsWith('已深度思考') || l.startsWith('深度思考(用时')) {
|
| 391 |
isThinking = false;
|
| 392 |
continue;
|
| 393 |
}
|
|
|
|
| 286 |
|
| 287 |
async def switch_model(self, model: str):
|
| 288 |
try:
|
| 289 |
+
# 极速思考模式
|
| 290 |
+
if 'fast' in model or 'lite' in model:
|
| 291 |
+
fast_btn = self.page.locator(
|
| 292 |
+
'button:has-text("极速思考"), div:has-text("极速思考"), '
|
| 293 |
+
'button:has-text("快速模式"), div:has-text("快速模式")'
|
| 294 |
+
).first
|
| 295 |
+
if await fast_btn.count() > 0:
|
| 296 |
+
await fast_btn.click()
|
| 297 |
+
await asyncio.sleep(0.5)
|
| 298 |
+
# 深度思考 / 专家模式
|
| 299 |
+
elif 'reasoner' in model or 'thinking' in model or 'pro' in model:
|
| 300 |
thinking_btn = self.page.locator(
|
| 301 |
'button:has-text("深度思考"), div:has-text("深度思考"), '
|
| 302 |
'button:has-text("专家模式"), div:has-text("专家模式"), '
|
|
|
|
| 383 |
const bodyText = scope.innerText || '';
|
| 384 |
if (!result.answer || (!result.thinking && (bodyText.includes('深度思考') || bodyText.includes('思考过程')))) {
|
| 385 |
const lines = bodyText.split('\\n').map(l => l.trim()).filter(Boolean);
|
| 386 |
+
const skip = ['智能搜索', '快速模式', '专家模式', '极速思考',
|
| 387 |
'内容由 AI 生成', '开启新对话', '暂无历史对话'];
|
| 388 |
|
| 389 |
let isThinking = false;
|
|
|
|
| 393 |
for (const l of lines) {
|
| 394 |
if (skip.some(s => l === s)) continue;
|
| 395 |
|
| 396 |
+
if (l === '深度思考' || l === '思考过程' || l.startsWith('深度思考...') || l.startsWith('极速思考...')) {
|
| 397 |
isThinking = true;
|
| 398 |
continue;
|
| 399 |
}
|
| 400 |
+
if (l.startsWith('已深度思考') || l.startsWith('深度思考(用时') || l.startsWith('已极速思考') || l.startsWith('极速思考(用时')) {
|
| 401 |
isThinking = false;
|
| 402 |
continue;
|
| 403 |
}
|
main.py
CHANGED
|
@@ -103,6 +103,7 @@ async def list_models(authorization: str = Header(...)):
|
|
| 103 |
return {
|
| 104 |
"data": [
|
| 105 |
{"id": "deepseek-flash", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
|
|
|
| 106 |
{"id": "deepseek-pro", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 107 |
],
|
| 108 |
"object": "list",
|
|
@@ -115,6 +116,7 @@ async def get_model(model_id: str, authorization: str = Header(...)):
|
|
| 115 |
|
| 116 |
models = {
|
| 117 |
"deepseek-flash": {"id": "deepseek-flash", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
|
|
|
| 118 |
"deepseek-pro": {"id": "deepseek-pro", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 119 |
}
|
| 120 |
|
|
|
|
| 103 |
return {
|
| 104 |
"data": [
|
| 105 |
{"id": "deepseek-flash", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 106 |
+
{"id": "deepseek-fast", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 107 |
{"id": "deepseek-pro", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 108 |
],
|
| 109 |
"object": "list",
|
|
|
|
| 116 |
|
| 117 |
models = {
|
| 118 |
"deepseek-flash": {"id": "deepseek-flash", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 119 |
+
"deepseek-fast": {"id": "deepseek-fast", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 120 |
"deepseek-pro": {"id": "deepseek-pro", "object": "model", "created": int(time.time()), "owned_by": "deepseek"},
|
| 121 |
}
|
| 122 |
|
static/index.html
CHANGED
|
@@ -201,8 +201,9 @@ select{cursor:pointer;appearance:none;background-image:url("data:image/svg+xml,%
|
|
| 201 |
<div class="row" style="gap:10px;margin-bottom:14px">
|
| 202 |
<div class="form-group" style="flex:1;margin-bottom:0">
|
| 203 |
<select id="model">
|
| 204 |
-
<option value="deepseek-flash">deepseek-flash</option>
|
| 205 |
-
<option value="deepseek-
|
|
|
|
| 206 |
</select>
|
| 207 |
</div>
|
| 208 |
<label class="check-label" style="margin-top:auto;padding-bottom:2px">
|
|
|
|
| 201 |
<div class="row" style="gap:10px;margin-bottom:14px">
|
| 202 |
<div class="form-group" style="flex:1;margin-bottom:0">
|
| 203 |
<select id="model">
|
| 204 |
+
<option value="deepseek-flash">deepseek-flash (极速)</option>
|
| 205 |
+
<option value="deepseek-fast">deepseek-fast (极速思考)</option>
|
| 206 |
+
<option value="deepseek-pro">deepseek-pro (专家思考)</option>
|
| 207 |
</select>
|
| 208 |
</div>
|
| 209 |
<label class="check-label" style="margin-top:auto;padding-bottom:2px">
|