assistant

package
v4.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{

	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_PLUGIN",
	MagicCookieValue: "hello",
}

Handshake is a common handshake that is shared by plugin and host.

Functions

func PersistInteractionTrace

func PersistInteractionTrace(receiveTs time.Time, askedTs time.Time, message *Message, nlpTokens *[]string, fact *engine.Fact, result *reader.Item, pipelineErr error) error

PersistInteractionTrace store a trace of the assistant interaction in postgresql

Types

type Assistant

type Assistant interface {
	SentenceProcess(string, string, [][]string) ([]byte, []string, error)
}

Assistant is the interface that we're exposing as a plugin.

type AssistantGRPCPlugin

type AssistantGRPCPlugin struct {
	// GRPCPlugin must still implement the Plugin interface
	plugin.Plugin
	// Concrete implementation, written in Go. This is only used for plugins that are written in Go.
	Impl Assistant
}

func (*AssistantGRPCPlugin) GRPCClient

func (p *AssistantGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*AssistantGRPCPlugin) GRPCServer

func (p *AssistantGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type AssistantPlugin

type AssistantPlugin struct {
	Name         string
	ClientConfig *plugin.ClientConfig
	Client       *plugin.Client
	Assistant    Assistant
}

func NewAssistantPlugin

func NewAssistantPlugin() *AssistantPlugin

func (*AssistantPlugin) Handler

func (m *AssistantPlugin) Handler() http.Handler

func (*AssistantPlugin) HandlerPrefix

func (m *AssistantPlugin) HandlerPrefix() string

func (*AssistantPlugin) SendMessage

func (m *AssistantPlugin) SendMessage(w http.ResponseWriter, r *http.Request)

SendMessage godoc @Summary Sends a message to the myrtea Assistant. @Description Sends a message to the myrtea Assistant. @Tags Assistant @Accept json @Produce json @Param time query string true "Timestamp" @Param sentence body interface{} true "User sentence and context Tokens" @Param debug query string false "Enable log debugging" @Security Bearer @Success 200 "Status OK" @Failure 400 "Status Bad Request" @Failure 500 "Status Internal Server Error" @Router /assistant/message [post]

func (*AssistantPlugin) Start

func (m *AssistantPlugin) Start() error

func (*AssistantPlugin) Stop

func (m *AssistantPlugin) Stop() error

func (*AssistantPlugin) Test

func (m *AssistantPlugin) Test()

type AssistantResponse

type AssistantResponse struct {
	Result *reader.WidgetData `json:"result"`
	Tokens []string           `json:"tokens"`
}

AssistantResponse reflcts the response format of the assistant

type GRPCClient

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

GRPCClient is an implementation of Assistant that talks over RPC.

func (*GRPCClient) SentenceProcess

func (m *GRPCClient) SentenceProcess(ti string, message string, tokens [][]string) ([]byte, []string, error)

type GRPCServer

type GRPCServer struct {
	// This is the real implementation
	Impl Assistant
}

func (*GRPCServer) SentenceProcess

type Message

type Message struct {
	Sentence      string     `json:"sentence"`
	ContextTokens [][]string `json:"contextTokens"`
}

Message represents an input raw message with its contexts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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