A FastAPI-based visualization agent that receives a dict containing a user query and a dataset, and returns a json schema containing recommended visualization data, including recommended chart type, x-axis, y-axis, and rows of data pertaining to the visualization to best optimize fulfilling the query.
Users often need to meticulously inspect datasets to figure out how to visualize them, which not only requires time, but requires knowledge of data visualization. The system automates this process by recommending the appropriate data visualization, while providing the rows of data for easy convertibility from json to a graph for easy integration with common visualization libraries.
- FastAPI
- OpenAI API
- Redis
- Pandas
- Pytest
Replace input1.json with input2.json, input3.json, input4.json, or input5.json to see how the agent behaves to different expected inpute, whose outputs are below.
- Terminal 1: start Redis by using
redis-server
- Terminal 2: Start FastAPI app by using
uvicorn fastapimodule.module:app --reload
- Terminal 3: Test endpoint by making POST request to endpoint
curl -X POST "http://127.0.0.1:8000/visualization_agent" \
-H "Content-Type: application/json" \
-d @./fastapimodule/input.json
curl -X POST "http://127.0.0.1:8000/visualization_agent" \
-H "Content-Type: application/json" \
-d @./testing/testinputs/input1.json
In project_root, run
PYTHONPATH=. pytest -v
- chart_type: bar
- x_axis: region
- y_axis: sales
- aggregation: sum
- chart_type: line
- x_axis: Data
- y_axis: sales
- aggregation: none
- chart_type: scatter
- x_axis: ad spend
- y_axis: sales
- aggregation: none
- status: unrelated
- status: Impossible