2025-02-01 14:19:21 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from .. import migration
|
|
|
|
|
|
|
|
|
|
|
2025-04-29 17:24:07 +08:00
|
|
|
@migration.migration_class('siliconflow-config', 23)
|
2025-02-01 14:19:21 +08:00
|
|
|
class SiliconFlowConfigMigration(migration.Migration):
|
|
|
|
|
"""迁移"""
|
|
|
|
|
|
|
|
|
|
async def need_migrate(self) -> bool:
|
|
|
|
|
"""判断当前环境是否需要运行此迁移"""
|
2025-04-29 17:24:07 +08:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
'siliconflow-chat-completions' not in self.ap.provider_cfg.data['requester']
|
|
|
|
|
)
|
2025-02-01 14:19:21 +08:00
|
|
|
|
|
|
|
|
async def run(self):
|
|
|
|
|
"""执行迁移"""
|
2025-04-29 17:24:07 +08:00
|
|
|
self.ap.provider_cfg.data['keys']['siliconflow'] = ['xxxxxxx']
|
2025-02-01 14:19:21 +08:00
|
|
|
|
|
|
|
|
self.ap.provider_cfg.data['requester']['siliconflow-chat-completions'] = {
|
2025-04-29 17:24:07 +08:00
|
|
|
'base-url': 'https://api.siliconflow.cn/v1',
|
|
|
|
|
'args': {},
|
|
|
|
|
'timeout': 120,
|
2025-02-01 14:19:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await self.ap.provider_cfg.dump_config()
|