diff --git a/internal/grpcserver/server_custom.go b/internal/grpcserver/server_custom.go new file mode 100644 index 0000000..9454d2c --- /dev/null +++ b/internal/grpcserver/server_custom.go @@ -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 +}