feat(ollama): 配置文件迁移

This commit is contained in:
RockChinQ 2024-07-09 23:37:34 +08:00
parent bdb8baeddd
commit 3dc413638b
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,23 @@
from __future__ import annotations
from .. import migration
@migration.migration_class("ollama-requester-config", 10)
class MsgTruncatorConfigMigration(migration.Migration):
"""迁移"""
async def need_migrate(self) -> bool:
"""判断当前环境是否需要运行此迁移"""
return 'ollama-chat' not in self.ap.provider_cfg.data['requester']
async def run(self):
"""执行迁移"""
self.ap.provider_cfg.data['requester']['ollama-chat'] = {
"base-url": "http://127.0.0.1:11434",
"args": {},
"timeout": 600
}
await self.ap.provider_cfg.dump_config()

View File

@ -6,6 +6,7 @@ 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, m006_vision_config, m007_qcg_center_url, m008_ad_fixwin_config_migrate, m009_msg_truncator_cfg from ...config.migrations import m005_deepseek_cfg_completion, m006_vision_config, m007_qcg_center_url, m008_ad_fixwin_config_migrate, m009_msg_truncator_cfg
from ...config.migrations import m010_ollama_requester_config
@stage.stage_class("MigrationStage") @stage.stage_class("MigrationStage")

View File

@ -37,6 +37,11 @@
"base-url": "https://api.deepseek.com", "base-url": "https://api.deepseek.com",
"args": {}, "args": {},
"timeout": 120 "timeout": 120
},
"ollama-chat": {
"base-url": "http://127.0.0.1:11434",
"args": {},
"timeout": 600
} }
}, },
"model": "gpt-3.5-turbo", "model": "gpt-3.5-turbo",