Configure
const ava = new AVA({
llm: { model: 'YOUR_MODEL', apiKey: process.env.OPENAI_API_KEY },
engine: { type: 'python', queryTimeoutMs: 30000 },
});Validation uses Python's official compile(..., 'exec') in the selected execution environment without running user code or loading data. Local validation requires python3; data execution also requires pandas. Additional file readers may need optional pandas dependencies for Excel or Parquet.
Engine options
Set engine.type to python. These are all additional fields accepted on engine.
| Field | Type | Required | Meaning / default |
|---|---|---|---|
execute | (code: string) => Promise<ExecutionResult> | No | Override local python3 execution with a custom environment. Local execution is not sandboxed. Run the complete Python script and return its JSON output as ExecutionResult. Each query first sends a compile-only validation script, then the data execution script with source loading and result limits. Configure remote execution deadlines separately. |
queryTimeoutMs | number | No | Wait and local process deadline for each validation or execution call. Default 30000 ms. |
Supported sources
Inline CSV and JSON, plus CSV, JSON, Excel, and Parquet files are supported. Files can be local or HTTP(S) URLs. This engine does not accept text extraction or database sources. source() stores validated configuration; actual reads occur during execution or metadata computation. Each query reloads its input.
Query bindings
pd provides pandas. DataFrames are available in tables, keyed by schema table name. For a single table, df is also provided. Assign the final value to result.
const result = await ava.query("result = df.groupby('region', as_index=False)['revenue'].sum()");DataFrame and Series indexes are not returned automatically; use reset_index() when those values matter. Each execution starts from fresh input data, so mutations and variables do not persist between calls.
Supply a Python executor
Keep AVA's Python query generation and source handling, and replace where the complete script runs:
import { AVA, type ExecutionResult } from '@antv/ava';
const ava = new AVA({
llm: { model: 'YOUR_MODEL', apiKey: process.env.OPENAI_API_KEY },
engine: {
type: 'python',
queryTimeoutMs: 30000,
execute: async (code: string): Promise<ExecutionResult> => {
const response = await fetch('https://YOUR_EXECUTOR/run', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ code }),
signal: AbortSignal.timeout(30000),
});
if (!response.ok) throw new Error(`Python execution failed: ${response.status}`);
return (await response.json()) as ExecutionResult;
},
},
});YOUR_EXECUTOR is an application-owned service, not an AVA endpoint. It must execute the supplied script with Python and pandas, parse its JSON output, and return an ExecutionResult. Validate that response at the service boundary. A local file path in the script must also exist in the executor environment; alternatively use inline data or accessible URLs.
| Callback parameter / result | Type | Required | Meaning |
|---|---|---|---|
code | string | Yes | Complete script for compile-only validation or data execution. |
| Returned promise | Promise<ExecutionResult> | Yes | Resolve with schema and data, plus applicable truncation metadata; reject on failure. |
See engine options for all engine fields and execution results for the result shape. Enforce deadlines and resource limits in the service itself: aborting the HTTP request only stops the client waiting.