diff --git a/README.md b/README.md index 8e2e48e369..c4d6a6550c 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用 > **Warning**:使用 Docker 拉取的最新镜像可能是 `alpha` 版本,如果追求稳定性请手动指定版本。 +> **Warning**:从 `v0.3` 版本升级到 `v0.4` 版本需要手动迁移数据库,请手动执行[数据库迁移脚本](./bin/migration_v0.3-v0.4.sql)。 + ## 功能 1. 支持多种 API 访问渠道,欢迎 PR 或提 issue 添加更多渠道: + [x] OpenAI 官方通道 diff --git a/bin/migration_v0.3-v0.4.sql b/bin/migration_v0.3-v0.4.sql new file mode 100644 index 0000000000..e6103c29ac --- /dev/null +++ b/bin/migration_v0.3-v0.4.sql @@ -0,0 +1,17 @@ +INSERT INTO abilities (`group`, model, channel_id, enabled) +SELECT c.`group`, m.model, c.id, 1 +FROM channels c +CROSS JOIN ( + SELECT 'gpt-3.5-turbo' AS model UNION ALL + SELECT 'gpt-3.5-turbo-0301' AS model UNION ALL + SELECT 'gpt-4' AS model UNION ALL + SELECT 'gpt-4-0314' AS model +) AS m +WHERE c.status = 1 + AND NOT EXISTS ( + SELECT 1 + FROM abilities a + WHERE a.`group` = c.`group` + AND a.model = m.model + AND a.channel_id = c.id +); diff --git a/model/ability.go b/model/ability.go index f3dae7ace9..26ff65d285 100644 --- a/model/ability.go +++ b/model/ability.go @@ -13,9 +13,6 @@ type Ability struct { } func GetRandomSatisfiedChannel(group string, model string) (*Channel, error) { - if group == "default" { - return GetRandomChannel() - } ability := Ability{} var err error = nil if common.UsingSQLite {