Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (client *Client) AudioMessage(request *MessageRequest) (*Message, error)
- func (client *Client) CreateEntity(entity *Entity) (*Entity, error)
- func (client *Client) CreateEntityValue(id string, entityValue *EntityValue) (*Entity, error)
- func (client *Client) CreateEntityValueExp(id string, value string, exp string) (*Entity, error)
- func (client *Client) DeleteEntity(id string) error
- func (client *Client) DeleteEntityValue(id string, value string) ([]byte, error)
- func (client *Client) DeleteEntityValueExp(id string, value string, exp string) ([]byte, error)
- func (client *Client) Entities() (*Entities, error)
- func (client *Client) Entity(id string) (*Entity, error)
- func (client *Client) Intents() (*Intents, error)
- func (client *Client) Message(request *MessageRequest) (*Message, error)
- func (client *Client) Messages(id string) (*Message, error)
- func (client *Client) UpdateEntity(entity *Entity) ([]byte, error)
- type Context
- type DatetimeIntervalEnd
- type DatetimeValue
- type Entities
- type Entity
- type EntityValue
- type Expression
- type HTTPParams
- type Intents
- type Message
- type MessageEntity
- type MessageRequest
- type Outcome
Constants ¶
const ( // UserAgent is the HTTP Uesr Agent sent on HTTP requests UserAgent = "WIT (Go net/http)" // APIVersion is the version of the Wit API supported APIVersion = "v=20151127" )
Variables ¶
var APIKey string
Stores the ApiKey for the Wit API
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
APIBase string
}
Client represents a client for the Wit API (https://wit.ai/docs/api)
func NewClient ¶
NewClient creates a new client for the Wit API
client := wit.NewClient("<ACCESS-TOKEN>")
func (*Client) AudioMessage ¶
func (client *Client) AudioMessage(request *MessageRequest) (*Message, error)
AudioMessage requests processing of an audio message (https://wit.ai/docs/api#toc_8)
request := &MessageRequest{}
request.File = "./audio_sample/helloWorld.wav"
request.FileContents = data
request.ContentType = "audio/wav;rate=8000"
message, err := client.AudioMessage(request)
func (*Client) CreateEntity ¶
CreateEntity creates a new entity (https://wit.ai/docs/api#toc_19)
result, err := client.CreateEntity(entity)
func (*Client) CreateEntityValue ¶
func (client *Client) CreateEntityValue(id string, entityValue *EntityValue) (*Entity, error)
CreateEntityValue creates a new entity value (https://wit.ai/docs/api#toc_25)
result, err := client.CreateEntityValue("favorite_city, entityValue)
func (*Client) CreateEntityValueExp ¶
CreateEntityValueExp creates a new entity value expression (https://wit.ai/docs/api#toc_25)
result, err := client.CreateEntityValueExp("favorite_city", "Barcelona", "Paella")
func (*Client) DeleteEntity ¶
DeleteEntity deletes an entity (https://wit.ai/docs/api#toc_30)
result, err := client.DeleteEntity("favorite_city")
func (*Client) DeleteEntityValue ¶
DeleteEntityValue deletes an entity's value (https://wit.ai/docs/api#toc_25)
result, err := client.DeleteEntityValue("favorite_city", "Paris")
func (*Client) DeleteEntityValueExp ¶
DeleteEntityValueExp deletes an entity's value's expression (https://wit.ai/docs/api#toc_35)
result, err := client.DeleteEntityValueExp("favorite_city", "Paris", "")
func (*Client) Entities ¶
Entities lists the configured entities (https://wit.ai/docs/api#toc_15)
result, err := client.Entities()
func (*Client) Entity ¶
Entity lists a single configured entity (https://wit.ai/docs/api#toc_17)
result, err := client.Entity("wit$temperature")
func (*Client) Intents ¶
Intents lists intents configured in the Wit API (https://wit.ai/docs/api#toc_13)
result, err := client.Intents()
func (*Client) Message ¶
func (client *Client) Message(request *MessageRequest) (*Message, error)
Message requests processing of a text message (https://wit.ai/docs/api#toc_3)
result, err := client.Message(request)
func (*Client) Messages ¶
Messages lists an already existing message (https://wit.ai/docs/api#toc_11)
result, err := client.Messages("ba0fcf60-44d3-4499-877e-c8d65c239730")
func (*Client) UpdateEntity ¶
UpdateEntity updates and entity (https://wit.ai/docs/api#toc_22)
result, err := client.UpdateEntity(entity)
type Context ¶
type Context struct {
ReferenceTime string `json:"reference_time"`
Timezone string `json:"timezone"`
}
Context represents the context portion of the message request
type DatetimeIntervalEnd ¶
type DatetimeValue ¶
type DatetimeValue struct {
From DatetimeIntervalEnd `json:"from"`
To DatetimeIntervalEnd `json:"to"`
}
DatetimeValue represents the datetime value portion of a Wit message
type Entities ¶
type Entities []string
Entities represents a slice of entites when returend as an array (https://wit.ai/docs/api#toc_15)
type Entity ¶
type Entity struct {
Builtin bool `json:"builtin,omitempty"`
Doc string `json:"doc"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
Values []EntityValue `json:"values"`
}
Entity represents an Entity for the Wit API (https://wit.ai/docs/api#toc_15)
type EntityValue ¶
EntityValue represents a Value within an Entity
type Expression ¶
type Expression struct {
Expression string `json:"expression"`
}
Expression respresents the expression
type HTTPParams ¶
HTTPParams represents the HTTP parameters to pass along to the Wit API
type Intents ¶
type Intents []struct {
ID string `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
Metadata string `json:"metadata"`
}
Intents represents intents in the Wit API (https://wit.ai/docs/api#toc_13)
type Message ¶
type Message struct {
MsgID string `json:"msg_id"`
Text string `json:"_text"`
Outcomes []Outcome `json:"outcomes"`
}
Message represents a Wit message (https://wit.ai/docs/api#toc_3)
type MessageEntity ¶
type MessageEntity struct {
Metadata *string `json:"metadata,omitempty"`
Value *interface{} `json:"value,omitempty"`
Grain *string `json:"grain,omitempty"`
Type *string `json:"type,omitempty"`
Unit *string `json:"unit,omitempty"`
Body *string `json:"body,omitempty"`
Entity *string `json:"entity,omitempty"`
Start *int64 `json:"start,omitempty"`
End *int64 `json:"end,omitempty"`
Values *[]interface{} `json:"values,omitempty"`
From *DatetimeIntervalEnd `json:"from,omitempty"`
To *DatetimeIntervalEnd `json:"to,omitempty"`
}
MessageEntity represents the entity portion of a Wit message
type MessageRequest ¶
type MessageRequest struct {
File string `json:"file,omitempty"`
Query string `json:"query"`
MsgID string `json:"msg_id,omitempty"`
Context string `json:"context, omitempty"`
ContentType string `json:"contentType, omitempty"`
N int `json:"n,omitempty"`
FileContents []byte `json:"-"`
}
MessageRequest represents a request to process a message