Skip to content

Utils

Utility modules for gllm-datastore.

convert_ttl_to_seconds(ttl)

Convert TTL (time-to-live) string with time units to seconds.

Supported units: s (seconds), m (minutes), h (hours), d (days), w (weeks), y (years).

Examples:

"2m" -> 120 (2 minutes in seconds) "1h" -> 3600 (1 hour in seconds) "1y" -> 31536000 (1 year in seconds) 300 -> 300 (numeric input returned as is)

Parameters:

Name Type Description Default
ttl str | int

Time to live value with optional unit suffix (e.g., "2m", "1h", "1y") or numeric value in seconds.

required

Returns:

Name Type Description
int int

TTL converted to seconds.

Raises:

Type Description
ValueError

If the input format is invalid.

from_langchain(doc, score=None)

Create a standardized Chunk from a LangChain Document.

Parameters:

Name Type Description Default
doc Document

The document to create a Chunk from.

required
score float | None

The score to assign to the Chunk. Defaults to None, in which case it will attempt to get the score from the score metadata.

None

Returns:

Name Type Description
Chunk Chunk

The standardized Chunk object.