localvectordb_server.utils package

Shared utilities for LocalVectorDB server.

localvectordb_server.utils.parse_metadata_schema(schema_data: Dict[str, Any]) Dict[str, MetadataField]

Parse metadata schema from configuration data with validation.

This is the canonical implementation for parsing metadata schema configurations across the LocalVectorDB server. It handles both simple string type specifications and full field configuration dictionaries.

Parameters:

schema_data (Dict[str, Any]) – The schema data to parse. Can be: - Empty dict for no schema - Dict mapping field names to type strings (e.g., {“title”: “text”}) - Dict mapping field names to configuration dicts (e.g., {“title”: {“type”: “text”, “indexed”: true}})

Returns:

Parsed metadata schema with validated fields

Return type:

Dict[str, MetadataField]

Raises:

ValidationError – If the schema data is invalid or contains unsafe field names

Examples

Simple string types: >>> parse_metadata_schema({“title”: “text”, “created_at”: “date”})

Full configuration: >>> parse_metadata_schema({ … “title”: {“type”: “text”, “indexed”: True, “required”: False}, … “score”: {“type”: “real”, “indexed”: False, “required”: True} … })

localvectordb_server.utils.check_ollama_service(base_url: str | None = None, timeout: float = 5.0, retries: int = 3) bool

Check if Ollama service is running and responding.

Parameters:
  • base_url (Optional[str]) – Ollama server URL. Defaults to the OLLAMA_URL environment variable or http://127.0.0.1:11434. (127.0.0.1 rather than localhost: on Windows, “localhost” resolves to ::1 first and stalls ~2.5s per request because Ollama only listens on IPv4.)

  • timeout (float) – Per-request timeout in seconds.

  • retries (int) – Number of attempts before giving up.

Returns:

True if service is running, False otherwise

Return type:

bool

localvectordb_server.utils.check_ollama_installation() str | None

Check if Ollama is installed and available in the system path.

Returns:

Version string if Ollama is installed, None otherwise

Return type:

Optional[str]

Raises:

OllamaNotFoundError – If Ollama is not installed or not accessible

Submodules