types

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Actions = map[uid.ID]Action{}
View Source
var Conversations = map[uid.ID]*Conversation{}
View Source
var OldScenarios map[string]OldScenario
View Source
var Scenarios map[string]Scenario

Functions

func RunConv

func RunConv(actionID uid.ID, conv *Conversation, trigger string) error

Types

type Action

type Action struct {
	Source string
	Meta   ActionMeta
}

func (Action) Run

func (a Action) Run(vals map[string]interface{}) error

type ActionMeta

type ActionMeta struct {
	Name string
	ID   uid.ID
}

type Character

type Character struct {
	Name        string        `json:"name"`
	Type        CharacterType `json:"type"`
	NameVisible bool          `json:"add_name_to_gpt"`
}

func NewChar

func NewChar(name string, t CharacterType) Character

func (Character) String

func (c Character) String() string

type CharacterType

type CharacterType string
const (
	CharacterTypeNarration CharacterType = "NARRATION"
	CharacterTypeInitial   CharacterType = "INITIAL"
	CharacterTypeGpt3      CharacterType = "GPT3"
	CharacterTypeUser      CharacterType = "USER"
)

type Characters

type Characters map[uid.ID]Character

func NewChars

func NewChars(n, i, g, u string) Characters

func (Characters) String

func (c Characters) String() string

type ConvMeta

type ConvMeta struct {
	Started time.Time     `json:"started"`
	ID      uid.ID        `json:"id"`
	Active  bool          `json:"active"`
	Engine  string        `json:"engine"`
	Timeout time.Duration `json:"timeout"`
	User    uid.ID        `json:"user"`
}

func NewConvMeta

func NewConvMeta(engine string, timeout time.Duration, user uid.ID) ConvMeta

func (ConvMeta) String

func (c ConvMeta) String() string

type Conversation

type Conversation struct {
	Meta     ConvMeta          `json:"meta"`
	Msgs     *Msgs             `json:"messages"`
	Scenario Scenario          `json:"-"`
	Actions  map[uid.ID]Action `json:"actions"`
	Chars    Characters        `json:"message_types"`
	State    string            `json:"state"`
	// contains filtered or unexported fields
}

func (*Conversation) ContentFilter

func (c *Conversation) ContentFilter(text string) (int, error)

func (*Conversation) Refresh

func (c *Conversation) Refresh() error

func (*Conversation) String

func (c *Conversation) String() string

type ConversationContainer

type ConversationContainer struct {
	Conversation
	Access []string
	Lock   sync.RWMutex
	Err    error
}

func NewConvCont

func NewConvCont(c Conversation) *ConversationContainer

type Engine

type Engine struct {
	E     *gin.Engine
	Conts map[uid.ID]*ConversationContainer
	Lock  sync.RWMutex
	Addr  []string
}

type GPT3

type GPT3 struct {
	SummarizeToken   int     `json:"-" toml:"summarize_token"`
	ResponseLength   int     `json:"-" toml:"response_length"`
	Temperature      float32 `json:"-" toml:"temperature"`
	TopP             float32 `json:"-" toml:"top_p"`
	FrequencyPenalty float32 `json:"-" toml:"frequency_penalty"`
	PresencePenalty  float32 `json:"-" toml:"presence_penalty"`
	MaxTokens        int     `json:"-" toml:"max_tokens"`
	Engine           string  `json:"-" toml:"engine"`
	N                int     `json:"-" toml:"n"`
	LogProbs         float32 `json:"-" toml:"log_probs"`
	APIKey           string  `json:"-"` // make sure to not send secrets
}

func (GPT3) NewClient

func (g GPT3) NewClient() gpt3.Client

func (GPT3) String

func (g GPT3) String() string

type Info

type Info map[string]string

type Msg

type Msg struct {
	ID         uid.ID   `json:"id"`
	From       uid.ID   `json:"from"`
	Content    string   `json:"content"`
	VisibleTo  []uid.ID `json:"visible_to"`  // nil VisibleTo means all allowed
	EditableTo []uid.ID `json:"editable_to"` // nil EditableTo means all allowed
}

func (Msg) String

func (m Msg) String() string

type Msgs

type Msgs []Msg

func (*Msgs) Append

func (m *Msgs) Append(m2 Msg)

func (*Msgs) ApproxTokens

func (m *Msgs) ApproxTokens() uint

func (*Msgs) Render

func (m *Msgs) Render() string

func (*Msgs) String

func (m *Msgs) String() string

type OldCharacter

type OldCharacter struct {
	ID          uid.ID `json:"-"`
	Name        string `json:"name"`
	Type        int    `json:"type"`
	NameVisible bool   `json:"add_name_to_gpt"`
}

type OldCharacters

type OldCharacters []OldCharacter

func (OldCharacters) ToCharacters

func (o OldCharacters) ToCharacters() Characters

type OldMsg

type OldMsg struct {
	ID       uid.ID `json:"-"`
	Content  string `json:"content"`
	Editable bool   `json:"editable"`
	Include  bool   `json:"include"`
	Visible  bool   `json:"visible"`
	From     int    `json:"from"`
}

type OldMsgs

type OldMsgs []OldMsg

func (OldMsgs) ToMsgs

func (o OldMsgs) ToMsgs(chars OldCharacters) Msgs

type OldScenario

type OldScenario struct {
	Meta  ScenarioMeta  `json:"meta"`
	Info  Info          `json:"info"`
	Msgs  OldMsgs       `json:"initial_messages"`
	Chars OldCharacters `json:"message_types"` // only support one char per type
	GPT3  GPT3          `json:"gpt_3"`
}

func (OldScenario) ToScenario

func (o OldScenario) ToScenario() Scenario

type Resp

type Resp struct {
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func (Resp) Map

func (r Resp) Map() map[string]interface{}

func (Resp) MarshalJSON

func (r Resp) MarshalJSON() ([]byte, error)

type Scenario

type Scenario struct {
	Meta  ScenarioMeta `json:"meta"`
	Info  Info         `json:"info"`
	Msgs  *Msgs        `json:"initial_messages"`
	Chars Characters   `json:"message_types"` // only support one char per type
	GPT3  GPT3         `json:"gpt_3"`
}

func (Scenario) String

func (s Scenario) String() string

type ScenarioMeta

type ScenarioMeta struct {
	Title       string        `toml:"title" json:"title"`
	Description string        `toml:"desc" json:"desc"`
	Duration    time.Duration `toml:"duration" json:"duration"`
	Level       int           `toml:"level" json:"level"`
}

func (ScenarioMeta) String

func (s ScenarioMeta) String() string

type ScenarioSummary

type ScenarioSummary struct {
	Meta *ScenarioMeta `json:"meta"`
}

func (ScenarioSummary) String

func (s ScenarioSummary) String() string

type User

type User struct {
	Username uid.ID              `json:"username"`
	Allow    map[uid.ID]struct{} `json:"allow"` // if both Allow and Block contain elements, then Allow is prioritized
	Block    map[uid.ID]struct{} `json:"block"`
}

func FromJSON

func FromJSON(src []byte) (u User)

func (User) Check

func (u User) Check(id uid.ID) bool

func (User) ToJSON

func (u User) ToJSON() (src []byte)

Jump to

Keyboard shortcuts

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