Documentation
¶
Index ¶
- func Decode[T any](data any) T
- func Ptr[T any](v T) *T
- type AIModel
- type AIModelConfig
- type APIError
- type APIResponse
- type BatchDeleteDocumentsRequest
- type ChatMessage
- type CheckModelRequest
- type CheckModelResponse
- type Client
- type CreateDatasetRequest
- type CreateModelRequest
- type Dataset
- type DatasetConfig
- type DatasetStats
- type DatasetsService
- func (s *DatasetsService) Create(ctx context.Context, req *CreateDatasetRequest) (*Dataset, error)
- func (s *DatasetsService) Delete(ctx context.Context, datasetID string) error
- func (s *DatasetsService) Get(ctx context.Context, datasetID string) (*Dataset, error)
- func (s *DatasetsService) GetStats(ctx context.Context, datasetID string) (*DatasetStats, error)
- func (s *DatasetsService) List(ctx context.Context, req *ListDatasetsRequest) (*ListDatasetsResponse, error)
- func (s *DatasetsService) Update(ctx context.Context, datasetID string, req *UpdateDatasetRequest) (*Dataset, error)
- type Document
- type DocumentsService
- func (s *DocumentsService) BatchDelete(ctx context.Context, req *BatchDeleteDocumentsRequest) error
- func (s *DocumentsService) Delete(ctx context.Context, datasetID, documentID string) error
- func (s *DocumentsService) Get(ctx context.Context, datasetID, documentID string) (*Document, error)
- func (s *DocumentsService) List(ctx context.Context, req *ListDocumentsRequest) (*ListDocumentsResponse, error)
- func (s *DocumentsService) Reindex(ctx context.Context, datasetID, documentID string) (*ReindexResponse, error)
- func (s *DocumentsService) Update(ctx context.Context, req *UpdateDocumentRequest) (*Document, error)
- func (s *DocumentsService) Upload(ctx context.Context, req *UploadDocumentRequest) (*UploadDocumentResponse, error)
- type GenerateRequest
- type GenerateResponse
- type GenerateService
- type HealthResponse
- type HealthService
- type JSON
- type ListDatasetsRequest
- type ListDatasetsResponse
- type ListDocumentsRequest
- type ListDocumentsResponse
- type ListModelsRequest
- type ListModelsResponse
- type ListProviderModelsRequest
- type ListResponse
- type ModelCapabilities
- type ModelsService
- func (s *ModelsService) Check(ctx context.Context, req *CheckModelRequest) (*CheckModelResponse, error)
- func (s *ModelsService) Create(ctx context.Context, req *CreateModelRequest) (*AIModel, error)
- func (s *ModelsService) Delete(ctx context.Context, modelID string) error
- func (s *ModelsService) Get(ctx context.Context, modelID string) (*AIModel, error)
- func (s *ModelsService) List(ctx context.Context, req *ListModelsRequest) (*ListModelsResponse, error)
- func (s *ModelsService) ListProviderModels(ctx context.Context, req *ListProviderModelsRequest) (interface{}, error)
- func (s *ModelsService) Update(ctx context.Context, modelID string, req *UpdateModelRequest) (*AIModel, error)
- func (s *ModelsService) Upsert(ctx context.Context, req *UpsertModelRequest) (*UpsertModelResponse, error)
- type Option
- type ProviderModel
- type QARequest
- type QAResponse
- type QAService
- type ReindexResponse
- type RetrieveRequest
- type SearchResponse
- type SearchResult
- type SearchService
- type UpdateDatasetRequest
- type UpdateDocumentRequest
- type UpdateModelRequest
- type UploadDocumentRequest
- type UploadDocumentResponse
- type UpsertModelRequest
- type UpsertModelResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AIModel ¶
type AIModel struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ModelType string `json:"model_type"`
Provider string `json:"provider"`
ModelName string `json:"model_name"`
Config AIModelConfig `json:"config"`
Capabilities ModelCapabilities `json:"capabilities"`
Status string `json:"status"`
IsDefault bool `json:"is_default"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
AIModel AI 模型
type AIModelConfig ¶
type AIModelConfig struct {
// API 配置
APIKey string `json:"api_key,omitempty"`
APIBase string `json:"api_base,omitempty"`
APIHeader string `json:"api_header,omitempty"`
APIVersion string `json:"api_version,omitempty"`
OrgID string `json:"org_id,omitempty"`
// 模型参数(Chat Model 专用)
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
// 其他配置
Timeout int `json:"timeout,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
CustomHeaders map[string]string `json:"custom_headers,omitempty"`
ExtraParameters map[string]interface{} `json:"extra_parameters,omitempty"`
}
AIModelConfig AI 模型配置
type APIResponse ¶
type APIResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
APIResponse 统一的 API 响应结构
type BatchDeleteDocumentsRequest ¶
type BatchDeleteDocumentsRequest struct {
DatasetID string `json:"-"`
DocumentIDs []string `json:"document_ids"`
}
BatchDeleteDocumentsRequest 批量删除文档请求
type ChatMessage ¶ added in v0.1.2
type CheckModelRequest ¶
type CheckModelRequest struct {
Provider string `json:"provider"`
ModelName string `json:"model_name"`
Config AIModelConfig `json:"config"`
}
CheckModelRequest 检查模型配置请求
type CheckModelResponse ¶
type CheckModelResponse struct {
Valid bool `json:"valid"`
Error string `json:"error,omitempty"`
ModelInfo interface{} `json:"model_info,omitempty"`
}
CheckModelResponse 检查模型响应
type Client ¶
type Client struct {
// Services
Models *ModelsService
Datasets *DatasetsService
Documents *DocumentsService
Search *SearchService
QA *QAService
Generate *GenerateService
Health *HealthService
// contains filtered or unexported fields
}
Client RAGLite SDK 客户端
type CreateDatasetRequest ¶
type CreateDatasetRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
DenseModelID *string `json:"dense_model_id,omitempty"`
SparseModelID *string `json:"sparse_model_id,omitempty"`
AnalysisModelID *string `json:"analysis_model_id,omitempty"`
RerankerModelID *string `json:"reranker_model_id,omitempty"`
VisionModelID *string `json:"vision_model_id,omitempty"`
Config DatasetConfig `json:"config,omitempty"`
}
CreateDatasetRequest 创建数据集请求
type CreateModelRequest ¶
type CreateModelRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
ModelType string `json:"model_type"`
Provider string `json:"provider"`
ModelName string `json:"model_name"`
Config AIModelConfig `json:"config,omitempty"`
Capabilities ModelCapabilities `json:"capabilities,omitempty"`
IsDefault bool `json:"is_default,omitempty"`
}
CreateRequest 创建模型请求
type Dataset ¶
type Dataset struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
DenseModelID string `json:"dense_model_id"`
SparseModelID *string `json:"sparse_model_id,omitempty"`
AnalysisModelID *string `json:"analysis_model_id,omitempty"`
RerankerModelID *string `json:"reranker_model_id,omitempty"`
VisionModelID *string `json:"vision_model_id,omitempty"`
Config DatasetConfig `json:"config"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Dataset 数据集
type DatasetConfig ¶
type DatasetConfig struct {
ChunkSize int `json:"chunk_size"` // 块大小(tokens)
ChunkOverlap int `json:"chunk_overlap"` // 块重叠(tokens)
IndexParams map[string]interface{} `json:"index_params,omitempty"` // 索引配置(可选)
}
DatasetConfig 数据集配置
type DatasetStats ¶
type DatasetStats struct {
Dataset Dataset `json:"dataset"`
TotalDocuments int64 `json:"total_documents"`
PendingDocs int64 `json:"pending_docs"`
ProcessingDocs int64 `json:"processing_docs"`
CompletedDocs int64 `json:"completed_docs"`
FailedDocs int64 `json:"failed_docs"`
TotalFileSize int64 `json:"total_file_size"`
}
DatasetStats 数据集统计
type DatasetsService ¶
type DatasetsService struct {
// contains filtered or unexported fields
}
DatasetsService 数据集管理服务
func (*DatasetsService) Create ¶
func (s *DatasetsService) Create(ctx context.Context, req *CreateDatasetRequest) (*Dataset, error)
Create 创建数据集
func (*DatasetsService) Delete ¶
func (s *DatasetsService) Delete(ctx context.Context, datasetID string) error
Delete 删除数据集
func (*DatasetsService) GetStats ¶
func (s *DatasetsService) GetStats(ctx context.Context, datasetID string) (*DatasetStats, error)
GetStats 获取数据集统计信息
func (*DatasetsService) List ¶
func (s *DatasetsService) List(ctx context.Context, req *ListDatasetsRequest) (*ListDatasetsResponse, error)
List 列出数据集
func (*DatasetsService) Update ¶
func (s *DatasetsService) Update(ctx context.Context, datasetID string, req *UpdateDatasetRequest) (*Dataset, error)
Update 更新数据集
type Document ¶
type Document struct {
ID string `json:"id"`
DatasetID string `json:"dataset_id"`
Title string `json:"title"`
Filename string `json:"filename"`
FilePath string `json:"file_path"`
FileHash string `json:"file_hash"`
FileSize int64 `json:"file_size"`
Metadata JSON `json:"metadata"`
Tags []string `json:"tags"`
Status string `json:"status"`
ProgressMsg string `json:"progress_msg,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Document 文档
type DocumentsService ¶
type DocumentsService struct {
// contains filtered or unexported fields
}
DocumentsService 文档管理服务
func (*DocumentsService) BatchDelete ¶
func (s *DocumentsService) BatchDelete(ctx context.Context, req *BatchDeleteDocumentsRequest) error
BatchDelete 批量删除文档
func (*DocumentsService) Delete ¶
func (s *DocumentsService) Delete(ctx context.Context, datasetID, documentID string) error
Delete 删除文档
func (*DocumentsService) Get ¶
func (s *DocumentsService) Get(ctx context.Context, datasetID, documentID string) (*Document, error)
Get 获取文档详情
func (*DocumentsService) List ¶
func (s *DocumentsService) List(ctx context.Context, req *ListDocumentsRequest) (*ListDocumentsResponse, error)
List 列出文档
func (*DocumentsService) Reindex ¶ added in v0.2.2
func (s *DocumentsService) Reindex(ctx context.Context, datasetID, documentID string) (*ReindexResponse, error)
Reindex 重新索引单个文档
func (*DocumentsService) Update ¶
func (s *DocumentsService) Update(ctx context.Context, req *UpdateDocumentRequest) (*Document, error)
Update 更新文档的 metadata 和 tags
func (*DocumentsService) Upload ¶
func (s *DocumentsService) Upload(ctx context.Context, req *UploadDocumentRequest) (*UploadDocumentResponse, error)
Upload 上传文档
type GenerateRequest ¶
type GenerateRequest struct {
Query string `json:"query"`
Context string `json:"context"`
DatasetID string `json:"dataset_id"`
}
GenerateRequest 生成请求
type GenerateResponse ¶
type GenerateResponse struct {
Answer string `json:"answer"`
}
GenerateResponse 生成响应
type GenerateService ¶
type GenerateService struct {
// contains filtered or unexported fields
}
GenerateService 生成服务
func (*GenerateService) Generate ¶
func (s *GenerateService) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate 生成答案(不检索,直接生成)
type HealthResponse ¶
HealthResponse 健康检查响应
type HealthService ¶
type HealthService struct {
// contains filtered or unexported fields
}
HealthService 健康检查服务
func (*HealthService) Check ¶
func (s *HealthService) Check(ctx context.Context) (*HealthResponse, error)
Check 健康检查
type JSON ¶
type JSON struct {
Data interface{}
}
JSON 辅助类型,用于处理 JSON 字段
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON 实现 json.Unmarshaler
type ListDatasetsRequest ¶
type ListDatasetsRequest struct {
Status string
}
ListDatasetsRequest 列表查询请求
type ListDatasetsResponse ¶
type ListDatasetsResponse struct {
Datasets []Dataset `json:"datasets"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
ListDatasetsResponse 列表响应
type ListDocumentsRequest ¶
type ListDocumentsRequest struct {
DatasetID string
DocumentIDs []string // 可选:按文档 ID 列表过滤
Page int // 页码,默认 1
PageSize int // 每页数量,默认 20,设为 0 则不分页
}
ListDocumentsRequest 列表查询请求
type ListDocumentsResponse ¶
type ListDocumentsResponse struct {
Documents []Document `json:"documents"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
ListDocumentsResponse 列表响应
type ListModelsRequest ¶
ListModelsRequest 列表查询请求
type ListModelsResponse ¶
ListModelsResponse 列表响应
type ListProviderModelsRequest ¶
type ListProviderModelsRequest struct {
Provider string `json:"provider"`
Options map[string]interface{} `json:"options,omitempty"`
}
ListProviderModelsRequest 获取供应商支持的模型列表请求
type ListResponse ¶
type ListResponse struct {
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
ListResponse 列表响应
type ModelCapabilities ¶
type ModelCapabilities struct {
// Embedding 模型能力
VectorDimension *int `json:"vector_dimension,omitempty"`
MaxInputTokens *int `json:"max_input_tokens,omitempty"`
SupportsBatch *bool `json:"supports_batch,omitempty"`
// Chat Model 能力
SupportsStreaming *bool `json:"supports_streaming,omitempty"`
SupportsFunctions *bool `json:"supports_functions,omitempty"`
ContextWindow *int `json:"context_window,omitempty"`
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
// 通用能力
CostPer1KTokens *float64 `json:"cost_per_1k_tokens,omitempty"`
}
ModelCapabilities 模型能力参数
type ModelsService ¶
type ModelsService struct {
// contains filtered or unexported fields
}
ModelsService AI 模型管理服务
func (*ModelsService) Check ¶
func (s *ModelsService) Check(ctx context.Context, req *CheckModelRequest) (*CheckModelResponse, error)
Check 检查模型配置
func (*ModelsService) Create ¶
func (s *ModelsService) Create(ctx context.Context, req *CreateModelRequest) (*AIModel, error)
Create 创建 AI 模型
func (*ModelsService) Delete ¶
func (s *ModelsService) Delete(ctx context.Context, modelID string) error
Delete 删除模型
func (*ModelsService) List ¶
func (s *ModelsService) List(ctx context.Context, req *ListModelsRequest) (*ListModelsResponse, error)
List 列出 AI 模型
func (*ModelsService) ListProviderModels ¶
func (s *ModelsService) ListProviderModels(ctx context.Context, req *ListProviderModelsRequest) (interface{}, error)
ListProviderModels 获取供应商支持的模型列表
func (*ModelsService) Update ¶
func (s *ModelsService) Update(ctx context.Context, modelID string, req *UpdateModelRequest) (*AIModel, error)
Update 更新模型
func (*ModelsService) Upsert ¶
func (s *ModelsService) Upsert(ctx context.Context, req *UpsertModelRequest) (*UpsertModelResponse, error)
Upsert 根据 API Base 和 Model Name 创建或更新模型 如果找到匹配的模型则更新,否则创建新模型
type Option ¶
type Option func(*Client)
Option 客户端配置选项
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Option
WithTransport 设置自定义 Transport
type ProviderModel ¶
type ProviderModel struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Capabilities []string `json:"capabilities"`
}
ProviderModel 供应商模型
type QARequest ¶
type QARequest struct {
Query string `json:"query"`
DatasetID string `json:"dataset_id"`
TopK int `json:"top_k,omitempty"`
RetrievalMode string `json:"retrieval_mode,omitempty"` // full | smart
Stream bool `json:"stream,omitempty"`
SimilarityThreshold float64 `json:"similarity_threshold,omitempty"`
}
QARequest 问答请求
type QAResponse ¶
type QAResponse struct {
Answer string `json:"answer"`
Context []SearchResult `json:"context"`
}
QAResponse 问答响应
type ReindexResponse ¶ added in v0.2.2
type ReindexResponse struct {
Message string `json:"message"`
DocumentID string `json:"document_id"`
}
ReindexResponse 重新索引单个文档响应
type RetrieveRequest ¶
type RetrieveRequest struct {
Query string `json:"query"`
DatasetID string `json:"dataset_id"`
TopK int `json:"top_k,omitempty"`
RetrievalMode string `json:"retrieval_mode,omitempty"` // full | smart
SimilarityThreshold float64 `json:"similarity_threshold,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
ChatHistory []ChatMessage `json:"chat_history,omitempty"`
MaxChunksPerDoc int `json:"max_chunks_per_doc,omitempty"`
}
RetrieveRequest 召回请求
type SearchResponse ¶
type SearchResponse struct {
Query string `json:"query"`
Results []SearchResult `json:"results"`
Total int `json:"total"`
LatencyMs int64 `json:"latency_ms"`
}
SearchResponse 搜索响应
type SearchResult ¶
type SearchResult struct {
ChunkID string `json:"chunk_id"`
DocumentID string `json:"document_id"`
DocumentTitle string `json:"document_title"`
SectionTitle string `json:"section_title"`
Content string `json:"content"`
Score float64 `json:"score"`
Metadata map[string]interface{} `json:"metadata"`
Tags []string `json:"tags"`
Highlights []string `json:"highlights,omitempty"`
}
SearchResult 搜索结果
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
SearchService 搜索服务
func (*SearchService) Retrieve ¶
func (s *SearchService) Retrieve(ctx context.Context, req *RetrieveRequest) (*SearchResponse, error)
Search 执行搜索
type UpdateDatasetRequest ¶
type UpdateDatasetRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
DenseModelID *string `json:"dense_model_id,omitempty"`
SparseModelID *string `json:"sparse_model_id,omitempty"`
AnalysisModelID *string `json:"analysis_model_id,omitempty"`
RerankerModelID *string `json:"reranker_model_id,omitempty"`
VisionModelID *string `json:"vision_model_id,omitempty"`
Config *DatasetConfig `json:"config,omitempty"`
Status *string `json:"status,omitempty"`
}
UpdateDatasetRequest 更新数据集请求
type UpdateDocumentRequest ¶
type UpdateDocumentRequest struct {
DatasetID string `json:"-"`
DocumentID string `json:"-"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
}
UpdateDocumentRequest 更新文档请求
type UpdateModelRequest ¶
type UpdateModelRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Provider *string `json:"provider,omitempty"`
ModelName *string `json:"model_name,omitempty"`
Config *AIModelConfig `json:"config,omitempty"`
Capabilities *ModelCapabilities `json:"capabilities,omitempty"`
Status *string `json:"status,omitempty"`
IsDefault *bool `json:"is_default,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
}
UpdateModelRequest 更新模型请求
type UploadDocumentRequest ¶
type UploadDocumentRequest struct {
DatasetID string
DocumentID string
File io.Reader
Title string
Filename string
Tags []string
Metadata map[string]interface{}
// 是否提取文档内容的关键词,会在解析完成后异步通知结果
ExtractKeywords bool
// 是否仅提取文档内容的关键词,不会解析文档内容,用于只在给定文档内容中提取关键词的场景
KeywordsOnlyMode bool
}
UploadDocumentRequest 上传文档请求
type UploadDocumentResponse ¶
type UploadDocumentResponse struct {
DocumentID string `json:"document_id"`
Status string `json:"status"`
Message string `json:"message"`
Filename string `json:"filename"`
Title string `json:"title"`
Size int64 `json:"size"`
}
UploadDocumentResponse 上传文档响应
type UpsertModelRequest ¶
type UpsertModelRequest struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ModelType string `json:"model_type"`
Provider string `json:"provider"`
ModelName string `json:"model_name"`
Config AIModelConfig `json:"config"`
Capabilities ModelCapabilities `json:"capabilities,omitempty"`
IsDefault bool `json:"is_default,omitempty"`
IsActive bool `json:"is_active,omitempty"`
}
UpsertModelRequest 根据配置创建或更新模型请求
type UpsertModelResponse ¶
type UpsertModelResponse struct {
Action string `json:"action"` // "created" 或 "updated"
Model AIModel `json:"model"`
}
UpsertModelResponse Upsert 响应