stores

package
v0.0.0-...-5a88d1b Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Separator  = "\n* "
	AnswerStop = " END"
)

Variables

View Source
var (
	ErrNoRows   = pgx.ErrNoRows
	ErrNotFound = pgx.ErrNotFound
	ErrEmptyKey = pgx.ErrEmptyKey

	ContextWithColumns  = pgx.ContextWithColumns
	ColumnsFromContext  = pgx.ColumnsFromContext
	ContextWithRelation = pgx.ContextWithRelation
	RelationFromContext = pgx.RelationFromContext

	RegisterModel = pgx.RegisterModel
)

vars nolint

View Source
var (
	ErrEmptyParam = errors.New("empty param")
)

Functions

func GetEmbedding

func GetEmbedding(ctx context.Context, text string) (vec qas.Vector, err error)

func InitDB

func InitDB() error

func LoadPreset

func LoadPreset() (doc aigc.Preset, err error)

func NewOpenAIClient

func NewOpenAIClient() *openai.Client

func SgtDB

func SgtDB(args ...string) *pgx.DB

SgtDB start and return a singleton instance of DB **Attention**: args only used with fist call

Types

type ChatLogSpec

type ChatLogSpec struct {
	PageSpec
	ModelSpec

	// 会话ID
	ChatID string `extensions:"x-order=A" form:"csid" json:"csid"`
}

func (*ChatLogSpec) Sift

func (spec *ChatLogSpec) Sift(q *ormQuery) *ormQuery

type Conversation

type Conversation interface {
	GetID() string
	GetOID() oid.OID
	AddHistory(ctx context.Context, item *aigc.HistoryItem) error
	ListHistory(ctx context.Context) (aigc.HistoryItems, error)
	ClearHistory(ctx context.Context) error
}

func NewConversation

func NewConversation(id any) Conversation

type DocumentSpec

type DocumentSpec struct {
	PageSpec
	ModelSpec

	// 主标题
	Title string `extensions:"x-order=A" form:"title" json:"title"`
	// 小节标题
	Heading string `extensions:"x-order=B" form:"heading" json:"heading"`
	// 内容
	Content string `extensions:"x-order=C" form:"content" json:"content"`
}

func (*DocumentSpec) CanSort

func (spec *DocumentSpec) CanSort(k string) bool

func (*DocumentSpec) Sift

func (spec *DocumentSpec) Sift(q *ormQuery) *ormQuery

type ExportArg

type ExportArg struct {
	Spec   *DocumentSpec
	Out    io.Writer
	Format string // csv,jsonl
}

type MatchSpec

type MatchSpec struct {
	Question  string
	Threshold float32
	Limit     int
}

type ModelSpec

type ModelSpec = pgx.ModelSpec

type PageSpec

type PageSpec = comm.PageSpec

type QaStore

type QaStore interface {
	ListDocument(ctx context.Context, spec *DocumentSpec) (data qas.Documents, total int, err error)
	GetDocument(ctx context.Context, id string) (obj *qas.Document, err error)
	CreateDocument(ctx context.Context, in qas.DocumentBasic) (obj *qas.Document, err error)
	UpdateDocument(ctx context.Context, id string, in qas.DocumentSet) error
	DeleteDocument(ctx context.Context, id string) error

	CreatePrompt(ctx context.Context, in qas.PromptBasic) (obj *qas.Prompt, err error)
	UpdatePrompt(ctx context.Context, id string, in qas.PromptSet) error
	DeletePrompt(ctx context.Context, id string) error

	CreateChatLog(ctx context.Context, in qas.ChatLogBasic) (obj *qas.ChatLog, err error)
	GetChatLog(ctx context.Context, id string) (obj *qas.ChatLog, err error)
	ListChatLog(ctx context.Context, spec *ChatLogSpec) (data qas.ChatLogs, total int, err error)
	DeleteChatLog(ctx context.Context, id string) error
	// contains filtered or unexported methods
}

type RedisClient

type RedisClient = redis.UniversalClient

func SgtRC

func SgtRC() RedisClient

SgtRC start return a singleton instance of redis client

type Storage

type Storage interface {
	Qa() QaStore // gened
}

type StringsDiff

type StringsDiff = pgx.StringsDiff

type TextSearchSpec

type TextSearchSpec = pgx.TextSearchSpec

type Wrap

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

Wrap implements Storages

func NewWithDB

func NewWithDB(db *pgx.DB) *Wrap

NewWithDB return new instance of Wrap

func Sgt

func Sgt() *Wrap

Sgt start and return a singleton instance of Storage

func (*Wrap) Close

func (w *Wrap) Close()

func (*Wrap) Qa

func (w *Wrap) Qa() QaStore

Jump to

Keyboard shortcuts

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