stores

package
v0.0.0-...-24eefd9 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 28 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 DbOpModelMetaCreator

func DbOpModelMetaCreator(ctx context.Context, db ormDB, obj ModelMetaCreator) (err error)

func GetEmbedding

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

func GetInteractAIClient

func GetInteractAIClient() *openai.Client

func GetKeywords

func GetKeywords(ctx context.Context, text string) (kw string, err error)

func InitDB

func InitDB() error

func LoadPreset

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

func NewOpenAIClient

func NewOpenAIClient(args ...string) *openai.Client

func OpModelCreator

func OpModelCreator(ctx context.Context, obj comm.ModelCreator) (id oid.OID, name string)

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 ExportArg

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

type MCPServerSpec

type MCPServerSpec struct {
	PageSpec
	ModelSpec

	// 名称
	Name string `extensions:"x-order=A" form:"name" json:"name"`
	// 传输类型 (支持混合解码)
	//  * `stdIO` - 标准IO
	//  * `sse`
	//  * `http`
	//  * `inMemory` - 内部运行
	TransType string `extensions:"x-order=B" form:"transType" json:"transType" swaggertype:"string"`
	// 状态
	//  * `stopped` - 已停止
	//  * `running` - 运行中
	Status mcps.Status `extensions:"x-order=C" form:"status" json:"status" swaggertype:"string"`
}

func (*MCPServerSpec) Sift

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

type MCPStore

type MCPStore interface {
	ListServer(ctx context.Context, spec *MCPServerSpec) (data mcps.Servers, total int, err error)
	GetServer(ctx context.Context, id string) (obj *mcps.Server, err error)
	CreateServer(ctx context.Context, in mcps.ServerBasic) (obj *mcps.Server, err error)
	UpdateServer(ctx context.Context, id string, in mcps.ServerSet) error
	DeleteServer(ctx context.Context, id string) error
}

type MatchSpec

type MatchSpec struct {
	Question     string
	Threshold    float32
	Limit        int
	SkipKeywords bool
}

type Model

type Model = pgx.Model

type ModelMeta

type ModelMeta = comm.ModelMeta

type ModelMetaCreator

type ModelMetaCreator interface {
	ModelMeta
	comm.ModelCreator
}

type ModelSpec

type ModelSpec = pgx.ModelSpec

type PageSpec

type PageSpec = comm.PageSpec

type QaDocumentSpec

type QaDocumentSpec 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 (*QaDocumentSpec) CanSort

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

func (*QaDocumentSpec) Sift

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

type QaStore

type QaStore interface {
	ListDocument(ctx context.Context, spec *QaDocumentSpec) (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

	GetDocVector(ctx context.Context, id string) (obj *qas.DocVector, err error)
	CreateDocVector(ctx context.Context, in qas.DocVectorBasic) (obj *qas.DocVector, err error)
	DeleteDocVector(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
	MCP() MCPStore // gened
}

type StringsDiff

type StringsDiff = pgx.StringsDiff

type TextSearchSpec

type TextSearchSpec = pgx.TextSearchSpec

type User

type User = auth.User

func UserFromContext

func UserFromContext(ctx context.Context) (*User, bool)

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) MCP

func (w *Wrap) MCP() MCPStore

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