utils

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfirmAction

func ConfirmAction(message string) bool

ConfirmAction prompts the user for confirmation

func CountMockCollections

func CountMockCollections(ctx context.Context, cfg *config.VectorDBConfig) (int, error)

CountMockCollections counts mock collections

func CountMockDocuments

func CountMockDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string) (int, error)

CountMockDocuments counts mock documents

func CountWeaviateCollections

func CountWeaviateCollections(ctx context.Context, cfg *config.VectorDBConfig) (int, error)

CountWeaviateCollections counts Weaviate collections

func CountWeaviateDocuments

func CountWeaviateDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string) (int, error)

CountWeaviateDocuments counts Weaviate documents

func CreateMockClient

func CreateMockClient(cfg *config.VectorDBConfig) *mock.Client

CreateMockClient creates a mock client from configuration

func CreateMockCollection

func CreateMockCollection(ctx context.Context, cfg *config.VectorDBConfig, collectionName, embeddingModel string, customFields []weaviate.FieldDefinition) error

CreateMockCollection creates a mock collection

func CreateMockDocument

func CreateMockDocument(ctx context.Context, cfg *config.VectorDBConfig, collectionName, filePath string, chunkSize int, imageCollection string, skipSmallImages bool, minImageSize int, batchSize int, reportPath string, reportMode string)

CreateMockDocument creates a mock document

func CreateWeaviateClient

func CreateWeaviateClient(cfg *config.VectorDBConfig) (*weaviate.Client, error)

CreateWeaviateClient creates a Weaviate client from configuration

func CreateWeaviateCollection

func CreateWeaviateCollection(ctx context.Context, cfg *config.VectorDBConfig, collectionName, embeddingModel string, customFields []weaviate.FieldDefinition) error

CreateWeaviateCollection creates a Weaviate collection with default schema

func CreateWeaviateCollectionFromConfigSchema added in v0.2.5

func CreateWeaviateCollectionFromConfigSchema(ctx context.Context, cfg *config.Config, dbConfig *config.VectorDBConfig, collectionName, schemaName, metadataMode string) error

CreateWeaviateCollectionFromConfigSchema creates a Weaviate collection from a named schema in config.yaml

func CreateWeaviateCollectionFromSchemaFile added in v0.2.4

func CreateWeaviateCollectionFromSchemaFile(ctx context.Context, cfg *config.VectorDBConfig, collectionName, schemaFilePath string) error

CreateWeaviateCollectionFromSchemaFile creates a Weaviate collection from a schema file

func CreateWeaviateDocument

func CreateWeaviateDocument(ctx context.Context, cfg *config.VectorDBConfig, collectionName, filePath string, chunkSize int, imageCollection string, skipSmallImages bool, minImageSize int, batchSize int, reportPath string, reportMode string) error

CreateWeaviateDocument creates a Weaviate document

func DeleteAllMockCollections

func DeleteAllMockCollections(ctx context.Context, cfg *config.VectorDBConfig)

DeleteAllMockCollections deletes all documents from all mock collections

func DeleteAllMockDocuments

func DeleteAllMockDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string)

DeleteAllMockDocuments deletes all mock documents in a collection

func DeleteAllWeaviateCollections

func DeleteAllWeaviateCollections(ctx context.Context, cfg *config.VectorDBConfig)

DeleteAllWeaviateCollections deletes all documents from all Weaviate collections

func DeleteAllWeaviateDocuments

func DeleteAllWeaviateDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string)

DeleteAllWeaviateDocuments deletes all Weaviate documents in a collection

func DeleteMockCollections

func DeleteMockCollections(ctx context.Context, cfg *config.VectorDBConfig, collectionNames []string) error

DeleteMockCollections deletes mock collections

func DeleteMockCollectionsByPattern

func DeleteMockCollectionsByPattern(ctx context.Context, cfg *config.VectorDBConfig, pattern string) error

DeleteMockCollectionsByPattern deletes mock collections by pattern

func DeleteMockDocuments

func DeleteMockDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, documentIDs []string, metadataFilters []string, virtual bool, pattern string, name string)

DeleteMockDocuments deletes mock documents

func DeleteWeaviateCollectionSchema

func DeleteWeaviateCollectionSchema(ctx context.Context, cfg *config.VectorDBConfig, collectionName string) error

DeleteWeaviateCollectionSchema deletes Weaviate collection schema

func DeleteWeaviateCollectionSchemasByPattern added in v0.2.6

func DeleteWeaviateCollectionSchemasByPattern(ctx context.Context, cfg *config.VectorDBConfig, pattern string) error

DeleteWeaviateCollectionSchemasByPattern deletes Weaviate collection schemas by pattern

func DeleteWeaviateCollections

func DeleteWeaviateCollections(ctx context.Context, cfg *config.VectorDBConfig, collectionNames []string) error

DeleteWeaviateCollections deletes Weaviate collections

func DeleteWeaviateCollectionsByPattern

func DeleteWeaviateCollectionsByPattern(ctx context.Context, cfg *config.VectorDBConfig, pattern string) error

DeleteWeaviateCollectionsByPattern deletes Weaviate collections by pattern

func DeleteWeaviateDocuments

func DeleteWeaviateDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, documentIDs []string, metadataFilters []string, virtual bool, pattern string, name string)

DeleteWeaviateDocuments deletes Weaviate documents

func DisplayQueryResults added in v0.2.8

func DisplayQueryResults(results []weaviate.QueryResult, collectionName, queryText string, noTruncate bool)

DisplayQueryResults displays semantic search results with styling

func DisplayRegularDocuments

func DisplayRegularDocuments(documents []weaviate.Document, collectionName string, showLong bool, shortLines int)

DisplayRegularDocuments displays regular documents with styling

func DisplayVirtualDocuments

func DisplayVirtualDocuments(documents []weaviate.Document, collectionName string, showLong bool, shortLines int, summary bool)

DisplayVirtualDocuments displays virtual documents with aggregation and styling

func ExportAsJSON added in v0.2.4

func ExportAsJSON(export *CollectionExport) (string, error)

ExportAsJSON exports collection data as JSON

func ExportAsYAML added in v0.2.4

func ExportAsYAML(export *CollectionExport) (string, error)

ExportAsYAML exports collection data as YAML with compact formatting

func FormatCreationError added in v0.2.10

func FormatCreationError(resourceType string, err error) string

FormatCreationError formats collection/document creation errors

func FormatDeletionError added in v0.2.10

func FormatDeletionError(resourceType string, err error) string

FormatDeletionError formats collection/document deletion errors

func FormatQueryError added in v0.2.10

func FormatQueryError(err error) string

FormatQueryError formats query errors

func GenerateDefaultReportPath added in v0.2.13

func GenerateDefaultReportPath(filePath string) string

GenerateDefaultReportPath generates a default CSV report path from input file

func GetStandaloneDocumentKey

func GetStandaloneDocumentKey(doc weaviate.Document) string

GetStandaloneDocumentKey extracts a unique key for standalone documents

func GetStyledEmoji

func GetStyledEmoji(emoji string) string

GetStyledEmoji returns a styled emoji string

func GetStyledKeyDimmed

func GetStyledKeyDimmed(key string) string

GetStyledKeyDimmed returns a dimmed styled key string

func GetStyledKeyProminent

func GetStyledKeyProminent(key string) string

GetStyledKeyProminent returns a styled key string

func GetStyledNumber

func GetStyledNumber(num interface{}) string

GetStyledNumber returns a styled number string

func GetStyledValueDimmed

func GetStyledValueDimmed(value string) string

GetStyledValueDimmed returns a dimmed styled value string

func GetValueType

func GetValueType(value interface{}) string

GetValueType returns a string representation of the Go type

func IsImageContent

func IsImageContent(content string) bool

IsImageContent checks if content looks like base64 image data

func IsImageDocument

func IsImageDocument(metadata map[string]interface{}) bool

IsImageDocument checks if metadata indicates this is an image document

func IsImageVirtualDocument

func IsImageVirtualDocument(vdoc VirtualDocument) bool

IsImageVirtualDocument checks if a virtual document represents an image collection

func ListMockCollections

func ListMockCollections(ctx context.Context, cfg *config.VectorDBConfig, limit int, virtual bool, jsonOutput bool)

ListMockCollections lists mock collections

func ListMockDocuments

func ListMockDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, limit int, showLong bool, shortLines int, virtual bool, summary bool)

ListMockDocuments lists mock documents

func ListWeaviateCollections

func ListWeaviateCollections(ctx context.Context, cfg *config.VectorDBConfig, limit int, virtual bool, jsonOutput bool)

ListWeaviateCollections lists Weaviate collections

func ListWeaviateDocuments

func ListWeaviateDocuments(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, limit int, showLong bool, shortLines int, virtual bool, summary bool)

ListWeaviateDocuments lists Weaviate documents

func LoadConfigWithOverrides

func LoadConfigWithOverrides() (*config.Config, error)

LoadConfigWithOverrides loads configuration with command-line overrides

func ParseFieldDefinitions

func ParseFieldDefinitions(fieldsStr string) ([]weaviate.FieldDefinition, error)

ParseFieldDefinitions parses field definitions from a string

func PrintError

func PrintError(message string)

PrintError prints an error message in red

func PrintHeader

func PrintHeader(message string)

PrintHeader prints a header message in bold cyan

func PrintInfo

func PrintInfo(message string)

PrintInfo prints an info message in blue

func PrintStyledEmoji

func PrintStyledEmoji(emoji string)

PrintStyledEmoji prints a styled emoji

func PrintStyledFilename

func PrintStyledFilename(filename string)

PrintStyledFilename prints a styled filename

func PrintStyledID

func PrintStyledID(id string)

PrintStyledID prints a styled ID

func PrintStyledKey

func PrintStyledKey(key string)

PrintStyledKey prints a styled key

func PrintStyledKeyNumberProminentWithEmoji

func PrintStyledKeyNumberProminentWithEmoji(key string, num int, emoji string)

PrintStyledKeyNumberProminentWithEmoji prints a prominent key-number pair with emoji

func PrintStyledKeyProminent

func PrintStyledKeyProminent(key string)

PrintStyledKeyProminent prints a prominent styled key

func PrintStyledKeyValueDimmed

func PrintStyledKeyValueDimmed(key, value string)

PrintStyledKeyValueDimmed prints a dimmed key-value pair

func PrintStyledKeyValueProminentWithEmoji

func PrintStyledKeyValueProminentWithEmoji(key, value, emoji string)

PrintStyledKeyValueProminentWithEmoji prints a prominent key-value pair with emoji

func PrintStyledNumber

func PrintStyledNumber(num int)

PrintStyledNumber prints a styled number

func PrintStyledValue

func PrintStyledValue(value string)

PrintStyledValue prints a styled value

func PrintStyledValueDimmed

func PrintStyledValueDimmed(value string)

PrintStyledValueDimmed prints a dimmed styled value

func PrintSuccess

func PrintSuccess(message string)

PrintSuccess prints a success message in green

func PrintWarning

func PrintWarning(message string)

PrintWarning prints a warning message in yellow

func QueryMockCollection added in v0.2.8

func QueryMockCollection(ctx context.Context, cfg *config.VectorDBConfig, collectionName, queryText string, options weaviate.QueryOptions)

QueryMockCollection performs semantic search on a mock collection

func QueryWeaviateCollection added in v0.2.8

func QueryWeaviateCollection(ctx context.Context, cfg *config.VectorDBConfig, collectionName, queryText string, options weaviate.QueryOptions)

QueryWeaviateCollection performs semantic search on a Weaviate collection

func ShowCollectionMetadata added in v0.2.4

func ShowCollectionMetadata(ctx context.Context, client *weaviate.Client, collectionName string, expandMetadata bool)

ShowCollectionMetadata displays collection metadata with styling

func ShowCollectionSchema added in v0.2.4

func ShowCollectionSchema(ctx context.Context, client *weaviate.Client, collectionName string)

ShowCollectionSchema displays the collection schema with styling

func ShowDocumentMetadata

func ShowDocumentMetadata(doc weaviate.Document, collectionName string)

ShowDocumentMetadata shows expanded metadata for a document

func ShowDocumentSchema

func ShowDocumentSchema(doc weaviate.Document, collectionName string)

ShowDocumentSchema shows the schema of a Weaviate document

func ShowMockCollection

func ShowMockCollection(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, shortLines int, noTruncate bool, verbose bool, showSchema bool, showMetadata bool, expandMetadata bool, outputYAML bool, outputJSON bool, yamlFile string, jsonFile string, compact bool)

ShowMockCollection shows mock collection details

func ShowMockDocument

func ShowMockDocument(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, documentIDs []string, showLong bool, shortLines int, metadataFilters []string, name string, showSchema bool, expandMetadata bool)

ShowMockDocument shows mock document details

func ShowWeaviateCollection

func ShowWeaviateCollection(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, shortLines int, noTruncate bool, verbose bool, showSchema bool, showMetadata bool, expandMetadata bool, outputYAML bool, outputJSON bool, yamlFile string, jsonFile string, compact bool)

ShowWeaviateCollection shows Weaviate collection details

func ShowWeaviateDocument

func ShowWeaviateDocument(ctx context.Context, cfg *config.VectorDBConfig, collectionName string, documentIDs []string, showLong bool, shortLines int, metadataFilters []string, name string, showSchema bool, expandMetadata bool)

ShowWeaviateDocument shows Weaviate document details

func SimplifyError added in v0.2.10

func SimplifyError(err error) string

SimplifyError takes a verbose error message and makes it more human-friendly

func SmartTruncate

func SmartTruncate(value, key string, shortLines int) string

SmartTruncate intelligently truncates content based on key type

func TruncateMetadataValue

func TruncateMetadataValue(value interface{}, maxLength int) string

TruncateMetadataValue truncates a metadata value to a maximum length

func TruncateStringByLines

func TruncateStringByLines(text string, maxLines int) string

TruncateStringByLines truncates text to a maximum number of lines

func UpdateMockDocument added in v0.2.9

func UpdateMockDocument(ctx context.Context, cfg *config.VectorDBConfig, collectionName, documentID, docName string, metadataFilter []string, content, filePath string, metadata []string)

UpdateMockDocument updates a document in the mock database

func UpdateWeaviateDocument added in v0.2.9

func UpdateWeaviateDocument(ctx context.Context, cfg *config.VectorDBConfig, collectionName, documentID, docName string, metadataFilter []string, content, filePath string, metadata []string) error

UpdateWeaviateDocument updates an existing document in Weaviate

func WriteProcessingReport added in v0.2.13

func WriteProcessingReport(report *ProcessingReport) error

WriteProcessingReport writes or appends a processing report to CSV

func WriteToFile added in v0.2.4

func WriteToFile(filePath string, content string) error

WriteToFile writes content to a file

Types

type ChunkReport added in v0.2.13

type ChunkReport struct {
	ChunkNumber int
	Success     bool
	Error       string
	SizeBytes   int
}

ChunkReport tracks a single text chunk processing result

type CollectionExport added in v0.2.4

type CollectionExport struct {
	Name           string                       `json:"name" yaml:"name"`
	Schema         *weaviate.CollectionSchema   `json:"schema,omitempty" yaml:"schema,omitempty"`
	SchemaMetadata map[string]interface{}       `json:"schema_metadata,omitempty" yaml:"metadata,omitempty"`
	Metadata       map[string]MetadataFieldInfo `json:"metadata,omitempty" yaml:"runtime_metadata,omitempty"`
}

CollectionExport represents the combined schema and metadata for export

func ExportCollectionSchemaAndMetadata added in v0.2.4

func ExportCollectionSchemaAndMetadata(ctx context.Context, client *weaviate.Client, collectionName string, includeMetadata bool, expandMetadata bool, compact bool) (*CollectionExport, error)

ExportCollectionSchemaAndMetadata exports collection schema and metadata

func LoadSchemaFromJSONFile added in v0.2.4

func LoadSchemaFromJSONFile(filePath string) (*CollectionExport, error)

LoadSchemaFromJSONFile loads a collection schema from a JSON file

func LoadSchemaFromYAMLFile added in v0.2.4

func LoadSchemaFromYAMLFile(filePath string) (*CollectionExport, error)

LoadSchemaFromYAMLFile loads a collection schema from a YAML file

type ImageGroup added in v0.2.13

type ImageGroup struct {
	SourcePDF   string
	DisplayName string
	TotalCount  int
	TotalChunks int
	Images      []VirtualDocument
	MinPage     int
	MaxPage     int
	IsImage     bool // true for images, false for regular documents
}

ImageGroup represents a group of images or documents from the same source

type ImageReport added in v0.2.13

type ImageReport struct {
	ImageNumber int
	Filename    string
	Success     bool
	Error       string
	SizeBytes   int
	OCRWarnings []string
}

ImageReport tracks a single image processing result

type MetadataFieldInfo added in v0.2.4

type MetadataFieldInfo struct {
	Type        string                 `json:"type" yaml:"type"`
	Occurrences int                    `json:"occurrences,omitempty" yaml:"occurrences,omitempty"`
	Sample      interface{}            `json:"sample,omitempty" yaml:"sample,omitempty"`
	JSONSchema  map[string]interface{} `json:"json_schema,omitempty" yaml:"json_schema,omitempty"`
}

MetadataFieldInfo represents metadata field information

type ProcessingReport added in v0.2.13

type ProcessingReport struct {
	FilePath   string
	Collection string
	Timestamp  time.Time
	TextChunks []ChunkReport
	Images     []ImageReport
	ReportPath string
	ReportMode string
}

ProcessingReport tracks processing results for CSV reporting

type VirtualDocument

type VirtualDocument struct {
	OriginalFilename string
	TotalChunks      int
	Chunks           []weaviate.Document
	Metadata         map[string]interface{}
}

VirtualDocument represents a virtual document structure

func AggregateDocumentsByOriginal

func AggregateDocumentsByOriginal(documents []weaviate.Document) []VirtualDocument

AggregateDocumentsByOriginal aggregates documents by their original filename/source

type WeaviateError added in v0.2.10

type WeaviateError struct {
	Error []struct {
		Message string `json:"message"`
	} `json:"error"`
}

WeaviateError represents a structured error from Weaviate

Jump to

Keyboard shortcuts

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