github.com/hupe1980/go-huggingface@v0.0.15/_examples/text_classification/main.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"log"
     7  	"os"
     8  
     9  	"github.com/hupe1980/go-huggingface"
    10  )
    11  
    12  func main() {
    13  	ic := huggingface.NewInferenceClient(os.Getenv("HUGGINGFACEHUB_API_TOKEN"))
    14  
    15  	res, err := ic.TextClassification(context.Background(), &huggingface.TextClassificationRequest{
    16  		Inputs: "The answer to the universe is 42",
    17  		//Model:  "deepset/deberta-v3-base-injection", // overwrite recommended model
    18  	})
    19  	if err != nil {
    20  		log.Fatal(err)
    21  	}
    22  
    23  	fmt.Println(res[0])
    24  }