collections

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateDocument

func ValidateDocument(path string) error

ValidateDocument checks if a document is valid for upload

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles xAI Collections Management API operations

func NewClient

func NewClient(managementAPIKey string) *Client

NewClient creates a new Collections API client

func (*Client) CreateCollection

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

CreateCollection creates a new collection

func (*Client) DeleteCollection

func (c *Client) DeleteCollection(collectionID string) error

DeleteCollection deletes a collection

func (*Client) ListCollections

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

ListCollections lists all collections

func (*Client) UploadDocument

func (c *Client) UploadDocument(collectionID, name string, data []byte, contentType string) (string, error)

UploadDocument uploads a document to a collection

type Collection

type Collection struct {
	ID            string    `json:"collection_id"`
	Name          string    `json:"collection_name"`
	Description   string    `json:"description"`
	CreatedAt     time.Time `json:"created_at"`
	DocumentCount int       `json:"documents_count,omitempty"`
	TotalFileSize string    `json:"total_file_size,omitempty"`
}

Collection represents an xAI collection

type CollectionsError

type CollectionsError struct {
	StatusCode int
	Message    string
	RequestID  string
}

CollectionsError represents an API error

func (*CollectionsError) Error

func (e *CollectionsError) Error() string

type Document

type Document struct {
	FileID      string    `json:"file_id"`
	Name        string    `json:"name"`
	ContentType string    `json:"content_type"`
	Size        int64     `json:"size"`
	UploadedAt  time.Time `json:"uploaded_at"`
}

Document represents a document in a collection

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager provides high-level collections management

func NewManager

func NewManager(client *Client, cfg *config.Config) *Manager

NewManager creates a new collections manager

func (*Manager) DisableCollection

func (m *Manager) DisableCollection(collectionID string) error

DisableCollection removes a collection from the active set

func (*Manager) EnableCollection

func (m *Manager) EnableCollection(collectionID string) error

EnableCollection adds a collection to the active set

func (*Manager) GetActiveCollectionIDs

func (m *Manager) GetActiveCollectionIDs() map[string]bool

GetActiveCollectionIDs returns a map of active collection IDs for quick lookup

func (*Manager) GetActiveCollections

func (m *Manager) GetActiveCollections() []string

GetActiveCollections returns the list of active collection IDs

func (*Manager) ListCollections

func (m *Manager) ListCollections() ([]Collection, error)

ListCollections fetches all collections from the API

func (*Manager) SaveConfig

func (m *Manager) SaveConfig() error

SaveConfig saves the configuration to disk

Jump to

Keyboard shortcuts

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