Documentation
¶
Overview ¶
TODO: this is a duplicate of LocalRAG/pkg/client
Index ¶
- type Client
- func (c *Client) AddSource(collection, url string, updateIntervalMinutes int) error
- func (c *Client) CreateCollection(name string) error
- func (c *Client) DeleteEntry(collection, entry string) ([]string, error)
- func (c *Client) GetEntryContent(collection, entry string) (content string, chunkCount int, err error)
- func (c *Client) ListCollections() ([]string, error)
- func (c *Client) ListEntries(collection string) ([]string, error)
- func (c *Client) ListSources(collection string) ([]SourceInfo, error)
- func (c *Client) RemoveSource(collection, url string) error
- func (c *Client) Reset(collection string) error
- func (c *Client) Search(collection, query string, maxResults int) ([]Result, error)
- func (c *Client) Store(collection, filePath string) (string, error)
- type EntryChunk
- type Result
- type SourceInfo
- type WrappedClient
- func (c *WrappedClient) Collection() string
- func (c *WrappedClient) Count() int
- func (c *WrappedClient) GetEntryContent(entry string) (content string, chunkCount int, err error)
- func (c *WrappedClient) Reset() error
- func (c *WrappedClient) Search(s string, similarity int) ([]string, error)
- func (c *WrappedClient) Store(s string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a client for the RAG API
func (*Client) CreateCollection ¶
CreateCollection creates a new collection
func (*Client) DeleteEntry ¶
DeleteEntry deletes an entry in a collection
func (*Client) GetEntryContent ¶
func (c *Client) GetEntryContent(collection, entry string) (content string, chunkCount int, err error)
GetEntryContent returns the full file content (no chunk overlap) and the number of chunks for the entry.
func (*Client) ListCollections ¶
ListCollections lists all collections
func (*Client) ListEntries ¶
ListEntries lists all entries in a collection
func (*Client) ListSources ¶
func (c *Client) ListSources(collection string) ([]SourceInfo, error)
ListSources returns external sources for a collection.
func (*Client) RemoveSource ¶
RemoveSource removes an external source from a collection.
type EntryChunk ¶
type EntryChunk struct {
ID string `json:"id"`
Content string `json:"content"`
Metadata map[string]string `json:"metadata"`
}
EntryChunk represents a single chunk (legacy; GetEntryContent now returns full file content).
type Result ¶
type Result struct {
ID string
Metadata map[string]string
Embedding []float32
Content string
// The cosine similarity between the query and the document.
// The higher the value, the more similar the document is to the query.
// The value is in the range [-1, 1].
Similarity float32
}
Result represents a single result from a query.
type SourceInfo ¶
type SourceInfo struct {
URL string `json:"url"`
UpdateInterval int `json:"update_interval"` // minutes
LastUpdate string `json:"last_update"` // RFC3339
}
SourceInfo represents an external source for a collection (LocalRecall API contract).
type WrappedClient ¶
type WrappedClient struct {
*Client
// contains filtered or unexported fields
}
func NewWrappedClient ¶
func NewWrappedClient(baseURL, apiKey, c string) *WrappedClient
func (*WrappedClient) Collection ¶
func (c *WrappedClient) Collection() string
Collection returns the collection name for this client.
func (*WrappedClient) Count ¶
func (c *WrappedClient) Count() int
func (*WrappedClient) GetEntryContent ¶
func (c *WrappedClient) GetEntryContent(entry string) (content string, chunkCount int, err error)
GetEntryContent returns the full file content (no chunk overlap) and the number of chunks for the entry.
func (*WrappedClient) Reset ¶
func (c *WrappedClient) Reset() error
func (*WrappedClient) Search ¶
func (c *WrappedClient) Search(s string, similarity int) ([]string, error)
func (*WrappedClient) Store ¶
func (c *WrappedClient) Store(s string) error