31 lines
686 B
Go
31 lines
686 B
Go
package grpcserver
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
|
"git.hlsq.asia/alex/service-common/utils"
|
|
"git.hlsq.asia/alex/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
|
|
}
|