After you deploy a Qwak-based model, your Go-based client applications can use this module to get inferences from the model hosted as a real-time endpoint.

Installation

To install the SDK and its dependencies, run the following Go command:

go get github.com/qwak-ai/go-sdk/qwak

Inference examples

The following example invokes the model test_model which accepts one feature vector which contains three fields and produces one output field named "score".

package main

import (
	"fmt"
	"github.com/qwak-ai/go-sdk/qwak"
)


func main() {
	client, err := qwak.NewRealTimeClient(qwak.RealTimeClientConfig{
		ApiKey:      "api-key",
		Environment: "env-name",
	})

	if err != nil {
		fmt.Println("Errors occurred, Error: ", err)
	}

	predictionRequest := qwak.NewPredictionRequest("test_model").AddFeatureVector(
		qwak.NewFeatureVector().
			WithFeature("feature_a", "feature_value").
			WithFeature("feature_b", 1).
			WithFeature("feature_c", 0.5),
	)

	response, err := client.Predict(predictionRequest)
	if err != nil {
		fmt.Println("Errors occurred, Error: ", err)
	}

	val , err := response.GetSinglePrediction().GetValueAsInt("score")
	if err != nil {
		fmt.Println("Errors occurred, Error: ", err)
	}

	fmt.Println(val)
}