mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Commit from m3o/m3o action
This commit is contained in:
37
answer/answer.go
Executable file
37
answer/answer.go
Executable file
@@ -0,0 +1,37 @@
|
||||
package answer
|
||||
|
||||
import (
|
||||
"github.com/m3o/m3o-go/client"
|
||||
)
|
||||
|
||||
func NewAnswerService(token string) *AnswerService {
|
||||
return &AnswerService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type AnswerService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Ask a question and receive an instant answer
|
||||
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
|
||||
rsp := &QuestionResponse{}
|
||||
return rsp, t.client.Call("answer", "Question", request, rsp)
|
||||
}
|
||||
|
||||
type QuestionRequest struct {
|
||||
// the question to answer
|
||||
Query string `json:"query"`
|
||||
}
|
||||
|
||||
type QuestionResponse struct {
|
||||
// the answer to your question
|
||||
Answer string `json:"answer"`
|
||||
// any related image
|
||||
Image string `json:"image"`
|
||||
// a related url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
Reference in New Issue
Block a user