Spaces:
Running
on
CPU Upgrade
Auto-Analyst API Documentation
The core application routes are designed to manage the data and AI analysis capabilities of the Auto-Analyst application.
1. Core Application Routes
Data Management
POST /upload_dataframe
Uploads a CSV dataset for analysis.
Request:
file
: CSV filename
: Dataset namedescription
: Dataset description
Headers:X-Force-Refresh
: "true" (optional) - Forces session reset before upload Response:
{ "message": "Dataframe uploaded successfully", "session_id": "abc123" }
POST /upload_excel
Uploads an Excel file with a specific sheet for analysis.
Request:
file
: Excel filename
: Dataset namedescription
: Dataset descriptionsheet_name
: Name of the Excel sheet to use Headers:X-Force-Refresh
: "true" (optional) - Forces session reset before upload Response:
{ "message": "Excel file processed successfully", "session_id": "abc123", "sheet": "Sheet1" }
POST /api/excel-sheets
Gets the list of sheet names from an Excel file.
Request:
file
: Excel file
Response:
{ "sheets": ["Sheet1", "Sheet2", "Data"] }
GET /api/default-dataset
Gets the default dataset.
Response:
{
"headers": ["column1", "column2", ...],
"rows": [[val1, val2, ...], ...],
"name": "Housing Dataset",
"description": "A comprehensive dataset containing housing information..."
}
POST /reset-session
Resets session to default dataset.
Request Body:
{
"name": "optional name",
"description": "optional description",
"preserveModelSettings": false
}
Response:
{
"message": "Session reset to default dataset",
"session_id": "abc123",
"dataset": "Housing.csv"
}
GET /api/preview-csv / POST /api/preview-csv
Preview the current dataset in the session. Response:
{
"headers": ["column1", "column2", ...],
"rows": [[val1, val2, ...], ...],
"name": "Dataset Name",
"description": "Dataset description..."
}
2. AI Analysis
POST /chat/{agent_name}
Processes a query using a specific AI agent.
Path Parameters: agent_name
Request Body:
{ "query": "Analyze the relationship between price and size" }
Query Parameters: user_id
(optional), chat_id
(optional)
Response:
{
"agent_name": "data_viz_agent",
"query": "Analyze the relationship between price and size",
"response": "# Analysis\n\nThere appears to be a strong positive correlation...",
"session_id": "abc123"
}
POST /chat
Processes a query using multiple AI agents with streaming responses.
Request Body:
{ "query": "Analyze the housing data" }
Query Parameters: user_id
(optional), chat_id
(optional)
Response: Streaming JSON objects:
{"agent": "data_viz_agent", "content": "# Visualization\n\n...", "status": "success"}
{"agent": "statistical_analytics_agent", "content": "# Statistical Analysis\n\n...", "status": "success"}
POST /chat_history_name
Generates a name for a chat based on the query.
Request Body:
{ "query": "Analyze sales data for Q4" }
Response:
{ "name": "Chat about sales data analysis" }
GET /agents
Lists available AI agents.
Response:
{
"available_agents": ["data_viz_agent", "sk_learn_agent", "statistical_analytics_agent", "preprocessing_agent"],
"standard_agents": ["preprocessing_agent", "statistical_analytics_agent", "sk_learn_agent", "data_viz_agent"],
"template_agents": ["custom_template_1", "custom_template_2"],
"custom_agents": []
}
3. Deep Analysis
POST /deep_analysis_streaming
Performs comprehensive deep analysis with real-time streaming updates.
Request Body:
{ "goal": "Perform comprehensive analysis of the sales data" }
Query Parameters: user_id
(optional), chat_id
(optional)
Response: Streaming JSON objects with progress updates
POST /deep_analysis/download_report
Downloads an HTML report from deep analysis results.
Request Body:
{
"analysis_data": { ... },
"report_uuid": "optional-uuid"
}
Response: HTML file download
4. Model Settings
GET /api/model-settings
Fetches current model settings.
Response:
{
"provider": "openai",
"model": "gpt-4o-mini",
"hasCustomKey": true,
"temperature": 1.0,
"maxTokens": 6000
}
POST /settings/model
Updates model settings.
Request Body:
{
"provider": "openai",
"model": "gpt-4",
"api_key": "sk-...",
"temperature": 0.7,
"max_tokens": 8000
}
Response:
{ "message": "Model settings updated successfully" }
5. Session Management
GET /api/session-info
Gets information about the current session.
Response:
{
"session_id": "abc123",
"dataset_name": "Housing Dataset",
"dataset_description": "...",
"model_config": { ... }
}
POST /set-message-info
Associates message tracking information with the session.
Request Body:
{
"chat_id": 123,
"message_id": 456,
"user_id": 789
}
POST /create-dataset-description
Creates an AI-generated description for a dataset.
Request Body:
{
"df_preview": "column1,column2\nvalue1,value2\n...",
"name": "Dataset Name"
}
6. System Endpoints
GET /
Returns API welcome information and feature list.
GET /health
Health check endpoint.
Response:
{ "message": "API is healthy and running" }
7. Debug Endpoints
GET /debug/deep_analysis_agents
Debug information about deep analysis agents for a session.
POST /debug/clear_deep_analyzer
Clears the deep analyzer cache for a session.
8. Authentication & Session Management
- Session ID Sources:
- Query parameter:
session_id
- Header:
X-Session-ID
- Auto-generated if not provided
- Query parameter:
- Session State Includes:
- Current dataset
- AI system instance
- Model configuration
- User and chat associations
9. Error Handling
- Comprehensive error handling with appropriate HTTP status codes
- Detailed error messages for debugging
- Fallback encoding support for CSV files (UTF-8, unicode_escape, ISO-8859-1)
- Session state preservation during errors