67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func main() {
|
|
_ = godotenv.Load("../../.env")
|
|
|
|
databaseURL := os.Getenv("DATABASE_URL")
|
|
if databaseURL == "" {
|
|
log.Fatal("DATABASE_URL 环境变量未设置")
|
|
}
|
|
|
|
ctx := context.Background()
|
|
pool, err := pgxpool.New(ctx, databaseURL)
|
|
if err != nil {
|
|
log.Fatalf("连接数据库失败: %v", err)
|
|
}
|
|
defer pool.Close()
|
|
|
|
// 插入阿里云百炼(通义千问)配置
|
|
sql := `
|
|
INSERT INTO model_providers (
|
|
name,
|
|
base_url,
|
|
api_key_encrypted,
|
|
models,
|
|
is_active,
|
|
priority,
|
|
config
|
|
) VALUES (
|
|
'阿里云百炼 (通义千问)',
|
|
'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
'sk-c0c5174892c44ff48d587cd040fbdd40',
|
|
'[
|
|
{"id": "qwen-plus", "name": "通义千问-Plus", "type": "chat"},
|
|
{"id": "qwen-turbo", "name": "通义千问-Turbo", "type": "chat"},
|
|
{"id": "qwen-max", "name": "通义千问-Max", "type": "chat"},
|
|
{"id": "qwen-long", "name": "通义千问-Long", "type": "chat"}
|
|
]'::jsonb,
|
|
true,
|
|
100,
|
|
'{
|
|
"provider": "openai",
|
|
"default_model": "qwen-plus",
|
|
"supports_function_calling": true,
|
|
"supports_streaming": true
|
|
}'::jsonb
|
|
)
|
|
ON CONFLICT DO NOTHING
|
|
`
|
|
|
|
_, err = pool.Exec(ctx, sql)
|
|
if err != nil {
|
|
log.Fatalf("插入数据失败: %v", err)
|
|
}
|
|
|
|
fmt.Println("✅ 成功初始化模型提供商数据:阿里云百炼 (通义千问)")
|
|
}
|