feat 自定义问答
This commit is contained in:
30
internal/grpcserver/server_custom.go
Normal file
30
internal/grpcserver/server_custom.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user