watson

package
v0.0.0-...-058b651 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// URL is the API URL.
	URL string `json:"url" yaml:"url"`

	// Version is the version of the API.
	Version string `json:"version" yaml:"yaml"`

	// IAMApiKey is the API key.
	IAMApiKey string `json:"apiKey" yaml:"apiKey"`
}

Config is the struct representing the config file. All these data are required to build a new connection.

type Generic

type Generic struct {
	// ResponseType represents the response type (ex: text)
	ResponseType string `json:"response_type"`
	// Text is the text of the value
	Text string `json:"text"`
}

Generic is a response value.

type Intent

type Intent struct {
	// Intent is the value of the intent.
	Intent string `json:"intent"`

	// Confidence is the confidence with which Watson gives the intention.
	Confidence float32 `json:"confidence"`
}

Intent represents a response intent.

type OutputWatson

type OutputWatson struct {
	// Generics is a slice containing all response values.
	Generics []*Generic `json:"generic"`

	// Intents is a slice containing all intents values.
	Intents []*Intent `json:"intents"`
}

OutputWatson contains the response values and the its intents.

type ResponseWatson

type ResponseWatson struct {
	// StatusCode is the status code of the response.
	StatusCode int `json:"StatusCode"`

	// Result is the result of the response.
	Result *ResultWatson `json:"Result"`
}

ResponseWatson is the struct which represents a response given by Watson to a user input. It is useful to parse the string-formatted response to its structured format.

type ResultWatson

type ResultWatson struct {
	// Output is the output of the response
	Output *OutputWatson `json:"output"`
}

ResultWatson is an intermediate struct of the Watson response.

type Watson

type Watson struct {
	// contains filtered or unexported fields
}

Watson is client which communicates with the IBM Watson Assistant API

func (*Watson) CreateSession

func (w *Watson) CreateSession(id string) error

CreateSession creates a new client session which would communicate with a IBM Watson Assistant.

func (*Watson) GetLabel

func (w *Watson) GetLabel() string

GetLabel returns the provider label.

func (*Watson) Initialize

func (w *Watson) Initialize(config *provider.Config) (provider.Provider, error)

Initialize initializes a new IBM Watson client and returns a new Watson struct.

func (*Watson) Message

func (w *Watson) Message(message string) (*provider.Response, error)

Message sends the user input to the IBM Watson Assistant and return a structured result of this text processing.

func (*Watson) Stop

func (w *Watson) Stop() error

Stop deletes the session which communicates with the IBM Watson Assistant.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL