Documentation ¶
Index ¶
- type Category
- type ContextBuilder
- func (cb *ContextBuilder) AppendContext(context *ContextEntry)
- func (cb *ContextBuilder) AppendContexts(contexts *ContextEntries)
- func (cb *ContextBuilder) PrependContext(context *ContextEntry)
- func (cb *ContextBuilder) Realize(budget int) (string, ContextReport)
- func (cb *ContextBuilder) ResolvePlaceholder(context *ContextEntry)
- func (cb *ContextBuilder) ResolvePlaceholders()
- type ContextConfig
- type ContextEntries
- type ContextEntry
- type ContextReport
- type ContextReportEntry
- type Lorebook
- type LorebookEntry
- type LorebookSettings
- type MaxTrimType
- type Placeholder
- type Placeholders
- type Scenario
- func (scenario Scenario) GenerateContext(story string, budget int) (newContext string, ctxReport ContextReport)
- func (scenario *Scenario) GetEncoder() *gpt_bpe.GPTEncoder
- func (scenario *Scenario) GetPlaceholderDefs() (defs Placeholders)
- func (scenario *Scenario) SetAuthorsNote(an string)
- func (scenario *Scenario) SetMemory(memory string)
- type ScenarioAIModule
- type ScenarioSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct { Name *string `json:"name,omitempty" yaml:"name"` Id *string `json:"id,omitempty" yaml:"id"` Enabled *bool `json:"enabled,omitempty" yaml:"enabled"` CreateSubcontext *bool `json:"createSubcontext,omitempty" yaml:"createSubcontext"` SubcontextSettings *LorebookEntry `json:"subcontextSettings,omitempty" yaml:"subcontextSettings"` UseCategoryDefaults *bool `json:"useCategoryDefaults,omitempty" yaml:"useCategoryDefaults"` CategoryDefaults *LorebookEntry `json:"categoryDefaults,omitempty" yaml:"categoryDefaults"` CategoryBiasGroups *structs.BiasGroups `json:"categoryBiasGroups,omitempty" yaml:"categoryBiasGroups"` }
type ContextBuilder ¶
type ContextBuilder struct { Encoder *gpt_bpe.GPTEncoder Contexts ContextEntries Placeholders *Placeholders }
func NewContextBuilder ¶
func NewContextBuilder(encoder *gpt_bpe.GPTEncoder) *ContextBuilder
func (*ContextBuilder) AppendContext ¶
func (cb *ContextBuilder) AppendContext(context *ContextEntry)
func (*ContextBuilder) AppendContexts ¶
func (cb *ContextBuilder) AppendContexts(contexts *ContextEntries)
func (*ContextBuilder) PrependContext ¶
func (cb *ContextBuilder) PrependContext(context *ContextEntry)
func (*ContextBuilder) Realize ¶
func (cb *ContextBuilder) Realize(budget int) (string, ContextReport)
func (*ContextBuilder) ResolvePlaceholder ¶
func (cb *ContextBuilder) ResolvePlaceholder(context *ContextEntry)
func (*ContextBuilder) ResolvePlaceholders ¶
func (cb *ContextBuilder) ResolvePlaceholders()
type ContextConfig ¶
type ContextConfig struct { Prefix *string `json:"prefix,omitempty" yaml:"prefix"` Suffix *string `json:"suffix,omitempty" yaml:"suffix"` TokenBudget *int `json:"tokenBudget,omitempty" yaml:"tokenBudget"` ReservedTokens *int `json:"reservedTokens,omitempty" yaml:"reservedTokens"` BudgetPriority *int `json:"budgetPriority,omitempty" yaml:"budgetPriority"` TrimDirection *string `json:"trimDirection,omitempty" yaml:"trimDirection"` InsertionType *string `json:"insertionType,omitempty" yaml:"insertionType"` MaximumTrimType *string `json:"maximumTrimType,omitempty" yaml:"maximumTrimType"` InsertionPosition *int `json:"insertionPosition,omitempty" yaml:"insertionPosition"` AllowInnerInsertion *bool `json:"allowInnerInsertion,omitempty" yaml:"allowInnerInsertion"` AllowInsertionInside *bool `json:"allowInsertionInside,omitempty" yaml:"allowInsertionInside"` Force *bool `json:"forced,omitempty" yaml:"forced"` }
func CreateDefaultContextConfig ¶
func CreateDefaultContextConfig() ContextConfig
type ContextEntries ¶
type ContextEntries []ContextEntry
func (*ContextEntries) ApplyTokenizer ¶
func (contexts *ContextEntries) ApplyTokenizer(tokenizer *gpt_bpe.GPTEncoder)
func (ContextEntries) Len ¶
func (contexts ContextEntries) Len() int
func (ContextEntries) Less ¶
func (contexts ContextEntries) Less(i, j int) bool
func (ContextEntries) Swap ¶
func (contexts ContextEntries) Swap(i, j int)
type ContextEntry ¶
type ContextEntry struct { Text *string `json:"text,omitempty" yaml:"text"` ContextCfg *ContextConfig `json:"contextConfig,omitempty" yaml:"config"` Tokens *gpt_bpe.Tokens `json:"-" yaml:"-"` Label string `json:"-" yaml:"-"` MatchIndexes []map[string][][]int `json:"-" yaml:"-"` Index uint `json:"-" yaml:"-"` }
func (*ContextEntry) Clone ¶
func (context *ContextEntry) Clone() ContextEntry
func (*ContextEntry) ResolveTrim ¶
func (context *ContextEntry) ResolveTrim(encoder *gpt_bpe.GPTEncoder, budget int) ( trimmedTokens *gpt_bpe.Tokens)
type ContextReport ¶
type ContextReport []ContextReportEntry
type ContextReportEntry ¶
type ContextReportEntry struct { Label string `json:"label"` InsertionPos int `json:"insertion_pos"` TokenCount int `json:"token_count"` TokensInserted int `json:"tokens_inserted"` BudgetRemaining int `json:"budget_remaining"` ReservedRemaining int `json:"reserved_remaining"` MatchIndexes []map[string][][]int `json:"matches"` Forced bool `json:"forced"` }
type Lorebook ¶
type Lorebook struct { Version int `json:"lorebookVersion"` Entries []LorebookEntry `json:"entries"` Settings LorebookSettings `json:"settings"` Categories []Category `json:"categories"` }
func (*Lorebook) ResolveContexts ¶
func (lorebook *Lorebook) ResolveContexts(placeholders *Placeholders, contexts *ContextEntries) (entries ContextEntries)
func (*Lorebook) ToPlaintext ¶
func (*Lorebook) ToPlaintextFile ¶
type LorebookEntry ¶
type LorebookEntry struct { Text *string `json:"text,omitempty" yaml:"text"` ContextCfg *ContextConfig `json:"contextConfig,omitempty" yaml:"contextConfig"` LastUpdatedAt *int `json:"lastUpdatedAt,omitempty" yaml:"lastUpdatedAt"` DisplayName *string `json:"displayName,omitempty" yaml:"displayName"` Keys *[]string `json:"keys,omitempty" yaml:"keys"` SearchRange *int `json:"searchRange,omitempty" yaml:"searchRange"` Enabled *bool `json:"enabled,omitempty" yaml:"enabled"` ForceActivation *bool `json:"forceActivation,omitempty" yaml:"forceActivation"` KeyRelative *bool `json:"keyRelative,omitempty" yaml:"keyRelative"` NonStoryActivatable *bool `json:"nonStoryActivatable,omitempty" yaml:"nonStoryActivatable"` CategoryId *string `json:"category,omitempty" yaml:"categoryId"` LoreBiasGroups *structs.BiasGroups `json:"loreBiasGroups,omitempty" yaml:"loreBiasGroups"` KeysRegex []*regexp.Regexp `json:"-" yaml:"-"` }
func (*LorebookEntry) RealizeDefaults ¶
func (defaults *LorebookEntry) RealizeDefaults(entry *LorebookEntry)
type LorebookSettings ¶
type LorebookSettings struct {
OrderByKeyLocations bool `json:"orderByKeyLocations" yaml:"orderByKeyLocations"`
}
type MaxTrimType ¶
type MaxTrimType uint
const ( TrimSentences MaxTrimType = iota TrimNewlines MaxTrimType = iota TrimTokens MaxTrimType = iota )
type Placeholder ¶
type Placeholders ¶
type Placeholders map[string]*Placeholder
func DiscoverPlaceholderDefs ¶
func DiscoverPlaceholderDefs(text string) Placeholders
func DiscoverPlaceholderTable ¶
func DiscoverPlaceholderTable(text string) Placeholders
func (Placeholders) Add ¶
func (accPlaceholders Placeholders) Add(new Placeholders)
func (Placeholders) Realize ¶
func (accPlaceholders Placeholders) Realize()
func (Placeholders) ReplacePlaceholders ¶
func (variables Placeholders) ReplacePlaceholders(text string) (replaced string)
func (*Placeholders) UpdateValues ¶
func (target *Placeholders) UpdateValues(kvs map[string]string)
type Scenario ¶
type Scenario struct { ScenarioVersion int `json:"scenarioVersion"` Title string `json:"title"` Author string `json:"author"` Description string `json:"description"` Prompt string `json:"prompt"` Tags []string `json:"tags,omitempty"` Context ContextEntries `json:"context,omitempty"` Settings ScenarioSettings `json:"settings,omitempty"` Lorebook Lorebook `json:"lorebook,omitempty"` Placeholders []Placeholder `json:"placeholders,omitempty"` StoryContextConfig *ContextConfig `json:"storyContextConfig,omitempty"` Biases *structs.BiasGroups `json:"-" yaml:"biases"` AIModule *aimodules.AIModule `json:"-"` PlaceholderMap Placeholders `json:"-"` Encoder *gpt_bpe.GPTEncoder `json:"-"` }
func ScenarioFromFile ¶
func ScenarioFromSpec ¶
func (Scenario) GenerateContext ¶
func (scenario Scenario) GenerateContext(story string, budget int) ( newContext string, ctxReport ContextReport)
func (*Scenario) GetEncoder ¶
func (scenario *Scenario) GetEncoder() *gpt_bpe.GPTEncoder
func (*Scenario) GetPlaceholderDefs ¶
func (scenario *Scenario) GetPlaceholderDefs() (defs Placeholders)
func (*Scenario) SetAuthorsNote ¶
type ScenarioAIModule ¶
type ScenarioSettings ¶
type ScenarioSettings struct { Parameters *novelai_api.NaiGenerateParams `json:"parameters,omitempty"` TrimResponses *bool `json:"trimResponses,omitempty"` BanBrackets *bool `json:"banBrackets,omitempty"` Prefix *string `json:"prefix,omitempty"` ScenarioAIModule *ScenarioAIModule `json:"-,omitempty"` Model *string `json:"model,omitempty"` }
Click to show internal directories.
Click to hide internal directories.