refactor: Clean up code by removing unnecessary blank lines and improving comments for better readability and maintainability
This commit is contained in:
@@ -6,13 +6,14 @@ const (
|
||||
TypeFAQImport = "faq:import" // FAQ导入任务
|
||||
)
|
||||
|
||||
// ExtractChunkPayload represents the extract chunk task payload
|
||||
type ExtractChunkPayload struct {
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
ChunkID string `json:"chunk_id"`
|
||||
ModelID string `json:"model_id"`
|
||||
}
|
||||
|
||||
// DocumentProcessPayload 文档处理任务payload
|
||||
// DocumentProcessPayload represents the document process task payload
|
||||
type DocumentProcessPayload struct {
|
||||
RequestId string `json:"request_id"`
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
@@ -26,7 +27,7 @@ type DocumentProcessPayload struct {
|
||||
EnableMultimodel bool `json:"enable_multimodel"`
|
||||
}
|
||||
|
||||
// FAQImportPayload FAQ导入任务payload
|
||||
// FAQImportPayload represents the FAQ import task payload
|
||||
type FAQImportPayload struct {
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
TaskID string `json:"task_id"`
|
||||
@@ -36,6 +37,7 @@ type FAQImportPayload struct {
|
||||
Mode string `json:"mode"`
|
||||
}
|
||||
|
||||
// PromptTemplateStructured represents the prompt template structured
|
||||
type PromptTemplateStructured struct {
|
||||
Description string `json:"description"`
|
||||
Tags []string `json:"tags"`
|
||||
@@ -48,6 +50,7 @@ type GraphNode struct {
|
||||
Attributes []string `json:"attributes,omitempty"`
|
||||
}
|
||||
|
||||
// GraphRelation represents the relation of the graph
|
||||
type GraphRelation struct {
|
||||
Node1 string `json:"node1,omitempty"`
|
||||
Node2 string `json:"node2,omitempty"`
|
||||
@@ -60,11 +63,13 @@ type GraphData struct {
|
||||
Relation []*GraphRelation `json:"relation,omitempty"`
|
||||
}
|
||||
|
||||
// NameSpace represents the name space of the knowledge base and knowledge
|
||||
type NameSpace struct {
|
||||
KnowledgeBase string `json:"knowledge_base"`
|
||||
Knowledge string `json:"knowledge"`
|
||||
}
|
||||
|
||||
// Labels returns the labels of the name space
|
||||
func (n NameSpace) Labels() []string {
|
||||
res := make([]string, 0)
|
||||
if n.KnowledgeBase != "" {
|
||||
|
||||
@@ -160,10 +160,14 @@ type FAQSearchRequest struct {
|
||||
type FAQImportTaskStatus string
|
||||
|
||||
const (
|
||||
FAQImportStatusPending FAQImportTaskStatus = "pending"
|
||||
// FAQImportStatusPending represents the pending status of the FAQ import task
|
||||
FAQImportStatusPending FAQImportTaskStatus = "pending"
|
||||
// FAQImportStatusProcessing represents the processing status of the FAQ import task
|
||||
FAQImportStatusProcessing FAQImportTaskStatus = "processing"
|
||||
FAQImportStatusCompleted FAQImportTaskStatus = "completed"
|
||||
FAQImportStatusFailed FAQImportTaskStatus = "failed"
|
||||
// FAQImportStatusCompleted represents the completed status of the FAQ import task
|
||||
FAQImportStatusCompleted FAQImportTaskStatus = "completed"
|
||||
// FAQImportStatusFailed represents the failed status of the FAQ import task
|
||||
FAQImportStatusFailed FAQImportTaskStatus = "failed"
|
||||
)
|
||||
|
||||
// FAQImportMetadata 存储在Knowledge.Metadata中的FAQ导入任务信息
|
||||
|
||||
@@ -10,10 +10,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// KnowledgeTypeManual represents the manual knowledge type
|
||||
KnowledgeTypeManual = "manual"
|
||||
KnowledgeTypeFAQ = "faq"
|
||||
// KnowledgeTypeFAQ represents the FAQ knowledge type
|
||||
KnowledgeTypeFAQ = "faq"
|
||||
)
|
||||
|
||||
// ManualKnowledgeFormat represents the format of the manual knowledge
|
||||
const (
|
||||
ManualKnowledgeFormatMarkdown = "markdown"
|
||||
ManualKnowledgeStatusDraft = "draft"
|
||||
|
||||
@@ -8,32 +8,34 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// KnowledgeBaseType represents the type of the knowledge base
|
||||
const (
|
||||
// KnowledgeBaseTypeDocument represents the document knowledge base type
|
||||
KnowledgeBaseTypeDocument = "document"
|
||||
KnowledgeBaseTypeFAQ = "faq"
|
||||
)
|
||||
|
||||
// FAQIndexMode 表示 FAQ 索引策略:仅索引标准问还是同时索引问答内容
|
||||
// FAQIndexMode represents the FAQ index mode: only index questions or index questions and answers
|
||||
type FAQIndexMode string
|
||||
|
||||
const (
|
||||
// FAQIndexModeQuestionOnly 仅使用标准问及相似问向量化
|
||||
// FAQIndexModeQuestionOnly only index questions and similar questions
|
||||
FAQIndexModeQuestionOnly FAQIndexMode = "question_only"
|
||||
// FAQIndexModeQuestionAnswer 将标准问与答案拼接后向量化
|
||||
// FAQIndexModeQuestionAnswer index questions and answers together
|
||||
FAQIndexModeQuestionAnswer FAQIndexMode = "question_answer"
|
||||
)
|
||||
|
||||
// FAQQuestionIndexMode 表示 FAQ 问题索引方式:一起索引还是分别索引
|
||||
// FAQQuestionIndexMode represents the FAQ question index mode: index together or index separately
|
||||
type FAQQuestionIndexMode string
|
||||
|
||||
const (
|
||||
// FAQQuestionIndexModeCombined 将标准问和相似问一起索引(当前方式)
|
||||
// FAQQuestionIndexModeCombined index questions and similar questions together
|
||||
FAQQuestionIndexModeCombined FAQQuestionIndexMode = "combined"
|
||||
// FAQQuestionIndexModeSeparate 将标准问和相似问分别索引
|
||||
// FAQQuestionIndexModeSeparate index questions and similar questions separately
|
||||
FAQQuestionIndexModeSeparate FAQQuestionIndexMode = "separate"
|
||||
)
|
||||
|
||||
// KnowledgeBase represents a knowledge base
|
||||
// KnowledgeBase represents a knowledge base entity
|
||||
type KnowledgeBase struct {
|
||||
// Unique identifier of the knowledge base
|
||||
ID string `yaml:"id" json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
@@ -195,6 +197,7 @@ func (c *VLMConfig) Scan(value interface{}) error {
|
||||
return json.Unmarshal(b, c)
|
||||
}
|
||||
|
||||
// ExtractConfig represents the extract configuration for a knowledge base
|
||||
type ExtractConfig struct {
|
||||
Enabled bool `yaml:"enabled" json:"enabled"`
|
||||
Text string `yaml:"text" json:"text,omitempty"`
|
||||
|
||||
@@ -19,6 +19,7 @@ const (
|
||||
ModelTypeVLLM ModelType = "VLLM" // VLLM model
|
||||
)
|
||||
|
||||
// ModelStatus represents the status of the model
|
||||
type ModelStatus string
|
||||
|
||||
const (
|
||||
@@ -36,6 +37,7 @@ const (
|
||||
ModelSourceAliyun ModelSource = "aliyun" // Aliyun DashScope model
|
||||
)
|
||||
|
||||
// EmbeddingParameters represents the embedding parameters for a model
|
||||
type EmbeddingParameters struct {
|
||||
Dimension int `yaml:"dimension" json:"dimension"`
|
||||
TruncatePromptTokens int `yaml:"truncate_prompt_tokens" json:"truncate_prompt_tokens"`
|
||||
|
||||
@@ -17,6 +17,7 @@ const (
|
||||
FallbackStrategyModel FallbackStrategy = "model" // Model fallback response
|
||||
)
|
||||
|
||||
// SummaryConfig represents the summary configuration for a session
|
||||
type SummaryConfig struct {
|
||||
// Max tokens
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
@@ -109,6 +110,7 @@ func (s *Session) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// StringArray represents a list of strings
|
||||
type StringArray []string
|
||||
|
||||
// Value implements the driver.Valuer interface, used to convert StringArray to database value
|
||||
|
||||
@@ -44,10 +44,12 @@ type Tenant struct {
|
||||
DeletedAt gorm.DeletedAt `yaml:"deleted_at" json:"deleted_at" gorm:"index"`
|
||||
}
|
||||
|
||||
// RetrieverEngines represents the retriever engines for a tenant
|
||||
type RetrieverEngines struct {
|
||||
Engines []RetrieverEngineParams `yaml:"engines" json:"engines" gorm:"type:json"`
|
||||
}
|
||||
|
||||
// BeforeCreate is a hook function that is called before creating a tenant
|
||||
func (t *Tenant) BeforeCreate(tx *gorm.DB) error {
|
||||
if t.RetrieverEngines.Engines == nil {
|
||||
t.RetrieverEngines.Engines = []RetrieverEngineParams{}
|
||||
|
||||
Reference in New Issue
Block a user