store

package
v0.0.0-...-59e9b9b Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBName                   = "gpterm.db"
	ConfigChatMessageContext = "chat.message-context"
	CredentialAPIKey         = "api_key"
	CredentialGithubToken    = "github_token"
)

Variables

View Source
var ErrNoMoreConversations = errors.New("no more conversations")

Functions

func DefaultDBPath

func DefaultDBPath() (string, error)

func DefaultStorePath

func DefaultStorePath() (string, error)

Types

type Config

type Config []query.Config

func (Config) Int

func (c Config) Int(key string) (int, error)

type Store

type Store struct {
	log.Logger
	// contains filtered or unexported fields
}

func New

func New(opts ...StoreOpt) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CycleClientConfig

func (s *Store) CycleClientConfig(ctx context.Context) error

func (*Store) DBPath

func (s *Store) DBPath() string

func (*Store) DropConversation

func (s *Store) DropConversation(ctx context.Context) error

func (*Store) GetClientConfig

func (s *Store) GetClientConfig(ctx context.Context) (query.ClientConfig, error)

func (*Store) GetConfig

func (s *Store) GetConfig(ctx context.Context) (Config, error)

func (*Store) GetConfigInt

func (s *Store) GetConfigInt(ctx context.Context, name string, defaultValue int) (int, error)

func (*Store) GetCredential

func (s *Store) GetCredential(ctx context.Context, name string) (string, error)

func (*Store) GetLastMessages

func (s *Store) GetLastMessages(ctx context.Context, count int) ([]query.Message, error)

func (*Store) GetPreviousMessageForRole

func (s *Store) GetPreviousMessageForRole(ctx context.Context, role string, offset int) (query.Message, error)

func (*Store) GetTotalUsage

func (s *Store) GetTotalUsage(ctx context.Context) (res query.Usage, err error)

func (*Store) NextConversation

func (s *Store) NextConversation(ctx context.Context) error

func (*Store) PreviousConversation

func (s *Store) PreviousConversation(ctx context.Context) error

func (*Store) SaveRequest

func (s *Store) SaveRequest(ctx context.Context, req openai.ChatCompletionRequest) error

func (*Store) SaveRequestResponse

func (s *Store) SaveRequestResponse(ctx context.Context, req openai.ChatCompletionRequest, resp openai.ChatCompletionResponse) error

func (*Store) SaveStreamResults

func (s *Store) SaveStreamResults(ctx context.Context, text string, usage openai.Usage, failure error) error

func (*Store) SetConfigInt

func (s *Store) SetConfigInt(ctx context.Context, name string, value int) error

func (*Store) SetCredential

func (s *Store) SetCredential(ctx context.Context, name string, value string) error

func (*Store) UpdateClientConfig

func (s *Store) UpdateClientConfig(ctx context.Context, messageContext int64) error

type StoreOpt

type StoreOpt func(*Store)

func StoreDir

func StoreDir(path string) StoreOpt

func StoreLog

func StoreLog(log log.Logger) StoreOpt

Jump to

Keyboard shortcuts

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