feat 自定义问答

This commit is contained in:
2026-03-11 20:17:59 +08:00
parent 77cc02fc95
commit f73783b742

View File

@@ -0,0 +1,30 @@
package grpcserver
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
"git.hlsq.asia/mmorpg/service-common/utils"
"git.hlsq.asia/mmorpg/service-qgdzs/internal/ai"
)
func (s *Server) CustomAnswerQuestion(ctx context.Context, req *rspb.CustomAnswerQuestionReq) (*rspb.CustomAnswerQuestionResp, error) {
answer := ""
err := ai.NewAIClient(false, "", 0.9).
RequestAI(
[]string{
fmt.Sprintf(req.Question),
},
func(content string, i int) error {
if i == 0 {
return nil
}
answer = content
return nil
},
)
if err != nil {
return nil, utils.ErrorsWrap(err)
}
return &rspb.CustomAnswerQuestionResp{Answer: answer}, nil
}