Documentation
¶
Overview ¶
Package snowman provides basic building blocks required to build a chat bot.
A bot consists of a `UI` to interact with users and a `Responder` to generate actions/response to the user based on the intent detected.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
UI UI
Self User
Logger Logger
Handler Handler
// contains filtered or unexported fields
}
Bot represents an instance of the bot. A bot runs continuously blocking the host goroutine and generates messages or actions in response to scheduled intents or user messages.
type ConsoleUI ¶
type ConsoleUI struct {
Prompt string
// contains filtered or unexported fields
}
ConsoleUI implements a console based UI. Stdin is used for reading input from the user and Stdout is used for output.
type Dialogue ¶ added in v0.2.0
Dialogue holds the conversational context of bot with a specific user.
type Handler ¶ added in v0.3.0
Handler represents the message Handler that can process the message to generate response or to append additional context to the message.
type Intent ¶
type Intent struct {
Tag string `json:"tag" yaml:"tag"`
Context map[string]interface{} `json:"context" yaml:"context"`
Response string `json:"response" yaml:"response"`
Confidence float64 `json:"confidence" yaml:"confidence"`
}
Intent represents the intent of a message along with context extracted from the message.
type Logger ¶
type Logger interface {
Debugf(msg string, args ...interface{})
Infof(msg string, args ...interface{})
Warnf(msg string, args ...interface{})
Errorf(msg string, args ...interface{})
}
Logger is responsible for providing logging facilities to bot instance.
type Msg ¶
type Msg struct {
At time.Time `json:"at"`
To User `json:"to"`
From User `json:"from"`
Body string `json:"body"`
Intents []Intent `json:"intents"`
// contains filtered or unexported fields
}
Msg represents a message from the user/bot. Msg can contain additional context in terms of intents that may be used by handler to generate response.
type NoOpLogger ¶
type NoOpLogger struct{}
NoOpLogger implements a Logger that simply ignores all the log entries.
func (NoOpLogger) Debugf ¶
func (n NoOpLogger) Debugf(string, ...interface{})
func (NoOpLogger) Errorf ¶
func (n NoOpLogger) Errorf(string, ...interface{})
func (NoOpLogger) Infof ¶
func (n NoOpLogger) Infof(string, ...interface{})
func (NoOpLogger) Warnf ¶
func (n NoOpLogger) Warnf(string, ...interface{})
type SlackUI ¶ added in v0.3.0
type SlackUI struct {
Logger
Token string
Options []slack.Option
EnableChannel bool
ThreadDirect bool
// contains filtered or unexported fields
}
SlackUI implements snowman SlackUI using Slack RTM based API.
type StdLogger ¶
type StdLogger struct{}
StdLogger implements the Logger using standard library log package.
type UI ¶
type UI interface {
// Say should display the message to the user as if the bot said it.
// Target user that should receive the message should be identified
// using the 'msg.To' value.
Say(ctx context.Context, msg Msg) error
// Listen should listen for messages from user and deliver them to the
// Handler. Listen should block until UI reaches a terminal state or
// until context is cancelled.
Listen(ctx context.Context, receive func(msg Msg)) error
}
UI represents the interface used for interactions between the bot and the user.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
snowman
command
|
|
|
pkg
|
|
|
ffnet
Package ffnet provides a generic Fully-Connected Feedforward neural network, and a Stochastic Gradient Descent based trainer.
|
Package ffnet provides a generic Fully-Connected Feedforward neural network, and a Stochastic Gradient Descent based trainer. |
|
ffnet/examples
command
|
|