Danialebrat commited on
Commit
5652fe3
·
1 Parent(s): 822ac98

Adding root app

Browse files

adding root requirements
adding root README.md

Files changed (3) hide show
  1. README.md +120 -0
  2. app.py +23 -0
  3. requirements.txt +51 -0
README.md ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: AI Messaging System Visualization
3
+ emoji: 🎵
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: "1.28.0"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # AI Messaging System - Visualization Tool
13
+
14
+ An interactive Streamlit dashboard for visualizing and analyzing AI-generated marketing messages across multiple brands and campaigns.
15
+
16
+ ## Features
17
+
18
+ - **Multi-Brand Support**: Visualize data for multiple brands with custom theming
19
+ - **Campaign Analysis**: Track message performance across different campaigns
20
+ - **AI Model Comparison**: Compare outputs from various AI models (GPT, Gemini, etc.)
21
+ - **Real-time Insights**: Interactive charts and metrics powered by Plotly
22
+ - **Secure Authentication**: Token-based access control
23
+ - **Snowflake Integration**: Direct connection to your data warehouse
24
+
25
+ ## Setup for HuggingFace Spaces
26
+
27
+ ### Required Secrets
28
+
29
+ This Space requires the following environment variables to be configured in your Space Settings:
30
+
31
+ #### Snowflake Database Configuration
32
+ - `SNOWFLAKE_USER`: Your Snowflake username
33
+ - `SNOWFLAKE_PASSWORD`: Your Snowflake password
34
+ - `SNOWFLAKE_ACCOUNT`: Your Snowflake account identifier
35
+ - `SNOWFLAKE_ROLE`: Your Snowflake role name
36
+ - `SNOWFLAKE_DATABASE`: Database name
37
+ - `SNOWFLAKE_WAREHOUSE`: Warehouse name
38
+ - `SNOWFLAKE_SCHEMA`: Schema name
39
+
40
+ #### AI Provider API Keys
41
+ - `OPENAI_API_KEY`: OpenAI API key for GPT models
42
+ - `GOOGLE_API_KEY`: Google AI API key for Gemini models
43
+
44
+ #### Application Security
45
+ - `APP_TOKEN`: Secure access token for authentication
46
+
47
+ ### How to Configure Secrets
48
+
49
+ 1. Go to your Space settings on HuggingFace
50
+ 2. Navigate to the "Settings" tab
51
+ 3. Scroll down to "Repository secrets"
52
+ 4. Click "Add a secret" for each required variable
53
+ 5. Enter the name and value, then save
54
+
55
+ ## Project Structure
56
+
57
+ ```
58
+ AI_Message_Generator/
59
+ ├── app.py # HuggingFace Space entry point
60
+ ├── requirements.txt # Combined dependencies
61
+ ├── ai_messaging_system_v2/ # Backend logic and AI agents
62
+ │ ├── Messaging_system/
63
+ │ ├── database/
64
+ │ ├── configs/
65
+ │ └── requirements.txt
66
+ └── visualization/ # Streamlit UI
67
+ ├── app.py # Main visualization app
68
+ ├── pages/ # Multi-page app sections
69
+ ├── utils/ # Helper functions
70
+ ├── data/ # Data storage
71
+ └── requirements.txt
72
+ ```
73
+
74
+ ## Local Development
75
+
76
+ To run this application locally:
77
+
78
+ 1. Clone the repository:
79
+ ```bash
80
+ git clone <your-repo-url>
81
+ cd AI_Message_Generator
82
+ ```
83
+
84
+ 2. Install dependencies:
85
+ ```bash
86
+ pip install -r requirements.txt
87
+ ```
88
+
89
+ 3. Set up environment variables:
90
+ - Copy `visualization/.env.example` to `.env`
91
+ - Fill in your actual credentials
92
+
93
+ 4. Run the Streamlit app:
94
+ ```bash
95
+ streamlit run app.py
96
+ ```
97
+
98
+ ## Architecture
99
+
100
+ - **Backend**: `ai_messaging_system_v2` handles AI message generation, database operations, and business logic
101
+ - **Frontend**: `visualization` provides the Streamlit-based user interface with authentication and data visualization
102
+ - **Integration**: The root `app.py` serves as the entry point that properly imports and runs the visualization app
103
+
104
+ ## Technologies Used
105
+
106
+ - **Streamlit**: Interactive web application framework
107
+ - **Snowflake**: Cloud data warehouse
108
+ - **OpenAI API**: GPT models for message generation
109
+ - **Google AI API**: Gemini models for message generation
110
+ - **Plotly**: Interactive data visualization
111
+ - **LangGraph**: Agentic workflow orchestration
112
+ - **Pandas**: Data manipulation and analysis
113
+
114
+ ## Support
115
+
116
+ For issues or questions, please open an issue in the repository.
117
+
118
+ ## License
119
+
120
+ [Specify your license here]
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ HuggingFace Space Entry Point
3
+ This file serves as the entry point for the HuggingFace Space,
4
+ redirecting to the visualization app.
5
+ """
6
+
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ # Add both directories to Python path
11
+ root_dir = Path(__file__).parent
12
+ sys.path.insert(0, str(root_dir))
13
+ sys.path.insert(0, str(root_dir / "ai_messaging_system_v2"))
14
+ sys.path.insert(0, str(root_dir / "visualization"))
15
+
16
+ # Import and run the visualization app
17
+ import importlib.util
18
+
19
+ # Load the visualization app module
20
+ app_path = root_dir / "visualization" / "app.py"
21
+ spec = importlib.util.spec_from_file_location("visualization_app", app_path)
22
+ visualization_app = importlib.util.module_from_spec(spec)
23
+ spec.loader.exec_module(visualization_app)
requirements.txt ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI Messaging System - Combined Requirements for HuggingFace Space
2
+ # Merges dependencies from both ai_messaging_system_v2 and visualization
3
+
4
+ # Core Dependencies
5
+ streamlit>=1.28.0
6
+ pandas>=2.0.0
7
+ numpy>=1.20.0
8
+ python-dotenv>=1.0.0
9
+
10
+ # Data Visualization
11
+ plotly>=5.17.0
12
+
13
+ # Snowflake Integration
14
+ snowflake-snowpark-python>=1.19.0
15
+ snowflake-connector-python>=3.0.0
16
+ pyarrow>=21.0.0
17
+ cloudpickle>=1.6.0,<=2.2.1
18
+ pyyaml>=6.0.0
19
+
20
+ # Date/Time Handling
21
+ pytz>=2020.1
22
+ python-dateutil>=2.8.0
23
+ tzdata>=2022.7
24
+
25
+ # AI/ML APIs
26
+ openai>=1.99.0
27
+ google-genai>=1.24.0
28
+ anyio>=4.8.0,<5.0.0
29
+ google-auth>=2.14.1,<3.0.0
30
+ httpx>=0.28.1,<1.0.0
31
+ pydantic>=2.0.0,<3.0.0
32
+ tenacity>=8.2.3,<9.0.0
33
+ websockets>=13.0.0,<15.1.0
34
+ distro>=1.7.0,<2.0.0
35
+ jiter>=0.4.0,<1.0.0
36
+ sniffio>=1.0.0
37
+
38
+ # LangGraph for Agentic Workflow Orchestration
39
+ langgraph>=0.2.0
40
+ langchain-core>=0.3.0
41
+
42
+ # HTTP and Crypto Dependencies
43
+ certifi>=2017.4.17
44
+ requests>=2.25.0,<3.0.0
45
+ urllib3>=1.21.1,<2.0.0
46
+ cryptography>=3.1.0
47
+ pyopenssl>=22.0.0,<26.0.0
48
+ cffi>=1.9,<2.0.0
49
+
50
+ # Utility Libraries
51
+ tqdm>=4.66.0