Files
Ettore Di Giacinto 07caa0b95d Adapt client too
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-03-21 00:46:41 +00:00

56 lines
2.0 KiB
Go

package collections
import (
"io"
"time"
)
// SearchResult is a single search result (content + metadata) for API responses.
type SearchResult struct {
Content string `json:"content"`
Metadata map[string]string `json:"metadata,omitempty"`
ID string `json:"id,omitempty"`
Similarity float32 `json:"similarity,omitempty"`
}
// SourceInfo is a single external source for a collection.
type SourceInfo struct {
URL string `json:"url"`
UpdateInterval int `json:"update_interval"` // minutes
LastUpdate time.Time `json:"last_update"`
}
// Backend is the interface used by REST handlers for collection operations.
// It is implemented by in-process state (embedded) or by an HTTP client.
type Backend interface {
ListCollections() ([]string, error)
CreateCollection(name string) error
Upload(collection, filename string, fileBody io.Reader) (string, error)
ListEntries(collection string) ([]string, error)
GetEntryContent(collection, entry string) (content string, chunkCount int, err error)
Search(collection, query string, maxResults int) ([]SearchResult, error)
Reset(collection string) error
DeleteEntry(collection, entry string) (remainingEntries []string, err error)
AddSource(collection, url string, intervalMin int) error
RemoveSource(collection, url string) error
ListSources(collection string) ([]SourceInfo, error)
EntryExists(collection, entry string) bool
// GetEntryFilePath returns the filesystem path of the stored file for the
// given entry. This is used to serve the original uploaded binary file.
GetEntryFilePath(collection, entry string) (string, error)
}
// Config holds the configuration for the in-process collections backend.
type Config struct {
LLMAPIURL string
LLMAPIKey string
LLMModel string
CollectionDBPath string
FileAssets string
VectorEngine string
EmbeddingModel string
MaxChunkingSize int
ChunkOverlap int
DatabaseURL string
}