diff --git a/_examples/question_answering/main.go b/_examples/question_answering/main.go index 615012d..c81ccd6 100644 --- a/_examples/question_answering/main.go +++ b/_examples/question_answering/main.go @@ -22,5 +22,8 @@ func main() { log.Fatal(err) } - fmt.Println(res[0].Answer) + fmt.Println("Answer:", res.Answer) + fmt.Println("Score:", res.Score) + fmt.Println("Start:", res.Start) + fmt.Println("End:", res.End) } diff --git a/huggingface.go b/huggingface.go index 4179563..194bfbc 100644 --- a/huggingface.go +++ b/huggingface.go @@ -149,7 +149,7 @@ func (ic *InferenceClient) ZeroShotClassification(ctx context.Context, req *Zero // QuestionAnswering performs question answering using the specified model. // It sends a POST request to the Hugging Face inference endpoint with the provided question and context inputs. // The response contains the answer or an error if the request fails. -func (ic *InferenceClient) QuestionAnswering(ctx context.Context, req *QuestionAnsweringRequest) (QuestionAnsweringResponse, error) { +func (ic *InferenceClient) QuestionAnswering(ctx context.Context, req *QuestionAnsweringRequest) (*QuestionAnsweringResponse, error) { if req.Inputs.Question == "" { return nil, errors.New("question is required") } @@ -168,7 +168,7 @@ func (ic *InferenceClient) QuestionAnswering(ctx context.Context, req *QuestionA return nil, err } - return questionAnsweringResponse, nil + return &questionAnsweringResponse, nil } // TableQuestionAnswering performs table-based question answering using the specified model. diff --git a/question_answering.go b/question_answering.go index 8af327e..c5bd79c 100644 --- a/question_answering.go +++ b/question_answering.go @@ -17,7 +17,7 @@ type QuestionAnsweringRequest struct { } // Response structure for question answering model -type QuestionAnsweringResponse []struct { +type QuestionAnsweringResponse struct { // A string that’s the answer within the Context text. Answer string `json:"answer,omitempty"`