Documentation ¶
Index ¶
- Variables
- type API
- type ActionVarType
- type ActionVariable
- type Analytics
- type Bot
- type CMatch
- type Chat
- type CognitiveService
- type CommunicationChannel
- type Configuration
- type Context
- func (c *Context) DeleteContextVariable(name string, value interface{})
- func (c *Context) GetFloat64ContextVariable(name string, _default float64) float64
- func (c *Context) GetIntContextVariable(name string, _default int) int
- func (c *Context) GetStringContextVariable(name string, _default string) string
- func (c *Context) SetContextVariable(name string, value interface{})
- func (c *Context) String() string
- type ContextFabric
- type ContextRecord
- type Dialog
- type DialogNode
- type DialogNodeMatch
- type Engine
- func (engine *Engine) Inject(channel CommunicationChannel, matcher *Matcher, middle InInjection)
- func (engine *Engine) InjectAll(channel CommunicationChannel, middle InInjection)
- func (engine *Engine) RegisterAdmin(Username, Password string) error
- func (engine *Engine) RemoveAdmin(Username string) error
- func (engine *Engine) Resolve(channel CommunicationChannel, matcher *Matcher, handler HandleResolver)
- func (engine *Engine) ResolveAny(channel CommunicationChannel, handler HandleResolver)
- func (engine *Engine) ResolveMany(channels []CommunicationChannel, matcher *Matcher, handler HandleResolver)
- func (engine *Engine) ResolveManyAny(channels []CommunicationChannel, handler HandleResolver)
- func (engine *Engine) Run() error
- func (engine *Engine) SetPerformanceMetric(perf func(*Dialog) float64)
- type Entity
- type HandleResolver
- type InInjection
- type Input
- type InputData
- type InputRecord
- type InputType
- type Intent
- type LogLevelType
- type LogMessage
- type Match
- type Matcher
- func IfContextVariableIs(name string, value interface{}) *Matcher
- func IfDialogNodeIs(title, name string) *Matcher
- func IfDialogNodeNameIs(name string) *Matcher
- func IfDialogNodeTitleIs(title string) *Matcher
- func IfEntityIs(entity string, confidence ...float64) *Matcher
- func IntentIs(intent string, confidence ...float64) *Matcher
- func (m *Matcher) And(and *Matcher) *Matcher
- func (m *Matcher) AndEntityIs(entity string, confidence ...float64) *Matcher
- func (m *Matcher) AndIfContextVariableIs(name string, value interface{}) *Matcher
- func (m *Matcher) AndIfDialogNodeIs(title, name string) *Matcher
- func (m *Matcher) AndIfDialogNodeNameIs(name string) *Matcher
- func (m *Matcher) AndIfDialogNodeTitleIs(title string) *Matcher
- func (m *Matcher) AndIntentIs(intent string, confidence ...float64) *Matcher
- func (m *Matcher) Or(or *Matcher) *Matcher
- func (m *Matcher) OrEntityIs(entity string, confidence ...float64) *Matcher
- func (m *Matcher) OrIfContextVariableIs(name string, value interface{}) *Matcher
- func (m *Matcher) OrIfDialogNodeIs(title, name string) *Matcher
- func (m *Matcher) OrIfDialogNodeNameIs(name string) *Matcher
- func (m *Matcher) OrIfDialogNodeTitleIs(title string) *Matcher
- func (m *Matcher) OrIntentIs(intent string, confidence ...float64) *Matcher
- type Message
- type MessageOwner
- type MessageResponse
- type MiddleHandler
- type Option
- type OptionsResponse
- type Output
- func (out *Output) AddImageResponse(url string) *Output
- func (out *Output) AddListOfOptionsResponse(options []OptionsResponse) *Output
- func (out *Output) AddOptionsResponse(title string, subtitle string, options ...Option) *Output
- func (out *Output) AddPauseResponse(duration time.Duration) *Output
- func (out *Output) AddTextResponse(resp string) *Output
- func (out *Output) Clean() *Output
- func (out *Output) ClearResponses() *Output
- func (out *Output) Fill(data interface{}) *Output
- func (out *Output) Match(c *Context, matcher *Matcher) bool
- type OutputRecord
- type OutputResponse
- type PersonInfo
- type Pipeline
- type Repository
- type Response
- type ResponseType
- type Summary
- type TimeAnalysisResult
- type TimeFrame
- type TimeFramePreset
- type UsersSummary
- type View
- type ViewClass
- type ViewClassType
- type ViewStyle
Constants ¶
This section is empty.
Variables ¶
var ErrChannelIsNotRegistered = errors.New("channel not exist on this engine instance")
var ErrContextNotExist = errors.New("context is not valid or not exist")
var ErrInvalidInputType = errors.New("invalid or unimplemented input type")
var ErrInvalidResponseFromCognitiveService = errors.New("invalid response from cognitive service")
var ErrSessionExpired = errors.Default("session expired")
var ErrSessionNotExist = errors.New("session not exist")
Functions ¶
This section is empty.
Types ¶
type ActionVariable ¶
type ActionVariable struct { Name string `json:"name"` Type ActionVarType `json:"type"` Value []byte `json:"value"` }
type CognitiveService ¶
type CommunicationChannel ¶
type CommunicationChannel interface { RegisterMessageEndpoint(handler MiddleHandler) error ToHear() error GetContextFabric() ContextFabric // TODO: Rev SetContextFabric(fabric ContextFabric) OnNewContextCreated(callback func(c *Context)) OnContextIsDone(callback func(c *Context)) CallContextDone(c *Context) }
type Configuration ¶
type Configuration struct { }
type Context ¶
type Context struct { Context *context.Context `json:"-" bson:"-"` SessionID string `json:"session_id" bson:"session_id"` Person PersonInfo `json:"person" bson:"person"` Variables map[string]interface{} `json:"variables" bson:"variables"` }
Context represent the context of a conversation
func (*Context) DeleteContextVariable ¶
func (*Context) GetFloat64ContextVariable ¶
func (*Context) GetIntContextVariable ¶
func (*Context) GetStringContextVariable ¶
func (*Context) SetContextVariable ¶
type ContextFabric ¶
type ContextFabric func(ctx context.Context, info PersonInfo) *Context
type ContextRecord ¶
type Dialog ¶
type Dialog struct { ID string `json:"id" bson:"id"` StartAt time.Time `json:"start_at" bson:"start_at"` LastActivity time.Time `json:"last_activity" bson:"last_activity"` EndAt time.Time `json:"end_at" bson:"end_at"` Ins []*InputRecord `json:"ins" bson:"ins"` Outs []*OutputRecord `json:"outs" bson:"outs"` Contexts []*ContextRecord `json:"contexts" bson:"contexts"` Performance float64 `json:"performance" bson:"performance"` }
func (*Dialog) HasContextVar ¶
func (*Dialog) HasDialogNode ¶
type DialogNode ¶
type DialogNode struct { Name string `json:"name"` Title string `json:"title"` Conditions string `json:"conditions"` }
DialogNode represents a node into complex tree of any dialog
type DialogNodeMatch ¶
type Engine ¶
type Engine struct { Repository Repository ActiveDialogs map[*Context]*Dialog Register map[string]string Analytics *Analytics // contains filtered or unexported fields }
func Default ¶
func Default(repository Repository, cognitive CognitiveService, channels ...CommunicationChannel) (*Engine, error)
Default ...
func (*Engine) Inject ¶
func (engine *Engine) Inject(channel CommunicationChannel, matcher *Matcher, middle InInjection)
func (*Engine) InjectAll ¶
func (engine *Engine) InjectAll(channel CommunicationChannel, middle InInjection)
func (*Engine) RegisterAdmin ¶
RegisterAdmin you can register new admin for get info purpose
func (*Engine) RemoveAdmin ¶
RemoveAdmin let you remove the admin
func (*Engine) Resolve ¶
func (engine *Engine) Resolve(channel CommunicationChannel, matcher *Matcher, handler HandleResolver)
func (*Engine) ResolveAny ¶
func (engine *Engine) ResolveAny(channel CommunicationChannel, handler HandleResolver)
func (*Engine) ResolveMany ¶
func (engine *Engine) ResolveMany(channels []CommunicationChannel, matcher *Matcher, handler HandleResolver)
func (*Engine) ResolveManyAny ¶
func (engine *Engine) ResolveManyAny(channels []CommunicationChannel, handler HandleResolver)
func (*Engine) SetPerformanceMetric ¶
SetPerformanceMetric links a custom performance metric function
type Entity ¶
type Entity struct { Entity string `json:"entity"` Location []int64 `json:"location"` Value string `json:"value"` Confidence float64 `json:"confidence"` Metadata map[string]interface{} `json:"metadata"` }
Entity define any kind of object or entity
type HandleResolver ¶
type HandleResolver func(c *Context, in *Input, out *Output, response OutputResponse) error
type InInjection ¶
type Input ¶
type Input struct { Data InputData `json:"data"` Entities []Entity `json:"entities"` Intents []Intent `json:"intents"` }
Input represent an Input for the cognitive service
type InputRecord ¶
type InputType ¶
type InputType string
const InputAudio InputType = "audio"
const InputEmoji InputType = "emoji"
const InputImage InputType = "image"
const InputText InputType = "text"
type LogLevelType ¶
type LogLevelType string
LogLevelType is level of the logs
var Error LogLevelType = "error"
Error is a level of log
var Info LogLevelType = "info"
Info is a level of log
var Warn LogLevelType = "warn"
Warn is a level of log
type LogMessage ¶
type LogMessage struct { Level LogLevelType `json:"level"` Message string `json:"message"` }
LogMessage represents a snapshot of the messages around the dialog
type Matcher ¶
type Matcher struct { DialogNode DialogNodeMatch Entity Match Intent Match ContextVariable CMatch AND *Matcher OR *Matcher }
func IfContextVariableIs ¶
func IfDialogNodeIs ¶
func IfDialogNodeNameIs ¶
func IfDialogNodeTitleIs ¶
func IfEntityIs ¶
func (*Matcher) AndEntityIs ¶
func (*Matcher) AndIfContextVariableIs ¶
func (*Matcher) AndIfDialogNodeIs ¶
func (*Matcher) AndIfDialogNodeNameIs ¶
func (*Matcher) AndIfDialogNodeTitleIs ¶
func (*Matcher) AndIntentIs ¶
func (*Matcher) OrEntityIs ¶
func (*Matcher) OrIfContextVariableIs ¶
func (*Matcher) OrIfDialogNodeIs ¶
func (*Matcher) OrIfDialogNodeNameIs ¶
func (*Matcher) OrIfDialogNodeTitleIs ¶
type Message ¶
type Message struct { At time.Time `json:"at"` Owner MessageOwner `json:"owner"` Intents []Intent `json:"intents"` Entities []Entity `json:"entities"` Response MessageResponse `json:"response"` }
type MessageOwner ¶
type MessageOwner string
const ChatBot MessageOwner = "bot"
const Person MessageOwner = "person"
type MessageResponse ¶
type MessageResponse struct { Type ResponseType `json:"type"` Value interface{} `json:"value"` }
type MiddleHandler ¶
type MiddleHandler func(c *Context, message *Input, response OutputResponse) error
type OptionsResponse ¶
type Output ¶
type Output struct { Entities []Entity `json:"entities"` Intents []Intent `json:"intents"` VisitedNodes []*DialogNode `json:"visited_nodes"` Logs []*LogMessage `json:"logs"` Responses []Response `json:"responses"` }
Output represents the response of an input from the cognitive service
func (*Output) AddImageResponse ¶
func (*Output) AddListOfOptionsResponse ¶
func (out *Output) AddListOfOptionsResponse(options []OptionsResponse) *Output
func (*Output) AddOptionsResponse ¶
func (*Output) AddPauseResponse ¶
func (*Output) AddTextResponse ¶
func (*Output) ClearResponses ¶
type OutputRecord ¶
type OutputResponse ¶
type PersonInfo ¶
type PersonInfo struct { ID string `json:"id"` Timezone string `json:"timezone"` Picture string `json:"picture"` Locale string `json:"locale"` Name string `json:"name"` }
PersonInfo describes the basic info of the person
type Repository ¶
type Repository interface { SaveDialog(dialog *Dialog) error GetDialogByID(id string) (*Dialog, error) AllDialogs(frame TimeFrame) ([]*Dialog, error) // to page or not to page? DeleteDialog(id string) (*Dialog, error) // Dialogs are inmutable, cause it doesn't have an updater DialogsByView(viewID string, frame TimeFrame) ([]*Dialog, error) Summary(frame TimeFrame) (*Summary, error) RegisterIntent(intent string) error RegisterEntity(entity string) error RegisterDialogNode(name string) error RegisterContextVar(value string) error Intents() []string Entities() []string DialogNodes() []string ContextVars() []string SaveView(view *View) error GetViewByID(id string) (*View, error) FindViewByName(name string) ([]*View, error) AllViews() ([]*View, error) UpdateView(view *View) error DeleteView(id string) (*View, error) SetActionVar(name string, value string) error GetActionVar(name string) (string, error) }
type Response ¶
type Response struct { IsTyping bool `json:"is_typing"` Type ResponseType `json:"type"` Value interface{} `json:"value"` }
type ResponseType ¶
type ResponseType string
ResponseType define the types of generic response
const Image ResponseType = "image"
Image is a kind of generic response
const Options ResponseType = "option"
Options is a kind of generic response
const Pause ResponseType = "pause"
Pause is a kind of generic response
const Suggestion ResponseType = "suggestion"
const Text ResponseType = "text"
Text is a kind of generic response
const Unknown ResponseType = "unknown"
type TimeAnalysisResult ¶
type TimeFramePreset ¶
type TimeFramePreset string
const DayPreset TimeFramePreset = "day"
const MonthPreset TimeFramePreset = "month"
const WeekPreset TimeFramePreset = "week"
const YearPreset TimeFramePreset = "year"
type UsersSummary ¶
type ViewClass ¶
type ViewClass struct { Type ViewClassType `json:"type"` Value string `json:"value"` }
type ViewClassType ¶
type ViewClassType string
const ContextVarClass ViewClassType = "context_var"
const DialogNodeClass ViewClassType = "node"
const EntityClass ViewClassType = "entity"
const IntentClass ViewClassType = "intent"
Source Files ¶
- analytics.go
- anaytics_processor.go
- api.go
- api_actions.go
- api_chats.go
- api_collections.go
- api_dialogs.go
- api_downloads.go
- api_summary.go
- api_views.go
- auth.go
- bot.go
- channel.go
- cognitive.go
- context.go
- context_utils.go
- cortex.go
- cortex_configuration.go
- cortex_creator.go
- cortex_metrics.go
- cortex_onmessage.go
- defaults.go
- dialog.go
- entity.go
- errors.go
- filler.go
- garbage_collector.go
- injection.go
- input.go
- intent.go
- log.go
- matcher.go
- matcher_utils.go
- node.go
- options.go
- output.go
- output_adders.go
- output_utils.go
- pipeline.go
- repository.go
- resolvers.go