localrag

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

TODO: this is a duplicate of LocalRAG/pkg/client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL string
	APIKey  string
}

Client is a client for the RAG API

func NewClient

func NewClient(baseURL, apiKey string) *Client

NewClient creates a new RAG API client

func (*Client) AddSource

func (c *Client) AddSource(collection, url string, updateIntervalMinutes int) error

AddSource registers an external source for a collection.

func (*Client) CreateCollection

func (c *Client) CreateCollection(name string) error

CreateCollection creates a new collection

func (*Client) DeleteEntry

func (c *Client) DeleteEntry(collection, entry string) ([]string, error)

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

func (c *Client) ListCollections() ([]string, error)

ListCollections lists all collections

func (*Client) ListEntries

func (c *Client) ListEntries(collection string) ([]string, error)

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

func (c *Client) RemoveSource(collection, url string) error

RemoveSource removes an external source from a collection.

func (*Client) Reset

func (c *Client) Reset(collection string) error

Reset resets a collection

func (*Client) Search

func (c *Client) Search(collection, query string, maxResults int) ([]Result, error)

Search searches a collection

func (*Client) Store

func (c *Client) Store(collection, filePath string) (string, error)

Store uploads a file to a collection and returns the assigned entry key.

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

Jump to

Keyboard shortcuts

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