From 2cd19e5fdfbd381ddc06db2c74aadff3034fc1c9 Mon Sep 17 00:00:00 2001 From: wolter <11@gmail> Date: Fri, 21 Nov 2025 15:25:01 +0800 Subject: [PATCH] feat: chat --- internal/biz/router.go | 5 +---- internal/entitys/response.go | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/biz/router.go b/internal/biz/router.go index 70a069e..6dcc233 100644 --- a/internal/biz/router.go +++ b/internal/biz/router.go @@ -46,10 +46,7 @@ func (r *AiRouterBiz) RouteWithSocket(client *gateway.Client, req *entitys.ChatS ctx, clearFunc := r.do.MakeCh(conn, requireData) defer func() { if err != nil { - requireData.Ch <- entitys.Response{ - Content: err.Error(), - Type: entitys.ResponseErr, - } + entitys.ResError(requireData.Ch, "", err.Error()) } clearFunc() }() diff --git a/internal/entitys/response.go b/internal/entitys/response.go index 5262102..cdadc98 100644 --- a/internal/entitys/response.go +++ b/internal/entitys/response.go @@ -67,6 +67,13 @@ func ResLoading(ch chan Response, index string, content string) { Type: ResponseLoading, } } +func ResError(ch chan Response, index string, content string) { + ch <- Response{ + Index: index, + Content: content, + Type: ResponseErr, + } +} type ResponseData struct { Done bool