package main
import (
"context"
"fmt"
bifrost "github.com/maximhq/bifrost/core"
"github.com/maximhq/bifrost/core/schemas"
)
func main() {
client, err := bifrost.Init(context.Background(), schemas.BifrostConfig{
Account: &MyAccount{},
})
if err != nil {
panic(err)
}
defer client.Shutdown()
ctx := schemas.NewBifrostContext(context.Background(), schemas.NoDeadline)
response, bifrostErr := client.DecisionRequest(ctx, &schemas.BifrostDecisionRequest{
Provider: schemas.Typesafe,
Model: "jev-1.13.0",
State: "Customer message: I was double charged and nobody replied. I want a refund today.",
Questions: map[string]schemas.DecisionQuestion{
"is_frustrated": {
Kind: schemas.DecisionKindNoul,
Instructions: "Is the customer frustrated?",
},
"category": {
Kind: schemas.DecisionKindChoice,
Instructions: "Pick the ticket category",
Criteria: map[string]interface{}{
"billing": "charges and refunds",
"bug": "product defects",
"other": "anything else",
},
},
"urgency": {
Kind: schemas.DecisionKindScore,
Instructions: "Rate how urgently this needs a human reply",
Criteria: []interface{}{"can wait a week", "should be answered soon", "needs a reply today"},
},
},
})
if bifrostErr != nil {
panic(bifrostErr.Error.Message)
}
for name, answer := range response.Answers {
fmt.Printf("%s (%s): %v\n", name, answer.Kind, answer.Value)
}
}