db

package
v0.0.0-...-235d477 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CtxDB *gorm.DB

Functions

func InitDB

func InitDB(config *config.Config, db *gorm.DB)

`InitDB` initialize local sql by open sql and create task_infos table

func OpenDB

func OpenDB(opts config.Config) (*gorm.DB, error)

func ParseDSN

func ParseDSN(opts config.Config) (dsn string, err error)

Types

type APIType

type APIType string
const OpenAI APIType = "openai"

type Datasource

type Datasource struct {
	ID         int       `gorm:"column:id;primaryKey;autoIncrement"`
	BID        string    `gorm:"column:b_id;not null;type:char(32);uniqueIndex;comment:datasource id"`
	Name       string    `gorm:"column:name;type:varchar(128);not null"`
	Type       string    `gorm:"column:type;type:varchar(128);not null"`
	Platform   string    `gorm:"column:platform;type:varchar(128);not null"`
	Config     string    `gorm:"column:config;type:text;not null"`
	Secret     string    `gorm:"column:secret;type:varchar(128);not null"`
	Host       string    `gorm:"column:host;type:varchar(128);not null"`
	Username   string    `gorm:"column:username;type:varchar(128);not null"`
	CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"`

	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;type:datetime"`
}

type Favorite

type Favorite struct {
	ID         int       `gorm:"column:id;primaryKey;autoIncrement"`
	BID        string    `gorm:"column:b_id;not null;type:char(32);uniqueIndex;comment:favorite id"`
	Content    string    `gorm:"column:content;type:varchar(255);not null"`
	Host       string    `gorm:"column:host;type:varchar(128);not null"`
	Username   string    `gorm:"column:username;type:varchar(128);not null"`
	CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"`

	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;type:datetime"`
}

type File

type File struct {
	ID         int       `gorm:"column:id;primaryKey;autoIncrement"`
	BID        string    `gorm:"column:b_id;not null;type:char(32);uniqueIndex;comment:file id"`
	Name       string    `gorm:"column:name;type:varchar(128);unique"`
	WithHeader bool      `gorm:"column:with_header;type:boolean;default:false;"`
	Delimiter  string    `gorm:"column:delimiter;default:',';"`
	Host       string    `gorm:"column:host;type:varchar(128);not null"`
	Username   string    `gorm:"column:username;type:varchar(128);not null"`
	CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"`
	UpdateTime time.Time `gorm:"column:update_time;type:datetime;autoUpdateTime"`
}

type LLMConfig

type LLMConfig struct {
	ID                 int     `json:"" gorm:"primaryKey;autoIncrement"`
	URL                string  `json:"url"`
	Key                string  `json:"key"`
	APIType            APIType `json:"apiType"`
	ContextLengthLimit int     `json:"contextLengthLimit"`
	Config             string  `json:"config"`
	Host               string  `json:"host"`
	UserName           string  `json:"userName"`
}

type LLMJob

type LLMJob struct {
	ID         int            `json:"id" gorm:"primaryKey;autoIncrement"`
	UserName   string         `json:"user_name" gorm:"index:"`
	Host       string         `json:"host" gorm:"index"`
	JobID      string         `json:"job_id" gorm:"index:,unique"`
	Space      string         `json:"space"`
	File       string         `json:"file"`
	JobType    string         `json:"job_type"`
	Status     base.LLMStatus `json:"status"`
	UserPrompt string         `json:"user_prompt"`
	Process    datatypes.JSON `json:"process"`
	CreateTime time.Time      `json:"create_time" gorm:"column:create_time;type:datetime;autoCreateTime"`
	UpdateTime time.Time      `json:"update_ime" gorm:"column:update_time;type:datetime;autoUpdateTime"`
}

type ModelVersion

type ModelVersion string
const LLM3Dot5Turbo ModelVersion = "llm3.5-turbo"
const LLM4 ModelVersion = "llm4"

type SchemaSnapshot

type SchemaSnapshot struct {
	ID         int       `gorm:"column:id;primaryKey;autoIncrement"`
	BID        string    `gorm:"column:b_id;not null;type:char(32);uniqueIndex;comment:schema snapshot id"`
	Space      string    `gorm:"column:space;type:varchar(255);not null"`
	Snapshot   string    `gorm:"column:snapshot;type:text;not null"`
	Host       string    `gorm:"column:host;type:varchar(256);not null"`
	Username   string    `gorm:"column:username;type:varchar(128);not null"`
	CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"`
	UpdateTime time.Time `gorm:"column:update_time;type:datetime;autoUpdateTime"`

	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;type:datetime"`
}

type Sketch

type Sketch struct {
	ID         int       `gorm:"column:id;primaryKey;autoIncrement"`
	BID        string    `gorm:"column:b_id;not null;type:char(32);uniqueIndex;comment:sketch id"`
	Name       string    `gorm:"column:name;type:varchar(255);not null"`
	Schema     string    `gorm:"column:schema;type:mediumtext;"`
	Snapshot   string    `gorm:"column:snapshot;type:mediumtext;"`
	Host       string    `gorm:"column:host;type:varchar(256);not null"`
	Username   string    `gorm:"column:username;type:varchar(128);not null"`
	CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"`
	UpdateTime time.Time `gorm:"column:update_time;type:datetime;autoUpdateTime"`

	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;type:datetime"`
}

type Stats

type Stats struct {
	ProcessedBytes  int64         `gorm:"column:processed_bytes;"`
	TotalBytes      int64         `gorm:"column:total_bytes;"`
	FailedRecords   int64         `gorm:"column:failed_records;"`
	TotalRecords    int64         `gorm:"column:total_records;"`
	FailedRequest   int64         `gorm:"column:failed_request;"`
	TotalRequest    int64         `gorm:"column:total_request;"`
	TotalLatency    time.Duration `gorm:"column:total_latency;"`
	TotalRespTime   time.Duration `gorm:"column:total_resp_time;"`
	FailedProcessed int64         `gorm:"column:failed_processed;"`
	TotalProcessed  int64         `gorm:"column:total_processed;"`
}

type TaskEffect

type TaskEffect struct {
	ID     int    `gorm:"column:id;primaryKey;autoIncrement;"`
	BID    string `gorm:"column:task_id;not null;type:char(32);uniqueIndex;comment:task id"`
	Log    string `gorm:"column:log;type:mediumtext;comment:partial task log"`
	Config string `gorm:"column:config;type:mediumtext;comment:task config.yaml"`

	CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"`
}

storage for task yaml config and partial task log

type TaskInfo

type TaskInfo struct {
	ID            int    `gorm:"column:id;primaryKey;autoIncrement;"`
	BID           string `gorm:"column:b_id;not null;type:char(32);uniqueIndex;comment:task id"`
	Address       string `gorm:"column:address;type:varchar(255);"`
	LLMJobID      int    `gorm:"column:llm_job_id;"`
	LLMJob        LLMJob `gorm:"foreignKey:LLMJobID;"`
	Name          string `gorm:"column:name;type:varchar(255);"`
	Space         string `gorm:"column:space;type:varchar(255);"`
	ImportAddress string `gorm:"column:import_address;"`
	User          string `gorm:"column:user;"`
	TaskStatus    string `gorm:"column:task_status;"`
	TaskMessage   string `gorm:"column:task_message;"`
	Stats         Stats  `gorm:"embedded"`
	RawConfig     string `gorm:"column:raw_config;type:mediumtext;"`

	CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"`
	UpdateTime time.Time `gorm:"column:update_time;type:datetime;autoUpdateTime"`
}

type Vector

type Vector struct {
	ID      int    `json:"ID" gorm:"primaryKey;autoIncrement"`
	Content string `json:"content"`
	Title   string `json:"title"`
	Url     string `json:"url"`
	Vec     string `json:"vec"`
}

Jump to

Keyboard shortcuts

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