Skip to main content

ask_with_schema

Function ask_with_schema 

Source
pub fn ask_with_schema(
    schema_dump: &str,
    question: &str,
    config: &AskConfig,
) -> Result<AskResponse, AskError>
Expand description

One-shot natural-language → SQL.

You pass the schema dump as a string (typically produced by the engine’s sqlrite::ConnectionAskExt / dump_schema_for_database helper, but any string format the model can read is fine) and the user’s question. Returns the generated SQL plus a one-sentence rationale plus token usage for cache-hit verification.

The library does not execute the returned SQL — that’s the caller’s call. See module docs for rationale.

Feature-gated under http (default-on) — wraps the built-in AnthropicProvider, which uses ureq and isn’t wasm-safe. WASM callers should use ask_with_schema_and_provider with a caller-supplied provider, or skip this crate entirely and use the WASM SDK’s db.askPrompt() / db.askParse() shape (Q9).