feat: add webui http channel for chat and file upload
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"laodingbot/internal/tools"
|
||||
"laodingbot/internal/transport/feishu"
|
||||
"laodingbot/internal/transport/telegram"
|
||||
"laodingbot/internal/transport/webui"
|
||||
)
|
||||
|
||||
// main 是程序的入口点。它负责初始化环境、加载配置、注册工具并启动消息通道。
|
||||
@@ -197,6 +198,21 @@ func runMessageChannel(ctx context.Context, cfg config.Config, engine *agent.Orc
|
||||
}
|
||||
return engine.HandleMessage(ctx, msg.ChatID, msg.UserID, msg.Text)
|
||||
})
|
||||
case "webui":
|
||||
wb, err := webui.NewBot(cfg.WebUI, lg.WithComponent("transport.webui"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("init webui bot failed: %w", err)
|
||||
}
|
||||
lg.Infof("starting webui transport listen_addr=%s", cfg.WebUI.ListenAddr)
|
||||
return wb.Run(
|
||||
ctx,
|
||||
func(ctx context.Context, msg webui.IncomingMessage) (string, error) {
|
||||
return engine.HandleMessage(ctx, msg.ChatID, msg.UserID, msg.Text)
|
||||
},
|
||||
func(ctx context.Context, chatID, userID string, files []llm.InputFile) ([]string, error) {
|
||||
return engine.UploadAndCacheFiles(ctx, chatID, userID, files)
|
||||
},
|
||||
)
|
||||
default:
|
||||
return fmt.Errorf("unsupported message channel: %s", cfg.MessageChannel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user