fix: 修复配置加载并优化错误处理
This commit is contained in:
parent
bc9801d553
commit
d85df95a65
|
|
@ -5,12 +5,12 @@ server:
|
||||||
|
|
||||||
ollama:
|
ollama:
|
||||||
base_url: "http://172.17.0.1:11434"
|
base_url: "http://172.17.0.1:11434"
|
||||||
# model: "qwen3:8b"
|
model: "qwen3:8b"
|
||||||
# generate_model: "qwen3:8b"
|
generate_model: "qwen3:8b"
|
||||||
# mapping_model: "qwen3:8b"
|
mapping_model: "qwen3:8b"
|
||||||
model: "qwen3-coder:480b-cloud"
|
# model: "qwen3-coder:480b-cloud"
|
||||||
generate_model: "qwen3-coder:480b-cloud"
|
# generate_model: "qwen3-coder:480b-cloud"
|
||||||
mapping_model: "deepseek-v3.2:cloud"
|
# mapping_model: "deepseek-v3.2:cloud"
|
||||||
vl_model: "qwen2.5vl:3b"
|
vl_model: "qwen2.5vl:3b"
|
||||||
timeout: "120s"
|
timeout: "120s"
|
||||||
level: "info"
|
level: "info"
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,7 @@ func handleCozeWorkflowEvents(ctx context.Context, resp coze.Stream[coze.Workflo
|
||||||
case coze.WorkflowEventTypeMessage:
|
case coze.WorkflowEventTypeMessage:
|
||||||
entitys.ResStream(ch, index, event.Message.Content)
|
entitys.ResStream(ch, index, event.Message.Content)
|
||||||
case coze.WorkflowEventTypeError:
|
case coze.WorkflowEventTypeError:
|
||||||
entitys.ResError(ch, index, fmt.Sprintf("工作流执行错误: %s", event.Error))
|
entitys.ResError(ch, index, fmt.Sprintf("工作流执行错误: %v", event.Error))
|
||||||
case coze.WorkflowEventTypeDone:
|
case coze.WorkflowEventTypeDone:
|
||||||
entitys.ResEnd(ch, index, "工作流执行完成")
|
entitys.ResEnd(ch, index, "工作流执行完成")
|
||||||
case coze.WorkflowEventTypeInterrupt:
|
case coze.WorkflowEventTypeInterrupt:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
type Macro struct {
|
type Macro struct {
|
||||||
botGroupImpl *impl.BotGroupImpl
|
botGroupImpl *impl.BotGroupImpl
|
||||||
|
botGroupConfigImpl *impl.BotGroupConfigImpl
|
||||||
reportDailyCacheImpl *impl.ReportDailyCacheImpl
|
reportDailyCacheImpl *impl.ReportDailyCacheImpl
|
||||||
config *config.Config
|
config *config.Config
|
||||||
rdb *utils.Rdb
|
rdb *utils.Rdb
|
||||||
|
|
@ -36,12 +37,14 @@ func NewMacro(
|
||||||
reportDailyCacheImpl *impl.ReportDailyCacheImpl,
|
reportDailyCacheImpl *impl.ReportDailyCacheImpl,
|
||||||
config *config.Config,
|
config *config.Config,
|
||||||
rdb *utils.Rdb,
|
rdb *utils.Rdb,
|
||||||
|
botGroupConfigImpl *impl.BotGroupConfigImpl,
|
||||||
) *Macro {
|
) *Macro {
|
||||||
return &Macro{
|
return &Macro{
|
||||||
botGroupImpl: botGroupImpl,
|
botGroupImpl: botGroupImpl,
|
||||||
reportDailyCacheImpl: reportDailyCacheImpl,
|
reportDailyCacheImpl: reportDailyCacheImpl,
|
||||||
config: config,
|
config: config,
|
||||||
rdb: rdb,
|
rdb: rdb,
|
||||||
|
botGroupConfigImpl: botGroupConfigImpl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +196,7 @@ func (m *Macro) ProductModify(ctx context.Context, content string, groupConfig *
|
||||||
groupConfig.ProductName = itemInfo
|
groupConfig.ProductName = itemInfo
|
||||||
cond := builder.NewCond()
|
cond := builder.NewCond()
|
||||||
cond = cond.And(builder.Eq{"config_id": groupConfig.ConfigID})
|
cond = cond.And(builder.Eq{"config_id": groupConfig.ConfigID})
|
||||||
err = m.botGroupImpl.UpdateByCond(&cond, groupConfig)
|
err = m.botGroupConfigImpl.UpdateByCond(&cond, groupConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("修改失败:%v", err)
|
err = fmt.Errorf("修改失败:%v", err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package do
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ai_scheduler/internal/config"
|
||||||
|
"ai_scheduler/internal/data/impl"
|
||||||
|
"ai_scheduler/internal/data/model"
|
||||||
|
|
||||||
|
"ai_scheduler/utils"
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_report(t *testing.T) {
|
||||||
|
con := "[利润同比报表]商品修改:官方–优酷周卡,官方–优酷月卡,官方–优酷季卡,官方–优酷年卡,,官方–爱奇艺-月卡,官方–爱奇艺-季卡,官方–爱奇艺-年卡,官方–芒果-PC周卡,官方–芒果-PC月卡,官方–芒果-PC季卡,官方–QQ音乐-绿钻月卡,官方–饿了么超级会员月卡,官方–网易云黑胶vip月卡,官方–喜马拉雅巅峰会员月卡,剪映会员7天卡,剪映会员月卡,剪映会员年卡,剪映SVIP会员7天卡,剪映SVIP会员月卡,剪映SVIP会员年卡"
|
||||||
|
run()
|
||||||
|
|
||||||
|
chatId, err, i := ma.ProductModify(context.Background(), con, &model.AiBotGroupConfig{ConfigID: 1, ToolList: "8,9,10,11,12,13,16"})
|
||||||
|
t.Log(chatId, err, i)
|
||||||
|
}
|
||||||
|
|
||||||
|
var ma *Macro
|
||||||
|
|
||||||
|
func run() {
|
||||||
|
configConfig, _ := config.LoadConfigWithTest()
|
||||||
|
db, _ := utils.NewGormDb(configConfig)
|
||||||
|
|
||||||
|
rdb := utils.NewRdb(configConfig)
|
||||||
|
reportDailyCacheImpl := impl.NewReportDailyCacheImpl(db)
|
||||||
|
botGroupImpl := impl.NewBotGroupImpl(db)
|
||||||
|
botGroupConfigImpl := impl.NewBotGroupConfigImpl(db)
|
||||||
|
ma = NewMacro(botGroupImpl, reportDailyCacheImpl, configConfig, rdb, botGroupConfigImpl)
|
||||||
|
}
|
||||||
|
|
@ -106,7 +106,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func run() {
|
func run() {
|
||||||
configConfig, _ = config.LoadConfigWithTest()
|
configConfig, _ = config.LoadConfigWithEnv()
|
||||||
// 初始化数据库连接
|
// 初始化数据库连接
|
||||||
db, _ := utils.NewGormDb(configConfig)
|
db, _ := utils.NewGormDb(configConfig)
|
||||||
reportDailyCacheImpl = impl.NewReportDailyCacheImpl(db)
|
reportDailyCacheImpl = impl.NewReportDailyCacheImpl(db)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue