github.com/hupe1980/go-huggingface@v0.0.15/_examples/conversational/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.Conversational(context.Background(), &huggingface.ConversationalRequest{
    16  		Inputs: huggingface.ConverstationalInputs{
    17  			PastUserInputs: []string{
    18  				"Which movie is the best ?",
    19  				"Can you explain why ?",
    20  			},
    21  			GeneratedResponses: []string{
    22  				"It's Die Hard for sure.",
    23  				"It's the best movie ever.",
    24  			},
    25  			Text: "Can you explain why ?",
    26  		},
    27  	})
    28  	if err != nil {
    29  		log.Fatal(err)
    30  	}
    31  
    32  	fmt.Println(res.GeneratedText)
    33  }