Skip to content

Commit

Permalink
feat: deepseek配置迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed May 7, 2024
1 parent 9c6491e commit c459313
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/config/migrations/m005_deepseek_cfg_completion.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions pkg/core/stages/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .. import stage, app
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 m005_deepseek_cfg_completion


@stage.stage_class("MigrationStage")
Expand Down

0 comments on commit c459313

Please sign in to comment.