repositories

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ActiveConversationFileName = "active.json"

Variables

View Source
var ErrConversationNotFound = errors.New("conversation not found")
View Source
var ErrNoActiveConversation = errors.New("no active conversation")
View Source
var ErrNoProfilesDir = fmt.Errorf("no profiles found. Please add profiles to the profiles folder.")

Functions

func CreateConfigDir

func CreateConfigDir() (string, error)

Uses two strategies to define the config directory: 1. If the system has a user config directory, it uses it and creates a gennie directory inside it 2. If the system does not have a user config directory, it uses the executable directory

func DefaultProfileDir

func DefaultProfileDir() string

Uses the os.UserConfigDir to setup the default profiles directory

Types

type ConfigRepository

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

func NewConfigRepository

func NewConfigRepository(configDir string) *ConfigRepository

func (*ConfigRepository) ConfigFile

func (cr *ConfigRepository) ConfigFile() string

Returns the full path to the config file

func (*ConfigRepository) Load

func (cr *ConfigRepository) Load() (*config.Config, error)

Loads the config from a gob file into the Config struct If the file does not exist, it returns a new Config with default values Once loaded config is cached until the cli quits

func (*ConfigRepository) Save

func (cr *ConfigRepository) Save(config *config.Config) error

Saves the config to a json file Caches the config in repository cache

type ConversationRepository

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

func NewConversationRepository

func NewConversationRepository(cacheDir string) *ConversationRepository

func (*ConversationRepository) ExportToFile

func (r *ConversationRepository) ExportToFile(conversation *conversation.Conversation, filepath string) error

func (*ConversationRepository) LoadActive

Loads the last conversation that has been active If there is no active conversation, creates a new one with the default profile and model

func (*ConversationRepository) LoadFromFile

func (r *ConversationRepository) LoadFromFile(filepath string) (*conversation.Conversation, error)

func (*ConversationRepository) SaveAsActive

func (r *ConversationRepository) SaveAsActive(conversation *conversation.Conversation) error

type ProfileRepository

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

func NewProfileRepository

func NewProfileRepository(profilesDir string) *ProfileRepository

func (*ProfileRepository) FindBySlug

func (pr *ProfileRepository) FindBySlug(slug string) (*profile.Profile, error)

Loads a profile from a toml file named as the slug. Ie: "test.profile.toml" for slug "test"

func (*ProfileRepository) ListAll

func (pr *ProfileRepository) ListAll() (map[string]*profile.Profile, error)

Lists all profiles found in the profiles directory, plus a default profile created in the application If dir does not exist, returns the default profile only and the error ErrNoProfilesDir

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳