1
This commit is contained in:
Binary file not shown.
@@ -111,6 +111,19 @@ func (c *agent) Update(ctx context.Context, req *dto.UpdateAgentReq) (res *struc
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// 确保 agent_profile 存在
|
||||
profile, _ := dao.AgentProfile.Get(ctx, req.Id)
|
||||
if profile == nil {
|
||||
_ = dao.AgentProfile.Save(ctx, &entity.AgentProfile{
|
||||
UserId: req.Id,
|
||||
MaxCustomers: 0,
|
||||
Renewals: 0,
|
||||
ExpiredAt: gtime.Now().AddDate(1, 0, 0),
|
||||
RegionProtected: false,
|
||||
})
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,32 @@ func init() {
|
||||
if _, err := g.DB().Exec(ctx, `ALTER TABLE `+public.TableNameModelConfig+` ADD COLUMN price_per_second INTEGER NOT NULL DEFAULT 0`); err != nil {
|
||||
g.Log().Debugf(ctx, "添加列 price_per_second 失败(可能已存在): %v", err)
|
||||
}
|
||||
|
||||
// 初始化默认模型配置(仅当表为空时)
|
||||
count, _ := g.DB().Model(public.TableNameModelConfig).Ctx(ctx).Count()
|
||||
if count == 0 {
|
||||
_, err := g.DB().Model(public.TableNameModelConfig).Ctx(ctx).Data(g.Map{
|
||||
"chat_api_key": "sk-ws-H.RXDDPMR.E8Rn.MEUCIQD00xjpXeNJlnXQejmbFTyC5ILHF8hLB2at4QXU6nf6GwIgae5TA8siaylUxMBDQcOWFfNx6hxB4rFsdCxoV6md810",
|
||||
"chat_base_url": "https://dashscope.aliyuncs.com/compatible-mode",
|
||||
"chat_model_name": "qwen-math-turbo",
|
||||
"max_tokens": 8192,
|
||||
"temperature": 0.7,
|
||||
"video_api_key": "sk-ws-H.RXDDPMR.E8Rn.MEUCIQD00xjpXeNJlnXQejmbFTyC5ILHF8hLB2at4QXU6nf6GwIgae5TA8siaylUxMBDQcOWFfNx6hxB4rFsdCxoV6md810",
|
||||
"video_base_url": "https://ws-0mn9581u5vt4lcx9.cn-beijing.maas.aliyuncs.com/api/v1/tasks",
|
||||
"video_task_callback_url": "https://ws-0mn9581u5vt4lcx9.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}",
|
||||
"video_model_name": "wan2.7-r2v",
|
||||
"max_single_duration": 5,
|
||||
"min_single_duration": 2,
|
||||
"price_per_second": 10,
|
||||
"created_at": gtime.Now().Format("Y-m-d H:i:s"),
|
||||
"updated_at": gtime.Now().Format("Y-m-d H:i:s"),
|
||||
}).Insert()
|
||||
if err != nil {
|
||||
g.Log().Warningf(ctx, "初始化默认模型配置失败: %v", err)
|
||||
} else {
|
||||
g.Log().Info(ctx, "已初始化默认模型配置")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetFirst 获取第一条配置行
|
||||
|
||||
@@ -31,7 +31,8 @@ func init() {
|
||||
}
|
||||
_, _ = g.DB().Exec(ctx, "CREATE UNIQUE INDEX IF NOT EXISTS idx_user_username ON "+public.TableNameUser+"(username) WHERE username != ''")
|
||||
_, _ = g.DB().Exec(ctx, "CREATE UNIQUE INDEX IF NOT EXISTS idx_user_phone ON "+public.TableNameUser+"(phone) WHERE phone != ''")
|
||||
// add address column for existing databases
|
||||
// add columns for existing databases
|
||||
_, _ = g.DB().Exec(ctx, "ALTER TABLE "+public.TableNameUser+" ADD COLUMN province TEXT NOT NULL DEFAULT ''")
|
||||
_, _ = g.DB().Exec(ctx, "ALTER TABLE "+public.TableNameUser+" ADD COLUMN address TEXT NOT NULL DEFAULT ''")
|
||||
// cleanup legacy columns
|
||||
_, _ = g.DB().Exec(ctx, "ALTER TABLE "+public.TableNameUser+" DROP COLUMN status")
|
||||
|
||||
@@ -159,6 +159,8 @@ func syncModelDurationFromAPI(ctx context.Context, cfg *entity.ModelConfig) {
|
||||
|
||||
func inferChatMaxTokens(modelName string) int {
|
||||
switch {
|
||||
case strings.Contains(modelName, "qwen-math"):
|
||||
return 32768
|
||||
case strings.Contains(modelName, "qwen3"):
|
||||
return 65536
|
||||
case strings.Contains(modelName, "qwen2.5"):
|
||||
@@ -188,6 +190,8 @@ func inferChatMaxTokens(modelName string) int {
|
||||
|
||||
func inferChatTemperature(modelName string) float64 {
|
||||
switch {
|
||||
case strings.Contains(modelName, "qwen-math"):
|
||||
return 0.5
|
||||
case strings.Contains(modelName, "qwen3"):
|
||||
return 0.7
|
||||
case strings.Contains(modelName, "qwen2.5"):
|
||||
|
||||
Reference in New Issue
Block a user