Utils
Utility modules for gllm-datastore.
QueryFilter
Bases: BaseModel
Model for query filters.
Attributes:
| Name | Type | Description |
|---|---|---|
conditions |
dict[str, Any]
|
The conditions for filtering the query. |
Example
QueryFilter(conditions={"column1": "value1", "column2": "value2"})
QueryOptions
Bases: BaseModel
Model for query options.
Attributes:
| Name | Type | Description |
|---|---|---|
columns |
Sequence[str] | None
|
The columns to include in the query result. Defaults to None. |
fields |
Sequence[str] | None
|
The fields to include in the query result. Defaults to None. |
order_by |
str | None
|
The column to order the query result by. Defaults to None. |
order_desc |
bool
|
Whether to order the query result in descending order. Defaults to False. |
limit |
int | None
|
The maximum number of rows to return. Defaults to None. |
Example
QueryOptions(fields=["field1", "field2"], order_by="column1", order_desc=True, limit=10)
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 |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Chunk |
Chunk
|
The standardized Chunk object. |