Skip to main content

Module utils

Module utils 

Source
Expand description

Utility functions for the Memvid CLI

Constants§

FREE_TIER_MAX_FILE_SIZE
Free tier file size limit: 50 MB Files larger than this require a paid plan with API key authentication With –no-raw default, 50 MB fits ~700 small documents or ~4 large PDFs
MIN_FILE_SIZE
Minimum file size: 10 MB Ensures memory files have reasonable capacity for basic usage

Functions§

apply_lock_cli
Apply lock CLI settings to a memory instance
autodetect_memory_file
Auto-detect a memory file in the current directory
ensure_api_key_for_large_file
Check if a file exceeds the free tier limit and require API key if so
ensure_capacity_with_api_key
Check total memory size against plan capacity limit Called before operations that would increase memory size
ensure_cli_mutation_allowed
Ensure that CLI mutations are allowed for the given memory
ensure_feature_access
Check if the current plan allows a feature
format_bytes
Format bytes in a human-readable format (B, KB, MB, GB, TB)
format_percent
Format a percentage value for display
format_timestamp
Format a Unix timestamp to ISO 8601 string
format_timestamp_ms
Format milliseconds as HH:MM:SS.mmm
frame_status_str
Convert frame status to string representation
get_effective_capacity
Get the effective capacity limit for the current user
looks_like_memory
Check if a string looks like a memory file path
looks_like_memory_path
Check if a path looks like a memory file
open_read_only_mem
Open a memory file in read-only mode
owner_hint_to_json
Convert lock owner hint to JSON format
parse_date_boundary
Parse a date boundary string (YYYY-MM-DD)
parse_size
Parse a size string (e.g., “6MB”, “1.5 GB”) into bytes
parse_timecode
Parse a timecode string (HH:MM:SS or MM:SS or SS) into milliseconds
parse_vector
Parse a comma-separated vector string into f32 values
read_embedding
Read an embedding vector from a file.
read_payload
Read payload bytes from a file or stdin
require_active_plan
Check if the user’s plan allows write/query operations
round_percent
Round a percentage value to one decimal place
select_frame
Select a frame by ID or URI
yes_no
Convert boolean to “yes” or “no” string