mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-26 03:44:58 +08:00
Merge pull request #762 from RockChinQ/feat/deepseek
Feat: 支持 deepseek 模型
This commit is contained in:
30
pkg/config/migrations/m005_deepseek_cfg_completion.py
Normal file
30
pkg/config/migrations/m005_deepseek_cfg_completion.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from .. import migration
|
||||||
|
|
||||||
|
|
||||||
|
@migration.migration_class("deepseek-config-completion", 5)
|
||||||
|
class DeepseekConfigCompletionMigration(migration.Migration):
|
||||||
|
"""OpenAI配置迁移
|
||||||
|
"""
|
||||||
|
|
||||||
|
async def need_migrate(self) -> bool:
|
||||||
|
"""判断当前环境是否需要运行此迁移
|
||||||
|
"""
|
||||||
|
return 'deepseek-chat-completions' not in self.ap.provider_cfg.data['requester'] \
|
||||||
|
or 'deepseek' not in self.ap.provider_cfg.data['keys']
|
||||||
|
|
||||||
|
async def run(self):
|
||||||
|
"""执行迁移
|
||||||
|
"""
|
||||||
|
if 'deepseek-chat-completions' not in self.ap.provider_cfg.data['requester']:
|
||||||
|
self.ap.provider_cfg.data['requester']['deepseek-chat-completions'] = {
|
||||||
|
'base-url': 'https://api.deepseek.com',
|
||||||
|
'args': {},
|
||||||
|
'timeout': 120,
|
||||||
|
}
|
||||||
|
|
||||||
|
if 'deepseek' not in self.ap.provider_cfg.data['keys']:
|
||||||
|
self.ap.provider_cfg.data['keys']['deepseek'] = []
|
||||||
|
|
||||||
|
await self.ap.provider_cfg.dump_config()
|
||||||
@@ -5,6 +5,7 @@ import importlib
|
|||||||
from .. import stage, app
|
from .. import stage, app
|
||||||
from ...config import migration
|
from ...config import migration
|
||||||
from ...config.migrations import m001_sensitive_word_migration, m002_openai_config_migration, m003_anthropic_requester_cfg_completion, m004_moonshot_cfg_completion
|
from ...config.migrations import m001_sensitive_word_migration, m002_openai_config_migration, m003_anthropic_requester_cfg_completion, m004_moonshot_cfg_completion
|
||||||
|
from ...config.migrations import m005_deepseek_cfg_completion
|
||||||
|
|
||||||
|
|
||||||
@stage.stage_class("MigrationStage")
|
@stage.stage_class("MigrationStage")
|
||||||
|
|||||||
15
pkg/provider/modelmgr/apis/deepseekchatcmpl.py
Normal file
15
pkg/provider/modelmgr/apis/deepseekchatcmpl.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from ....core import app
|
||||||
|
|
||||||
|
from . import chatcmpl
|
||||||
|
from .. import api
|
||||||
|
|
||||||
|
|
||||||
|
@api.requester_class("deepseek-chat-completions")
|
||||||
|
class DeepseekChatCompletions(chatcmpl.OpenAIChatCompletions):
|
||||||
|
"""Deepseek ChatCompletion API 请求器"""
|
||||||
|
|
||||||
|
def __init__(self, ap: app.Application):
|
||||||
|
self.requester_cfg = ap.provider_cfg.data['requester']['deepseek-chat-completions']
|
||||||
|
self.ap = ap
|
||||||
@@ -6,7 +6,7 @@ from . import entities
|
|||||||
from ...core import app
|
from ...core import app
|
||||||
|
|
||||||
from . import token, api
|
from . import token, api
|
||||||
from .apis import chatcmpl, anthropicmsgs, moonshotchatcmpl
|
from .apis import chatcmpl, anthropicmsgs, moonshotchatcmpl, deepseekchatcmpl
|
||||||
|
|
||||||
FETCH_MODEL_LIST_URL = "https://api.qchatgpt.rockchin.top/api/v2/fetch/model_list"
|
FETCH_MODEL_LIST_URL = "https://api.qchatgpt.rockchin.top/api/v2/fetch/model_list"
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,11 @@
|
|||||||
"name": "moonshot-v1-128k",
|
"name": "moonshot-v1-128k",
|
||||||
"requester": "moonshot-chat-completions",
|
"requester": "moonshot-chat-completions",
|
||||||
"token_mgr": "moonshot"
|
"token_mgr": "moonshot"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "deepseek-chat",
|
||||||
|
"requester": "deepseek-chat-completions",
|
||||||
|
"token_mgr": "deepseek"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
"api-key": "",
|
"api-key": "",
|
||||||
"api-secret": ""
|
"api-secret": ""
|
||||||
},
|
},
|
||||||
"submit-messages-tokens": 3072,
|
|
||||||
"rate-limit": {
|
"rate-limit": {
|
||||||
"strategy": "drop",
|
"strategy": "drop",
|
||||||
"algo": "fixwin",
|
"algo": "fixwin",
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
],
|
],
|
||||||
"moonshot": [
|
"moonshot": [
|
||||||
"sk-1234567890"
|
"sk-1234567890"
|
||||||
|
],
|
||||||
|
"deepseek": [
|
||||||
|
"sk-1234567890"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"requester": {
|
"requester": {
|
||||||
@@ -28,6 +31,11 @@
|
|||||||
"base-url": "https://api.moonshot.cn/v1",
|
"base-url": "https://api.moonshot.cn/v1",
|
||||||
"args": {},
|
"args": {},
|
||||||
"timeout": 120
|
"timeout": 120
|
||||||
|
},
|
||||||
|
"deepseek-chat-completions": {
|
||||||
|
"base-url": "https://api.deepseek.com",
|
||||||
|
"args": {},
|
||||||
|
"timeout": 120
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"model": "gpt-3.5-turbo",
|
"model": "gpt-3.5-turbo",
|
||||||
|
|||||||
Reference in New Issue
Block a user