23 lines
568 B
Go
23 lines
568 B
Go
package ai
|
|
|
|
import (
|
|
"context"
|
|
|
|
domai "haixun-backend/internal/model/ai/domain/usecase"
|
|
"haixun-backend/internal/svc"
|
|
"haixun-backend/internal/types"
|
|
)
|
|
|
|
type ChatStreamLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewChatStreamLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatStreamLogic {
|
|
return &ChatStreamLogic{ctx: ctx, svcCtx: svcCtx}
|
|
}
|
|
|
|
func (l *ChatStreamLogic) ChatStream(req *types.AIChatReq, token string) (<-chan domai.StreamEvent, error) {
|
|
return l.svcCtx.AI.StreamText(l.ctx, toGenerateRequest(req, token))
|
|
}
|