storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupPostgresStorage

func SetupPostgresStorage(dns string) error

Types

type JSONStorage

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

func (*JSONStorage) AddNewJourney added in v0.1.6

func (s *JSONStorage) AddNewJourney(ctx context.Context, journey *Journey) error

func (*JSONStorage) DeleteSession

func (s *JSONStorage) DeleteSession(ctx context.Context, id string) error

func (*JSONStorage) FetchSession

func (s *JSONStorage) FetchSession(ctx context.Context, id string) (*Session, error)

func (*JSONStorage) SaveSession

func (s *JSONStorage) SaveSession(ctx context.Context, session *Session) error

func (*JSONStorage) UpdateSession

func (s *JSONStorage) UpdateSession(ctx context.Context, session *Session) error

type Journey added in v0.1.6

type Journey struct {
	SessionID string
	StepNo    int
	Kind      string
	Duration  time.Duration
	Messages  []llm.Message
	Metadata  any
}

type NoneStorage

type NoneStorage struct {
}

func (*NoneStorage) DeleteSession

func (s *NoneStorage) DeleteSession(ctx context.Context, id string) error

func (*NoneStorage) FetchSession

func (s *NoneStorage) FetchSession(ctx context.Context, id string) (*Session, error)

func (*NoneStorage) SaveSession

func (s *NoneStorage) SaveSession(ctx context.Context, session *Session) error

func (*NoneStorage) UpdateSession

func (s *NoneStorage) UpdateSession(ctx context.Context, session *Session) error

type PostgresStorage

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

func (*PostgresStorage) AddNewJourney added in v0.1.6

func (s *PostgresStorage) AddNewJourney(ctx context.Context, journey *Journey) error

func (*PostgresStorage) DeleteSession

func (s *PostgresStorage) DeleteSession(ctx context.Context, id string) error

func (*PostgresStorage) FetchSession

func (s *PostgresStorage) FetchSession(ctx context.Context, id string) (*Session, error)

func (*PostgresStorage) SaveSession

func (s *PostgresStorage) SaveSession(ctx context.Context, session *Session) error

func (*PostgresStorage) UpdateSession

func (s *PostgresStorage) UpdateSession(ctx context.Context, session *Session) error

type Session

type Session struct {
	UID        string         `json:"uid" gorm:"column:uid;type:varchar(255);"`                 // session id
	EngineID   string         `json:"engine_id" gorm:"column:engine_id;type:varchar(255);"`     // engine id
	EngineType string         `json:"engine_type" gorm:"column:engine_type;type:varchar(255);"` // engine type
	EngineData map[string]any `json:"engine_data" gorm:"column:engine_data;type:jsonb"`         // engine data

	Memory memory.Memory `json:"memory"` // 记忆

	Messages []llm.Message `json:"messages"`

	Data any `json:"data"`

	CreatedAt time.Time `json:"created_at" gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;autoUpdateTime"`
}

for domain usage

func NewSession

func NewSession(id string) *Session

type Storage

type Storage interface {
	AddNewJourney(ctx context.Context, journey *Journey) error
	SaveSession(ctx context.Context, session *Session) error
	FetchSession(ctx context.Context, id string) (*Session, error)
	UpdateSession(ctx context.Context, session *Session) error
	DeleteSession(ctx context.Context, id string) error
}

func NewJSONStorage

func NewJSONStorage(path string) Storage

func NewPostgresStorage

func NewPostgresStorage(db *sql.DB) Storage

func NewPostgresStorageWithDNS

func NewPostgresStorageWithDNS(dns string) Storage

func NewPostgresStorageWithGormDB

func NewPostgresStorageWithGormDB(gormDB *gorm.DB) Storage

Jump to

Keyboard shortcuts

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