55 lines
1.8 KiB
Go
55 lines
1.8 KiB
Go
package biz
|
|
|
|
import (
|
|
"ai_scheduler/internal/config"
|
|
"ai_scheduler/internal/data/impl"
|
|
"ai_scheduler/internal/data/model"
|
|
"ai_scheduler/internal/entitys"
|
|
"ai_scheduler/internal/pkg/utils_ollama"
|
|
"ai_scheduler/internal/tools"
|
|
"ai_scheduler/utils"
|
|
"encoding/json"
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/gofiber/fiber/v2/log"
|
|
)
|
|
|
|
func Test_task(t *testing.T) {
|
|
var c entitys.TaskConfig
|
|
config := `{"param": {"type": "object", "required": ["number"], "properties": {"number": {"type": "string", "description": "订单编号/流水号"}}}, "request": {"url": "http://www.baidu.com/${number}", "headers": {"Authorization": "${authorization}"}, "method": "GET"}}`
|
|
err := json.Unmarshal([]byte(config), &c)
|
|
t.Log(err)
|
|
}
|
|
|
|
type configData struct {
|
|
Param map[string]interface{} `json:"param"`
|
|
Do map[string]interface{} `json:"do"`
|
|
}
|
|
|
|
func Test_Order(t *testing.T) {
|
|
routerBiz := in()
|
|
err := routerBiz.handleTask(nil, &entitys.Match{Index: "order_diagnosis"}, &model.AiTask{Config: `{"tool": "zltxOrderDetail", "param": {"type": "object", "optional": [], "required": ["order_number"], "properties": {"order_number": {"type": "string", "description": "订单编号/流水号"}}}}`})
|
|
t.Log(err)
|
|
}
|
|
|
|
func in() *AiRouterBiz {
|
|
configPath := flag.String("config", "./config/config.yaml", "Path to configuration file")
|
|
flag.Parse()
|
|
configConfig, err := config.LoadConfig(*configPath)
|
|
if err != nil {
|
|
panic("加载配置失败")
|
|
}
|
|
allLogger := log.DefaultLogger()
|
|
manager := tools.NewManager(configConfig)
|
|
db, _ := utils.NewGormDb(configConfig)
|
|
sessionImpl := impl.NewSessionImpl(db)
|
|
sysImpl := impl.NewSysImpl(db)
|
|
taskImpl := impl.NewTaskImpl(db)
|
|
chatImpl := impl.NewChatImpl(db)
|
|
utilOllama := utils_ollama.NewUtilOllama(configConfig, allLogger)
|
|
routerBiz := NewAiRouterBiz(manager, sessionImpl, sysImpl, taskImpl, chatImpl, configConfig, utilOllama)
|
|
|
|
return routerBiz
|
|
}
|