Files
freedak f7a720204a Update: 将子项目从 submodule 转为完整内容
- 移除 GovAI, nomifun-tauri, 算力盒子 的 submodule 引用
- 添加所有子项目的完整源代码
- 保留原始 .git 为 .git.bak 备份
2026-07-04 19:20:46 +08:00

73 lines
1.5 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()
// 插入阿里云百炼(通义千问)配置
apiKey := os.Getenv("QWEN_API_KEY")
if apiKey == "" {
log.Println("⚠️ QWEN_API_KEY 未设置,跳过初始化千问")
return
}
sql := `
INSERT INTO model_providers (
name,
base_url,
api_key_encrypted,
models,
is_active,
priority,
config
) VALUES (
'阿里云百炼 (通义千问)',
'https://dashscope.aliyuncs.com/compatible-mode/v1',
$1,
'[
{"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, apiKey)
if err != nil {
log.Fatalf("插入数据失败: %v", err)
}
fmt.Println("✅ 成功初始化模型提供商数据:阿里云百炼 (通义千问)")
}