Natural language parser for spreadsheet operations. Converts user queries into structured intents with entity extraction and safety validation.
- Node.js 18+
- OpenAI API key
npm installCreate .env file:
cp .env.example .envEdit .env and add your OpenAI API key:
OPENAI_API_KEY=your-key-here
LLM_MODEL=gpt-4o-mini-2024-07-18
LLM_TEMPERATURE=0.2
PORT=3000
MAX_INPUT_LENGTH=2000
Start the web app:
npm run webappStart API server only:
npm run start:devPOST http://localhost:3000/api/parse
Content-Type: application/json
{
"text": "sum revenue in column C where region = West"
}Response:
{
"intent": "CREATE_FORMULA",
"tool": "formula_generator",
"confidence": 0.95,
"command_text": "sum revenue in column C where region = West",
"entities": {
"aggregation": "sum",
"column": "C",
"condition": "region = West"
},
"safety_flags": {
"risky_external_fetch": false,
"file_write": false
},
"requires_disambiguation": false,
"ask": []
}| Intent | Description |
|---|---|
| CREATE_FORMULA | Create/modify formulas |
| FIX_FORMULA | Debug formula errors |
| CLEAN_DATA | Remove duplicates, trim, format |
| FILTER_SORT | Filter and sort data |
| SUMMARIZE | Group and aggregate data |
| CREATE_PIVOT | Create pivot tables |
| CREATE_CHART | Create visualizations |
| EXPLAIN_CELL | Explain cell contents |
| IMPORT_DATA | Import external data |
| JOIN_SHEETS | Merge data from sheets |
| VALIDATE_DATA | Validate data patterns |
| AUTOMATE_MACRO | Create automation |
| HELP | General help |
| CANCEL | Cancel operation |
| AMBIGUOUS | Unclear intent (triggers clarification) |
When queries are ambiguous, the clarifying agent asks follow-up questions:
Input: make a chart
Response:
{
"intent": "AMBIGUOUS",
"clarification": {
"needsClarification": true,
"questions": [
"What type of chart? (bar, line, pie, etc.)",
"What data should be visualized?"
],
"suggestedIntents": ["CREATE_CHART"]
}
}Follow-up: bar chart showing sales by region
Final Result: Refined query with CREATE_CHART intent
├── src/
│ ├── api/ # Express server
│ ├── config/ # Configuration
│ ├── models/ # Type definitions
│ ├── services/ # Core services
│ │ ├── Parser.ts
│ │ ├── IntentClassifier.ts
│ │ ├── EntityExtractor.ts
│ │ ├── ClarifyingAgent.ts
│ │ └── SafetyValidator.ts
│ └── utils/ # Utilities
├── public/ # Web UI
├── docs/ # Documentation
└── examples/ # Usage examples
npm run buildnpm run demoPress Ctrl+C in the terminal
| Endpoint | Method | Description |
|---|---|---|
/api/parse |
POST | Parse user query |
/api/clarify |
POST | Process clarification response |
/api/v1/parse |
POST | Parse with full error handling |
/api/v1/metrics |
GET | Get performance metrics |
/health |
GET | Health check |
| Variable | Default | Description |
|---|---|---|
| OPENAI_API_KEY | - | OpenAI API key (required) |
| LLM_MODEL | gpt-4o-mini-2024-07-18 | Model to use |
| LLM_TEMPERATURE | 0.2 | Temperature (0-1) |
| PORT | 3000 | Server port |
| MAX_INPUT_LENGTH | 2000 | Max query length |
MIT