Deepa Shalini commited on
Commit
8385610
·
1 Parent(s): bdae9e2

hf deployment

Browse files
Files changed (3) hide show
  1. .gitignore +0 -8
  2. README.md +78 -45
  3. requirements.txt +1 -0
.gitignore CHANGED
@@ -8,13 +8,5 @@ __pycache__/
8
  # ignore environment variables
9
  .env
10
 
11
- # ignore old multi-page files (no longer used)
12
- pages/
13
- utils/chartbot_dataset_layout.py
14
- utils/components.py
15
-
16
- # ignore design html file
17
- design.html
18
-
19
  # ignore temporary files created
20
  temp*
 
8
  # ignore environment variables
9
  .env
10
 
 
 
 
 
 
 
 
 
11
  # ignore temporary files created
12
  temp*
README.md CHANGED
@@ -1,60 +1,93 @@
1
- # ChaRtBot - Data Visualization Assistant
 
 
 
 
 
 
2
 
3
- A single-page Dash application that helps users visualize their CSV data using natural language prompts powered by AI.
4
 
5
- ## Features
6
 
7
- - **Simple, Clean UI**: Modern design with gradient backgrounds and smooth animations
8
- - **CSV File Upload**: Easy drag-and-drop or click-to-upload functionality (CSV files only)
9
- - **Natural Language Prompts**: Describe the visualization you want in plain English
10
- - **AI-Powered Visualizations**: Automatically generates Plotly charts based on your data and prompts
11
- - **Download Charts**: Export generated visualizations as standalone HTML files
12
- - **Error Handling**: Comprehensive error handling for file uploads, API calls, and data processing
13
 
14
- ## How to Use
15
 
16
- 1. **Start the App**:
17
- ```bash
18
- source .venv/bin/activate
19
- python app.py
20
- ```
21
 
22
- 2. **Upload Your Data**: Click "Choose file" and select a CSV file
23
 
24
- 3. **Enter Your Prompt**: Describe the visualization you want, e.g.:
25
- - "Create a bar chart showing the top 10 values"
26
- - "Make a scatter plot with X vs Y"
27
- - "Show me a pie chart of category distribution"
28
 
29
- 4. **Submit**: Click the Submit button to generate your visualization
 
 
30
 
31
- 5. **Download** (Optional): Download the generated chart as an HTML file
32
 
33
- ## Technical Details
34
 
35
- ### Structure
36
- - **app.py**: Main application file with all callbacks and layout
37
- - **utils/prompt.py**: LLM integration for generating visualization code
38
- - **utils/helpers.py**: Helper functions for processing data and displaying results
39
- - **assets/custom.css**: Custom styling matching the design specifications
40
 
41
- ### Callbacks
42
- 1. **File Upload**: Validates CSV files, stores data in memory
43
- 2. **Submit**: Validates prompt and data, calls LLM, generates visualizations
44
- 3. **Download**: Provides HTML export functionality
45
 
46
- ### Error Handling
47
- - CSV file validation
48
- - Missing prompt validation
49
- - Missing file validation
50
- - API error handling
51
- - Code execution error handling
52
 
53
- ## Requirements
54
 
55
- See requirements in the Python environment. Main dependencies:
56
- - Dash
57
- - Plotly
58
- - Pandas
59
- - LangChain (for LLM integration)
60
- - Dash Mantine Components
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: ChaRtBot
3
+ emoji: 📊
4
+ sdk: docker
5
+ app_file: app.py
6
+ pinned: true
7
+ ---
8
 
9
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
10
 
11
+ # Dash on Spaces
12
 
13
+ ![Gapminder Dashboard Screenshot](screenshot.png)
 
 
 
 
 
14
 
15
+ With Dash Open Source, you can create data apps on your laptop in pure Python, no JavaScript required.
16
 
17
+ Get familiar with Dash by building a [sample app](https://dash.plotly.com/tutorial) with open source. Scale up with [Dash Enterprise](https://plotly.com/dash/) when your Dash app is ready for department or company-wide consumption. Or, launch your initiative with Dash Enterprise from the start to unlock developer productivity gains and hands-on acceleration from Plotly's team.
 
 
 
 
18
 
19
+ ## Deploy Dash on Spaces
20
 
21
+ To get started with Dash on Spaces, click the button below:
 
 
 
22
 
23
+ <a href="http://huggingface.co/new-space?template=plotly/dash-app-template" target="_blank">
24
+ <img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/deploy-to-spaces-lg.svg" alt="">
25
+ </a>
26
 
27
+ This will start building your Space using Plotly's Dash Docker template. If successful, you should see a similar application to the [Dash template app](https://huggingface.co/spaces/dash/dash-app-template).
28
 
29
+ ## Customizing your Dash app
30
 
31
+ If you have never built with Dash before, we recommend getting started with our [Dash in 20 minutes tutorial](https://dash.plotly.com/tutorial).
 
 
 
 
32
 
33
+ When you create a Dash Space, you'll get a few key files to help you get started:
 
 
 
34
 
35
+ ### 1. app.py
 
 
 
 
 
36
 
37
+ This is the main app file that defines the core logic of your project. Dash apps are often structured as modules, and you can optionally seperate your layout, callbacks, and data into other files, like `layout.py`, etc.
38
 
39
+ Inside of `app.py` you will see:
40
+
41
+ 1. `from dash import Dash, html`
42
+ We import the `Dash` object to define our app, and the `html` library, which gives us building blocks to assemble our project.
43
+
44
+ 2. `app = Dash()`
45
+ Here, we define our app. Layout, server, and callbacks are _bound_ to the `app` object.
46
+
47
+ 3. `server = app.server`
48
+ Here, we define our server variable, which is used to run the app in production.
49
+
50
+ 4. `app.layout = `
51
+ The starter app layout is defined as a list of Dash components, an indivdual Dash component, or a function that returns either.
52
+
53
+ The `app.layout` is your initial layout that will be updated as a single-page application by callbacks and other logic in your project.
54
+
55
+ 5. `if __name__ == '__main__': app.run(debug=True)`
56
+ If you are running your project locally with `python app.py`, `app.run(...)` will execute and start up a development server to work on your project, with features including hot reloading, the callback graph, and more.
57
+
58
+ In production, we recommend `gunicorn`, which is a production-grade server. Debug features will not be enabled when running your project with `gunicorn`, so this line will never be reached.
59
+
60
+ ### 2. Dockerfile
61
+
62
+ The Dockerfile for a Dash app is minimal since Dash has few system dependencies. The key requirements are:
63
+
64
+ - It installs the dependencies listed in `requirements.txt` (using `uv`)
65
+ - It creates a non-root user for security
66
+ - It runs the app with `gunicorn` using `gunicorn app:server --workers 4`
67
+
68
+ You may need to modify this file if your application requires additional system dependencies, permissions, or other CLI flags.
69
+
70
+ ### 3. requirements.txt
71
+
72
+ The Space will automatically install dependencies listed in the `requirements.txt` file. At minimum, you must include `dash` and `gunicorn` in this file. You will want to add any other required packages your app needs.
73
+
74
+ The Dash Space template provides a basic setup that you can extend based on your needs.
75
+
76
+ ## Additional Resources and Support
77
+
78
+ - [Dash documentation](https://dash.plotly.com)
79
+ - [Dash GitHub repository](https://github.com/plotly/dash)
80
+ - [Dash Community Forums](https://community.plotly.com)
81
+ - [Dash Enterprise](https://plotly.com/dash)
82
+ - [Dash template Space](https://huggingface.co/spaces/plotly/dash-app-template)
83
+
84
+ ## Troubleshooting
85
+
86
+ If you encounter issues:
87
+
88
+ 1. Make sure your notebook runs locally in app mode using `python app.py`
89
+ 2. Check that all required packages are listed in `requirements.txt`
90
+ 3. Verify the port configuration matches (7860 is the default for Spaces)
91
+ 4. Check Space logs for any Python errors
92
+
93
+ For more help, visit the [Plotly Community Forums](https://community.plotly.com) or [open an issue](https://github.com/plotly/dash/issues).
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  annotated-types==0.7.0
2
  anyio==4.12.0
3
  blinker==1.9.0
 
1
+ gunicorn
2
  annotated-types==0.7.0
3
  anyio==4.12.0
4
  blinker==1.9.0