service

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SplitByDesign  string = "split_by_design"
	SplitByDefault string = "split_by_default"
)

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(ctx context.Context, srcFilePath string, destObjectNamePre string) (string, string, int64, error)

func DeleteFile

func DeleteFile(ctx context.Context, minioFilePath string) error

func DownloadFile

func DownloadFile(ctx context.Context, minioFilePath string) ([]byte, error)

func DownloadFileObject added in v0.2.1

func DownloadFileObject(ctx context.Context, minioFilePath string) (*minio.Object, error)

func DownloadFileToLocal

func DownloadFileToLocal(ctx context.Context, minioFilePath string, localPath string) error

func RagCreateDocSegment added in v0.2.0

func RagCreateDocSegment(ctx context.Context, ragCreateDocSegmentParams *RagCreateDocSegmentParams) error

RagCreateDocSegment 新增文档切片

func RagDeleteDoc

func RagDeleteDoc(ctx context.Context, ragDeleteDocParams *RagDeleteDocParams) error

RagDeleteDoc 删除具体文档

func RagDeleteDocSegment added in v0.2.1

func RagDeleteDocSegment(ctx context.Context, ragDeleteDocSegmentParams *RagDeleteDocSegmentParams) error

RagDeleteDocSegment 删除文档切片

func RagDocMeta added in v0.1.6

func RagDocMeta(ctx context.Context, ragDocTagParams *RagDocMetaParams) error

RagDocMeta 更新文档元数据

func RagDocSegmentLabels added in v0.1.8

func RagDocSegmentLabels(ctx context.Context, ragDocSegLabelsParams *RagDocSegmentLabelsParams) error

RagDocSegmentLabels 更新文档切片标签

func RagDocUpdateDocSegmentStatus

func RagDocUpdateDocSegmentStatus(ctx context.Context, docSegmentStatusUpdateParams interface{}) error

RagDocUpdateDocSegmentStatus 更新文档切片状态

func RagImportDoc

func RagImportDoc(ctx context.Context, ragImportDocParams *RagImportDocParams) error

RagImportDoc 导入具体文档

func RagImportUrlDoc

func RagImportUrlDoc(ctx context.Context, ragImportDocParams *RagImportUrlDocParams) error

RagImportUrlDoc 导入url文档

func RagKnowledgeCreate

func RagKnowledgeCreate(ctx context.Context, ragCreateParams *RagCreateParams) error

RagKnowledgeCreate rag创建知识库

func RagKnowledgeDelete

func RagKnowledgeDelete(ctx context.Context, ragDeleteParams *RagDeleteParams) error

RagKnowledgeDelete rag更新知识库删除

func RagKnowledgeUpdate

func RagKnowledgeUpdate(ctx context.Context, ragUpdateParams *RagUpdateParams) error

RagKnowledgeUpdate rag更新知识库

func RagOperateKeywords added in v0.1.6

func RagOperateKeywords(ctx context.Context, ragOperateKeywordsParams *RagOperateKeywordsParams) error

RagOperateKeywords rag添加关键词

func RagUpdateDocSegment added in v0.2.1

func RagUpdateDocSegment(ctx context.Context, ragUpdateDocSegmentParams *RagUpdateDocSegmentParams) error

RagUpdateDocSegment 更新文档切片

func RebuildFileName

func RebuildFileName(docId, docType, docName string) string

func RebuildSegmentType

func RebuildSegmentType(segmentType string) string

RebuildSegmentType 转换分段类型

func SplitFilePath

func SplitFilePath(filePath string) (bucketName string, objectName string, fileName string)

func UploadFile

func UploadFile(ctx context.Context, dir string, fileName string, reader io.Reader, objectSize int64) (string, int64, error)

func UploadLocalFile

func UploadLocalFile(ctx context.Context, minioDir string, minioFileName string, srcFilePath string) (string, string, int64, error)

UploadLocalFile 根据文件路径上传文件

Types

type ChunkSearchList added in v0.1.3

type ChunkSearchList struct {
	Title    string      `json:"title"`
	Snippet  string      `json:"snippet"`
	KbName   string      `json:"kb_name"`
	MetaData interface{} `json:"meta_data"`
}

type ContentListResp

type ContentListResp struct {
	List          []FileSplitContent `json:"content_list"`
	ChunkTotalNum int                `json:"chunk_total_num"`
}

func RagGetDocSegmentList

func RagGetDocSegmentList(ctx context.Context, ragGetDocSegmentParams *RagGetDocSegmentParams) (*ContentListResp, error)

RagGetDocSegmentList rag获取知识库文档分片

type ContentMetaData

type ContentMetaData struct {
	FileName        string `json:"file_name"`
	ChunkLen        int    `json:"chunk_len"`
	ChunkCurrentNum int    `json:"chunk_current_num"`
	ChunkTotalNum   int    `json:"chunk_total_num"`
}

type DocSegmentStatusUpdateAllParams

type DocSegmentStatusUpdateAllParams struct {
	DocSegmentStatusUpdateParams
	All bool `json:"on_off_switch"`
}

type DocSegmentStatusUpdateParams

type DocSegmentStatusUpdateParams struct {
	UserId        string `json:"userId"`
	KnowledgeName string `json:"knowledgeBase"`
	FileName      string `json:"fileName"`
	ContentId     string `json:"content_id"`
	Status        bool   `json:"status"`
}

type DocUrlParams

type DocUrlParams struct {
	Url string `json:"url"`
}

type DocUrlResp

type DocUrlResp struct {
	Url          string        `json:"url"`
	OldName      string        `json:"old_name"`
	FileName     string        `json:"file_name"`
	FileSize     float64       `json:"file_size"`
	ResponseInfo RagCommonResp `json:"response_info"`
}

func BatchRagDocUrlAnalysis

func BatchRagDocUrlAnalysis(ctx context.Context, urlList []string) ([]*DocUrlResp, error)

func RagDocUrlAnalysis

func RagDocUrlAnalysis(ctx context.Context, docUrlParams *DocUrlParams) (*DocUrlResp, error)

RagDocUrlAnalysis 文档url解析

type DocUrlRespSafeArray

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

func (*DocUrlRespSafeArray) Append

func (sa *DocUrlRespSafeArray) Append(value *DocUrlResp)

func (*DocUrlRespSafeArray) Get

func (sa *DocUrlRespSafeArray) Get(index int) interface{}

func (*DocUrlRespSafeArray) Len

func (sa *DocUrlRespSafeArray) Len() int

type FileSplitContent

type FileSplitContent struct {
	Content   string          `json:"content"`
	Order     int             `json:"order"`
	Status    bool            `json:"status"`
	MetaData  ContentMetaData `json:"meta_data"`
	ContentId string          `json:"content_id"`
	UserId    string          `json:"userId"`
	KbName    string          `json:"kb_name"`
	FileName  string          `json:"file_name"`
	Labels    []string        `json:"labels"`
}

type KnowledgeHitData added in v0.1.3

type KnowledgeHitData struct {
	Prompt     string             `json:"prompt"`
	SearchList []*ChunkSearchList `json:"searchList"`
	Score      []float64          `json:"score"`
}

type KnowledgeHitParams added in v0.1.3

type KnowledgeHitParams struct {
	UserId               string                `json:"userId"`
	Question             string                `json:"question" validate:"required"`
	KnowledgeBase        []string              `json:"knowledgeBase" validate:"required"`
	Threshold            float64               `json:"threshold"`
	TopK                 int32                 `json:"topK"`
	RerankModelId        string                `json:"rerank_model_id"`               // rerankId
	RerankMod            string                `json:"rerank_mod"`                    // rerank_model:重排序模式,weighted_score:权重搜索
	RetrieveMethod       string                `json:"retrieve_method"`               // hybrid_search:混合搜索, semantic_search:向量搜索, full_text_search:文本搜索
	Weight               *WeightParams         `json:"weights"`                       // 权重搜索下的权重配置
	TermWeight           float32               `json:"term_weight_coefficient"`       // 关键词系数
	MetaFilter           bool                  `json:"metadata_filtering"`            // 元数据过滤开关
	MetaFilterConditions []*MetadataFilterItem `json:"metadata_filtering_conditions"` // 元数据过滤条件
}

type MetaData added in v0.1.7

type MetaData struct {
	Key       string      `json:"key"`
	Value     interface{} `json:"value"`
	ValueType string      `json:"value_type"`
}

type MetaItem added in v0.2.2

type MetaItem struct {
	MetaName           string      `json:"meta_name"`           // 元数据名称
	MetaType           string      `json:"meta_type"`           // 元数据类型
	ComparisonOperator string      `json:"comparison_operator"` // 比较运算符
	Value              interface{} `json:"value,omitempty"`     // 用于过滤的条件值
}

type MetadataFilterItem added in v0.2.2

type MetadataFilterItem struct {
	FilterKnowledgeName string      `json:"filtering_kb_name"`
	LogicalOperator     string      `json:"logical_operator"`
	Conditions          []*MetaItem `json:"conditions"`
}

type NewChunkItem added in v0.2.1

type NewChunkItem struct {
	Content string   `json:"content"`
	Labels  []string `json:"labels"`
}

type RagCommonResp

type RagCommonResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type RagCreateDocSegmentParams added in v0.2.0

type RagCreateDocSegmentParams struct {
	UserId          string          `json:"userId"`            // 发起请求的用户ID
	KnowledgeBase   string          `json:"knowledgeBase"`     // 知识库的名称
	KnowledgeId     string          `json:"kb_id"`             // 知识库的唯一ID
	FileName        string          `json:"fileName"`          // 与chunk关联的文件名
	MaxSentenceSize int             `json:"max_sentence_size"` // 最大分段长度限制
	Chunks          []*NewChunkItem `json:"chunks"`            // 分段数据列表
}

type RagCreateParams

type RagCreateParams struct {
	UserId           string `json:"userId"`
	Name             string `json:"knowledgeBase"`
	KnowledgeBaseId  string `json:"kb_id"`
	EmbeddingModelId string `json:"embedding_model_id"`
}

type RagDeleteDocParams

type RagDeleteDocParams struct {
	UserId        string `json:"userId"`
	KnowledgeBase string `json:"knowledgeBase"`
	FileName      string `json:"fileName"`
}

type RagDeleteDocSegmentParams added in v0.2.1

type RagDeleteDocSegmentParams struct {
	UserId        string   `json:"userId"`        // 发起请求的用户ID
	KnowledgeBase string   `json:"knowledgeBase"` // 知识库的名称
	KnowledgeId   string   `json:"kb_id"`         // 知识库的唯一ID
	FileName      string   `json:"fileName"`      // 与chunk关联的文件名
	ChunkIds      []string `json:"chunk_ids"`     // 分段数据列表
}

type RagDeleteParams

type RagDeleteParams struct {
	UserId            string `json:"userId"`
	KnowledgeBaseName string `json:"knowledgeBase"`
}

type RagDocMetaParams added in v0.1.6

type RagDocMetaParams struct {
	UserId        string      `json:"userId"`
	KnowledgeBase string      `json:"knowledgeBase"`
	FileName      string      `json:"fileName"`
	MetaList      []*MetaData `json:"tags"`
}

type RagDocSegmentLabelsParams added in v0.1.8

type RagDocSegmentLabelsParams struct {
	UserId        string   `json:"userId"`        // 发起请求的用户ID
	KnowledgeBase string   `json:"knowledgeBase"` // 知识库的名称
	KnowledgeId   string   `json:"kb_id"`         // 知识库的唯一ID
	FileName      string   `json:"fileName"`      // 与chunk关联的文件名
	ContentId     string   `json:"chunk_id"`      // 要更新标签的chunk的唯一ID
	Labels        []string `json:"labels"`        // 需要为该chunk关联的标签列表
}

type RagDocSegmentResp added in v0.2.1

type RagDocSegmentResp struct {
	Code    int           `json:"code"`
	Message string        `json:"message"`
	Data    SegmentResult `json:"data"`
}

type RagGetDocSegmentParams

type RagGetDocSegmentParams struct {
	UserId            string `json:"userId"`
	KnowledgeBaseName string `json:"knowledgeBase"`
	FileName          string `json:"fileName"`
	PageSize          int32  `json:"page_size"`
	SearchAfter       int32  `json:"search_after"`
}

type RagGetDocSegmentResp

type RagGetDocSegmentResp struct {
	RagCommonResp
	Data *ContentListResp `json:"data"`
}

type RagImportDocParams

type RagImportDocParams struct {
	DocId             string               `json:"id"`         //文档id
	KnowledgeName     string               `json:"categoryId"` //知识库名称
	CategoryId        string               `json:"kb_id"`      //知识库id
	IsEnhanced        string               `json:"is_enhanced"`
	UserId            string               `json:"userId"`
	Overlap           float32              `json:"overlap" `
	ObjectName        string               `json:"objectName"`
	SegmentSize       int                  `json:"chunk_size"`
	OriginalName      string               `json:"originalName"`
	SegmentType       string               `json:"chunk_type"`
	Separators        []string             `json:"separators"`
	ParserChoices     []string             `json:"parser_choices"`
	OcrModelId        string               `json:"ocr_model_id"`
	PreProcess        []string             `json:"pre_process"`
	RagMetaDataParams []*RagMetaDataParams `json:"meta_data"`
}

type RagImportUrlDocParams

type RagImportUrlDocParams struct {
	Url               string               `json:"url"`
	FileName          string               `json:"file_name"`
	Overlap           float32              `json:"overlap_size" `
	SegmentSize       int                  `json:"sentence_size"`
	SegmentType       string               `json:"chunk_type"`
	UserId            string               `json:"userId"`
	KnowledgeBaseName string               `json:"knowledgeBase"`
	IsEnhanced        bool                 `json:"is_enhanced"`
	Separators        []string             `json:"separators"`
	TaskId            string               `json:"task_id"`
	OcrModelId        string               `json:"ocr_model_id"`
	PreProcess        []string             `json:"pre_process"`
	RagMetaDataParams []*RagMetaDataParams `json:"meta_data"`
}

type RagKnowledgeHitResp added in v0.1.3

type RagKnowledgeHitResp struct {
	Code    int               `json:"code"`
	Message string            `json:"message"`
	Data    *KnowledgeHitData `json:"data"`
}

func RagKnowledgeHit added in v0.1.3

func RagKnowledgeHit(ctx context.Context, knowledgeHitParams *KnowledgeHitParams) (*RagKnowledgeHitResp, error)

RagKnowledgeHit rag命中测试

type RagMetaDataParams added in v0.1.7

type RagMetaDataParams struct {
	MetaId    string      `json:"meta_id"`    // 元数据id
	Key       string      `json:"key"`        // key
	Value     interface{} `json:"value"`      // 常量
	ValueType string      `json:"value_type"` // 常量类型
	Rule      string      `json:"rule"`       // 正则表达式
}

type RagOperateKeywordsParams added in v0.1.6

type RagOperateKeywordsParams struct {
	Id               uint32   `json:"id"`
	UserId           string   `json:"user_id"`
	Action           string   `json:"action"`
	Name             string   `json:"name"`
	Alias            []string `json:"alias"`
	KnowledgeBaseIds []string `json:"knowledge_base_list"`
}

type RagOperationParams

type RagOperationParams struct {
	Operation string              `json:"operation"`
	Type      string              `json:"type"`
	Doc       *RagImportDocParams `json:"doc"`
}

type RagUpdateDocSegmentParams added in v0.2.1

type RagUpdateDocSegmentParams struct {
	UserId          string           `json:"userId"`            // 发起请求的用户ID
	KnowledgeBase   string           `json:"knowledgeBase"`     // 知识库的名称
	KnowledgeId     string           `json:"kb_id"`             // 知识库的唯一ID
	FileName        string           `json:"fileName"`          // 与chunk关联的文件名
	MaxSentenceSize int              `json:"max_sentence_size"` // 最大分段长度限制
	Chunk           *UpdateChunkItem `json:"chunk"`             // 分段数据列表
}

type RagUpdateParams

type RagUpdateParams struct {
	UserId          string `json:"userId"`
	KnowledgeBaseId string `json:"kb_id"`
	OldKbName       string `json:"old_kb_name"`
	NewKbName       string `json:"new_kb_name"`
}

type SegmentResult added in v0.2.0

type SegmentResult struct {
	SuccessCount int `json:"success_count"` // 分段成功导入数量
}

type UpdateChunkItem added in v0.2.1

type UpdateChunkItem struct {
	ChunkId string   `json:"chunk_id"`
	Content string   `json:"content"`
	Labels  []string `json:"labels"`
}

type WeightParams added in v0.1.5

type WeightParams struct {
	VectorWeight float32 `json:"vector_weight"` //语义权重
	TextWeight   float32 `json:"text_weight"`   //关键字权重
}

Jump to

Keyboard shortcuts

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