Appearance
Elsai NLI
Package: elsai-nli v0.1.0
Ask natural language questions directly over structured CSV data. CSVAgentHandler uses an LLM-powered agent to interpret questions, query the CSV, and return results without writing any SQL or pandas code.
Installation
bash
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-nli/ elsai-nli==0.1.0Requirements: Python >= 3.9
CSVAgentHandler
Wraps one or more CSV files with an LLM agent that translates natural language questions into structured data operations.
python
from elsai_nli.natural_language_interface import CSVAgentHandler
agent = CSVAgentHandler(
csv_files="path/to/sales_data.csv",
model="your_llm_model",
agent_type="openai-functions",
verbose=True,
)
response = agent.ask_question("What is the total sales amount for each product?")
print(response)Multiple CSV files:
python
agent = CSVAgentHandler(
csv_files=["path/to/orders.csv", "path/to/customers.csv"],
model="your_llm_model",
agent_type="openai-functions",
verbose=False,
)
response = agent.ask_question("How many orders did each customer place last month?")
print(response)Constructor parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
csv_files | str or list | Yes | Path to a single CSV file, or a list of paths for multi-file queries |
model | str or instance | Yes | LLM model identifier or instance to use for query generation |
agent_type | str | Yes | Agent backend type (e.g. "openai-functions") |
verbose | bool | No | Enables debug output during processing. Defaults to False |
Methods:
| Method | Description |
|---|---|
ask_question(question) | Converts a natural language question into operations over the CSV data and returns the result |