Documentation ¶
Index ¶
- Constants
- Variables
- type AmountOfMoneyInterval
- type Client
- func (client *Client) AudioMessage(request *MessageRequest) (*MessageResponse, 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) IntentShow(intentId string) (*Intent, error)
- func (client *Client) Intents() (*Intents, error)
- func (client *Client) Message(q string) (*MessageResponse, error)
- func (client *Client) UpdateEntity(entity *Entity) ([]byte, error)
- type Datetime
- type DatetimeInterval
- type Entities
- type Entity
- type EntityValue
- type Expression
- type HTTPParams
- type Intent
- type IntentEntity
- type IntentExpression
- type IntentExpressionEntity
- type Intents
- type MessageEntity
- type MessageRequest
- type MessageResponse
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=20170307" )
Variables ¶
var APIKey string
Stores the ApiKey for the Wit API
Functions ¶
This section is empty.
Types ¶
type AmountOfMoneyInterval ¶
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) (*MessageResponse, 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(q string) (*MessageResponse, error)
Message requests processing of a text message (https://wit.ai/docs/http/20170307#get--message-link)
message, err := client.Message("Hello world")
func (*Client) UpdateEntity ¶
UpdateEntity updates and entity (https://wit.ai/docs/api#toc_22)
result, err := client.UpdateEntity(entity)
type DatetimeInterval ¶
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"` Exotic bool `json:"exotic,omitempty"` ID string `json:"id"` Lang string `json:"lang,omitempty"` Name string `json:"name,omitempty"` Lookups []string `json:"lookups,omitempty"` }
Entity represents an Entity for the Wit API (https://wit.ai/docs/api#toc_15)
type EntityValue ¶
type EntityValue struct { Value string `json:"value"` Metadata string `json:"metadata,omitempty"` Expressions []string `json:"expressions"` }
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 Intent ¶
type Intent struct { ID string `json:"id"` Name string `json:"name"` Doc string `json:"doc"` Metadata string `json:"metadata"` Entities []IntentEntity `json:"entities"` Expressions []IntentExpression `json:"expressions"` }
type IntentEntity ¶
type IntentExpression ¶
type IntentExpression struct { Body string `json:"body"` ID string `json:"id"` ExpressionEntities []IntentExpressionEntity `json:"entities"` }
type IntentExpressionEntity ¶
type MessageEntity ¶
type MessageEntity struct { Metadata *string `json:"metadata,omitempty"` Value interface{} `json:"value,omitempty"` Confidence float64 `json:"confidence"` Body *string `json:"body,omitempty"` Start *int64 `json:"start,omitempty"` End *int64 `json:"end,omitempty"` Type *string `json:"type,omitempty"` Unit *string `json:"unit,omitempty"` From interface{} `json:"from,omitempty"` To interface{} `json:"to,omitempty"` Values interface{} `json:"values,omitempty"` }
MessageEntity represents the entity portion of a Wit message
type MessageRequest ¶
type MessageRequest struct { File string `json:"file,omitempty"` MsgID string `json:"msg_id,omitempty"` Context string `json:"context, omitempty"` ContentType string `json:"contentType, omitempty"` FileContents []byte `json:"-"` }
MessageRequest represents a request to process a message
type MessageResponse ¶
type MessageResponse struct { MsgID string `json:"msg_id"` Text string `json:"_text"` Entities map[string][]MessageEntity `json:"entities"` }
MessageResponse represents a Wit message (https://wit.ai/docs/api#toc_3)