yao/kb/api/types.go
Max 704c0331b1 Enhance Assistant stream functionality and remove history handling
- Added permission validation in the Assistant's Stream method to ensure user authorization before processing input messages.
- Introduced conversation initialization within the Stream method to prepare the context for chat interactions.
- Removed the history.go file, which previously contained a placeholder method for handling chat history, streamlining the Assistant's codebase.
- Updated the Knowledge Base API integration in collection management, ensuring all collection operations utilize the new API structure for improved consistency and error handling.
2025-12-08 10:28:26 +08:00

73 lines
3.1 KiB
Go

package api
import (
"github.com/yaoapp/gou/graphrag/types"
"github.com/yaoapp/gou/model"
)
// CreateCollectionParams represents the parameters for creating a collection
type CreateCollectionParams struct {
ID string `json:"id"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
EmbeddingProviderID string `json:"embedding_provider_id"`
EmbeddingOptionID string `json:"embedding_option_id"`
Locale string `json:"locale,omitempty"`
Config *types.CreateCollectionOptions `json:"config,omitempty"`
AuthScope map[string]interface{} `json:"-"` // Internal: authentication scope fields
}
// CreateCollectionResult represents the result of creating a collection
type CreateCollectionResult struct {
CollectionID string `json:"collection_id"`
Message string `json:"message"`
}
// RemoveCollectionResult represents the result of removing a collection
type RemoveCollectionResult struct {
CollectionID string `json:"collection_id"`
Removed bool `json:"removed"`
DocumentsRemoved int `json:"documents_removed"`
Message string `json:"message"`
}
// CollectionExistsResult represents the result of checking if a collection exists
type CollectionExistsResult struct {
CollectionID string `json:"collection_id"`
Exists bool `json:"exists"`
}
// ListCollectionsFilter represents the filter options for listing collections
type ListCollectionsFilter struct {
Page int `json:"page"`
PageSize int `json:"pagesize"`
Keywords string `json:"keywords,omitempty"`
Status []string `json:"status,omitempty"`
System *bool `json:"system,omitempty"`
EmbeddingProviderID string `json:"embedding_provider_id,omitempty"`
Select []interface{} `json:"select,omitempty"`
Sort []model.QueryOrder `json:"sort,omitempty"`
AuthFilters []model.QueryWhere `json:"-"` // Internal: authentication filters
}
// ListCollectionsResult represents the result of listing collections
type ListCollectionsResult struct {
Data []map[string]interface{} `json:"data"`
Next int `json:"next"`
Prev int `json:"prev"`
Page int `json:"page"`
PageSize int `json:"pagesize"`
Total int `json:"total"`
PageCnt int `json:"pagecnt"`
}
// UpdateMetadataParams represents the parameters for updating collection metadata
type UpdateMetadataParams struct {
Metadata map[string]interface{} `json:"metadata"`
AuthScope map[string]interface{} `json:"-"` // Internal: authentication scope fields for update
}
// UpdateMetadataResult represents the result of updating collection metadata
type UpdateMetadataResult struct {
CollectionID string `json:"collection_id"`
Message string `json:"message"`
}