DynamicQueries
DynamicQueries(model: rai.Model, *)Queries provider that lets agents author ad-hoc queries against a PyRel model.
Discovery returns a queryable-schema view derived from
schema. At runtime the agent
constructs and executes queries directly — the deployer only wires up
the model.
Errors raised during validation or execution arrive as a structured
envelope (see DynamicQuerySpecError) so the agent can
self-correct on retry without a round-trip to a human.
PRIVATE PREVIEW: ships under QUERY (preview-gated).
Dynamic queries are intentionally a small-result, exploratory surface
that complements rather than replaces catalog queries — narrow filters,
counts, and simple aggregations.
Parameters
Section titled “Parameters”
(modelrelationalai.semantics.Model) - The model to query against. Its queryable schema (viaschema) is what the agent sees at discovery time.
Methods
Section titled “Methods”.get_available_queries()
Section titled “.get_available_queries()”DynamicQueries.get_available_queries() -> dictReturn queryable-schema metadata and instructions for dynamic queries.
Returns:
dict- Dict with"query_mode","queries"(single entry for the reserved id),"schema","spec_format", and"query_instructions"keys.
.explain()
Section titled “.explain()”DynamicQueries.explain(query_id: str) -> Optional[str]Return the full dynamic-mode reference when query_id is "dynamic".
Bundles the instructions and the per-model queryable schema. This is the content the agent needs to author a valid dynamic query spec for this model.
Parameters:
(query_idstr) - Must be"dynamic"for this provider.
Returns:
str or None- Instructions plus the queryable schema as a single string, orNoneifquery_idis anything other than"dynamic".
.execute()
Section titled “.execute()”DynamicQueries.execute(query_id: str, args: dict) -> pandas.DataFrameExecute the spec carried in args["spec"] against the bound model.
Parameters:
(query_idstr) - Must be"dynamic"for this provider.
(argsdict) - Must include"spec"— the validated dynamic-query spec.
Returns:
pandas.DataFrame- Rows produced by executing the spec against the bound model.
Raises:
KeyError- Ifquery_idis not"dynamic".DynamicQuerySpecError- Ifargsdoes not carry aspeckey.