File size: 3,059 Bytes
79c6522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Excel Assistant

A Streamlit application that allows users to ask natural language questions about their Excel data and get answers using a Hugging Face LLM (TinyLlama-1.1B-Chat).

## Features

- Upload Excel files (.xlsx) with up to 500 rows and 10-20 columns
- Automatic column name cleaning and normalization
- Natural language question answering about your data
- Automatic chart generation based on question context
- Question history tracking
- Support for complex data queries

## Architecture

This project follows a modular structure:

- `app.py`: Main Streamlit application and UI
- `data_utils.py`: Excel file loading and data cleaning utilities
- `llm_utils.py`: LLM interaction and prompt handling
- `viz_utils.py`: Visualization generation based on LLM responses

## Requirements

- Python 3.8+
- CUDA-compatible GPU recommended (but not required)
- Dependencies listed in `requirements.txt`

## Installation

1. Clone this repository:
   ```
   git clone https://github.com/yourusername/excel-assistant.git
   cd excel-assistant
   ```

2. Create a virtual environment (recommended):
   ```
   python -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate
   ```

3. Install the required packages:
   ```
   pip install -r requirements.txt
   ```

## Usage

1. Start the Streamlit app:
   ```
   streamlit run app.py
   ```

2. Open your web browser and navigate to the URL displayed in your terminal (typically http://localhost:8501)

3. Upload an Excel file using the sidebar upload button

4. View the data preview and ask questions about your data

5. Explore the generated charts and answers

## Example Questions

- "What is the average age in the dataset?"
- "Show me a bar chart of sales by region"
- "What's the distribution of customer types?"
- "Show me customers under 30 years old"
- "Is there a correlation between age and income?"

## Deployment Options

### Streamlit Cloud

1. Push your code to a GitHub repository
2. Create an account on [Streamlit Cloud](https://streamlit.io/cloud)
3. Create a new app and connect it to your GitHub repository
4. Deploy the app

### Hugging Face Spaces

1. Create an account on [Hugging Face](https://huggingface.co/)
2. Create a new Space with Streamlit as the SDK
3. Upload your code to the Space
4. Configure the requirements

## Performance Considerations

- The first query might take longer as the model is loaded into memory
- Quantization is used to reduce memory usage (4-bit)
- For large Excel files, consider pre-processing to reduce size
- Chart generation might take a few seconds depending on the complexity

## Limitations

- Handles only the first sheet of an Excel file
- Works best with clean, structured data
- Chart extraction is based on pattern matching and might not always be perfect
- Advanced statistical operations might require additional implementation

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the LICENSE file for details.