api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandHome

func ExpandHome(path string) string

ExpandHome expands a leading ~ to the user's home directory.

Types

type APIError

type APIError struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Status  string `json:"status"`
	} `json:"error"`
}

APIError represents an error response from the API.

type ChunkingConfig

type ChunkingConfig struct {
	WhiteSpaceConfig *WhiteSpaceConfig `json:"whiteSpaceConfig,omitempty"`
}

ChunkingConfig configures how documents are chunked.

type Client

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

Client is the HTTP client for the Gemini File Search API.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new API client with the given API key.

func (*Client) CreateStore

func (c *Client) CreateStore(ctx context.Context, displayName string) (*FileSearchStore, error)

CreateStore creates a new FileSearchStore.

func (*Client) DeleteDocument

func (c *Client) DeleteDocument(ctx context.Context, docName string, force bool) error

DeleteDocument deletes a document from a FileSearchStore.

func (*Client) DeleteStore

func (c *Client) DeleteStore(ctx context.Context, name string, force bool) error

DeleteStore deletes a FileSearchStore.

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, docName string) (*Document, error)

GetDocument retrieves a specific document.

func (*Client) GetOperation

func (c *Client) GetOperation(ctx context.Context, opName string) (*Operation, error)

GetOperation retrieves the status of a long-running operation.

func (*Client) GetStore

func (c *Client) GetStore(ctx context.Context, name string) (*FileSearchStore, error)

GetStore retrieves a specific FileSearchStore.

func (*Client) ListDocuments

func (c *Client) ListDocuments(ctx context.Context, storeName string, pageSize int, pageToken string) (*ListDocumentsResponse, error)

ListDocuments lists documents in a FileSearchStore.

func (*Client) ListStores

func (c *Client) ListStores(ctx context.Context, pageSize int, pageToken string) (*ListStoresResponse, error)

ListStores lists all FileSearchStores with pagination.

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, storeName, filePath string, config *UploadConfig) (*Operation, error)

UploadFile uploads a file to a FileSearchStore.

type CreateStoreRequest

type CreateStoreRequest struct {
	DisplayName string `json:"displayName,omitempty"`
}

CreateStoreRequest is the request body for creating a store.

type CustomMetadata

type CustomMetadata struct {
	Key          string   `json:"key"`
	StringValue  *string  `json:"stringValue,omitempty"`
	NumericValue *float64 `json:"numericValue,omitempty"`
}

CustomMetadata is a key-value pair attached to a document.

type Document

type Document struct {
	Name           string           `json:"name"`
	DisplayName    string           `json:"displayName,omitempty"`
	CustomMetadata []CustomMetadata `json:"customMetadata,omitempty"`
	CreateTime     string           `json:"createTime,omitempty"`
	UpdateTime     string           `json:"updateTime,omitempty"`
	State          string           `json:"state,omitempty"`
	SizeBytes      int64            `json:"sizeBytes,omitempty,string"`
	MimeType       string           `json:"mimeType,omitempty"`
}

Document represents a document within a FileSearchStore.

type FileSearchStore

type FileSearchStore struct {
	Name                  string `json:"name"`
	DisplayName           string `json:"displayName,omitempty"`
	CreateTime            string `json:"createTime,omitempty"`
	UpdateTime            string `json:"updateTime,omitempty"`
	ActiveDocumentsCount  int64  `json:"activeDocumentsCount,omitempty,string"`
	PendingDocumentsCount int64  `json:"pendingDocumentsCount,omitempty,string"`
	FailedDocumentsCount  int64  `json:"failedDocumentsCount,omitempty,string"`
	SizeBytes             int64  `json:"sizeBytes,omitempty,string"`
}

FileSearchStore represents a Google Gemini File Search store.

type ListDocumentsResponse

type ListDocumentsResponse struct {
	Documents     []Document `json:"documents"`
	NextPageToken string     `json:"nextPageToken,omitempty"`
}

ListDocumentsResponse is the response for listing documents.

type ListStoresResponse

type ListStoresResponse struct {
	FileSearchStores []FileSearchStore `json:"fileSearchStores"`
	NextPageToken    string            `json:"nextPageToken,omitempty"`
}

ListStoresResponse is the response for listing file search stores.

type Operation

type Operation struct {
	Name     string          `json:"name"`
	Metadata json.RawMessage `json:"metadata,omitempty"`
	Done     bool            `json:"done"`
	Error    *Status         `json:"error,omitempty"`
	Response json.RawMessage `json:"response,omitempty"`
}

Operation represents a long-running operation.

type Status

type Status struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Status represents an error status from the API.

type UploadConfig

type UploadConfig struct {
	DisplayName    string           `json:"displayName,omitempty"`
	CustomMetadata []CustomMetadata `json:"customMetadata,omitempty"`
	ChunkingConfig *ChunkingConfig  `json:"chunkingConfig,omitempty"`
}

UploadConfig holds configuration for file uploads.

type WhiteSpaceConfig

type WhiteSpaceConfig struct {
	MaxTokensPerChunk int `json:"maxTokensPerChunk,omitempty"`
	MaxOverlapTokens  int `json:"maxOverlapTokens,omitempty"`
}

WhiteSpaceConfig configures whitespace-based chunking.

Jump to

Keyboard shortcuts

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