Documentation
¶
Overview ¶
Package storage centralizes data-directory handling, series metadata persistence, and other filesystem-backed concerns (cache, output, metrics) for the DALL·E server. By isolating these responsibilities, higher‑level packages avoid duplicating path logic or environment bootstrap code.
Index ¶
- func AudioURL(baseURL, series, address string) (string, error)
- func Clean(series, address string)
- func ConfigureManager(opts ManagerOptions)
- func ContextCount() int
- func DeleteSeries(seriesDir, suffix string) error
- func GenerateAnnotatedImage(series, address string, skipImage bool, lockTTL time.Duration) (string, error)
- func GenerateAnnotatedImageWithBaseURL(series, address string, skipImage bool, lockTTL time.Duration, baseURL string) (string, error)
- func GenerateSpeech(series, address string, lockTTL time.Duration) (string, error)
- func GetAllItems() (map[string][]model.Item, error)
- func GetItemsForDatabase(dbName string) ([]model.Item, error)
- func IsValidSeries(series string, list []string) bool
- func ListSeries() []string
- func ReadToMe(series, address string) (string, error)
- func RemoveSeries(seriesDir, suffix string) error
- func ResetContextManagerForTest()
- func SetupTest(t testing.TB, opts SetupTestOptions)
- func SortDalleDress(items []model.DalleDress, sortSpec sdk.SortSpec) error
- func SortDatabases(items []model.Database, sortSpec sdk.SortSpec) error
- func SortSeries(items []Series, sortSpec sdk.SortSpec) error
- func Speak(series, address string) (string, error)
- func TextToSpeech(text string, voice string, series string, address string) (string, error)
- func UndeleteSeries(seriesDir, suffix string) error
- type Context
- func (ctx *Context) GenerateEnhanced(addr string) (string, error)
- func (ctx *Context) GenerateImage(address string) (string, error)
- func (ctx *Context) GenerateImageWithBaseURL(address, baseURL string) (string, error)
- func (ctx *Context) GetEnhanced(addr string) string
- func (ctx *Context) GetPrompt(addr string) string
- func (ctx *Context) MakeDalleDress(addressIn string) (*model.DalleDress, error)
- func (ctx *Context) ReloadDatabases(filter string) error
- func (ctx *Context) Save(addr string) bool
- type ManagerOptions
- type Series
- type SetupTestOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AudioURL ¶
AudioURL resolves a relative URL (served by internal file server) for an existing or newly generated mp3. Returns empty string if generation not possible or file server base URL unknown.
func Clean ¶
func Clean(series, address string)
Clean removes generated images and data for a given series and address.
func ConfigureManager ¶
func ConfigureManager(opts ManagerOptions)
ConfigureManager allows callers to override default manager options.
func ContextCount ¶
func ContextCount() int
ContextCount (testing) returns number of cached contexts.
func DeleteSeries ¶
func GenerateAnnotatedImage ¶
func GenerateAnnotatedImage(series, address string, skipImage bool, lockTTL time.Duration) (string, error)
GenerateAnnotatedImage builds (and optionally generates) an annotated image path. The image generation step is skipped if skipImage is true.
func GenerateAnnotatedImageWithBaseURL ¶
func GenerateAnnotatedImageWithBaseURL(series, address string, skipImage bool, lockTTL time.Duration, baseURL string) (string, error)
GenerateAnnotatedImageWithBaseURL builds (and optionally generates) an annotated image path with a specific base URL.
func GenerateSpeech ¶
GenerateSpeech ensures a text-to-speech mp3 exists for the enhanced prompt of the given address. It returns the path to the mp3. If already generated it returns existing path.
func GetAllItems ¶ added in v6.6.6
GetAllItems loads all database items from the cache manager into a map keyed by database name. Items are lazily loaded from embedded CSV files on first call, then cached in memory. Returns a map where keys are database names (e.g., "nouns") and values are slices of Items.
func GetItemsForDatabase ¶ added in v6.6.6
GetItemsForDatabase returns all items for a specific database. Returns an empty slice (not an error) if the database is not found.
func IsValidSeries ¶
IsValidSeries determines whether a requested series is valid given an optional list.
func ListSeries ¶
func ListSeries() []string
ListSeries returns the list of existing series (json files) beneath output Dir/series.
func ReadToMe ¶
ReadToMe ensures the mp3 exists (generating if necessary) and always attempts playback. It returns the path if the file exists or was generated, else empty string.
func RemoveSeries ¶
func ResetContextManagerForTest ¶
func ResetContextManagerForTest()
ResetContextManagerForTest clears context cache (test helper).
func SetupTest ¶
func SetupTest(t testing.TB, opts SetupTestOptions)
func SortDalleDress ¶
func SortDalleDress(items []model.DalleDress, sortSpec sdk.SortSpec) error
SortDalleDress sorts in place based on field in spec
func SortDatabases ¶
SortDatabases sorts in place based on field in spec
func SortSeries ¶
SortSeries sorts in place based on field in spec (suffix, modifiedAt, last)
func Speak ¶
Speak plays (or generates then plays) the speech mp3 for the given series/address. Returns the path to the mp3 (even if play fails). Generation is skipped if file exists.
func TextToSpeech ¶
TextToSpeech converts the given text to speech using OpenAI's audio API and writes it to the provided output directory. It returns the full path of the written mp3 file. If the OPENAI_API_KEY is missing, it returns an empty string and no error.
func UndeleteSeries ¶
Types ¶
type Context ¶
type Context struct {
Series Series
Databases map[string][]string
DalleCache map[string]*model.DalleDress
CacheMutex sync.Mutex
// contains filtered or unexported fields
}
Context holds templates, series, dbs, and cache for prompt generation.
func NewContext ¶
func NewContext() *Context
func (*Context) GenerateEnhanced ¶
GenerateEnhanced generates a literarily-enhanced prompt for the given address (Stage 1).
func (*Context) GenerateImage ¶
GenerateImage generates an image using the DALL-E API.
func (*Context) GenerateImageWithBaseURL ¶
GenerateImageWithBaseURL generates an image using the DALL-E API with a specific base URL.
func (*Context) GetEnhanced ¶
GetEnhanced returns the enhanced prompt for the given address.
func (*Context) MakeDalleDress ¶
func (ctx *Context) MakeDalleDress(addressIn string) (*model.DalleDress, error)
MakeDalleDress builds or retrieves a DalleDress for the given address using the context's templates, series, dbs, and cache.
func (*Context) ReloadDatabases ¶
ReloadDatabases reloads databases applying filters from the specified series suffix. Now uses binary cache for improved performance while maintaining immutability.
type ManagerOptions ¶
ManagerOptions controls cache sizing and expiration.
type Series ¶
type Series struct {
Last int `json:"last,omitempty"`
Suffix string `json:"suffix"`
Purpose string `json:"purpose,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Adverbs []string `json:"adverbs"`
Adjectives []string `json:"adjectives"`
Nouns []string `json:"nouns"`
Emotions []string `json:"emotions"`
Occupations []string `json:"occupations"`
Actions []string `json:"actions"`
Artstyles []string `json:"artstyles"`
Litstyles []string `json:"litstyles"`
Colors []string `json:"colors"`
Viewpoints []string `json:"viewpoints"`
Gazes []string `json:"gazes"`
Backstyles []string `json:"backstyles"`
Compositions []string `json:"compositions"`
ModifiedAt string `json:"modifiedAt,omitempty"`
}
Series represents a collection of prompt attributes and their values.
func LoadActiveSeriesModels ¶
LoadActiveSeriesModels loads all non-deleted series JSON files
func LoadDeletedSeriesModels ¶
LoadDeletedSeriesModels loads all deleted series JSON files
func LoadSeriesModels ¶
LoadSeriesModels loads all series JSON files from the series folder beneath the provided dataDir
func (*Series) SaveSeries ¶
SaveSeries saves the Series to a file with the given filename and last index.
type SetupTestOptions ¶
type SetupTestOptions struct {
Series []string
ManagerConfig *ManagerOptions
}
Public test helper: creates isolated data dir with series and output, sets skip image. Intended for consumers writing tests against the dalle package.