This innovative solution combining real-time weather monitoring with AI-powered interactions. This application uses Streamlit for the frontend, Python and NATS for the backend, and integrates OpenAI's GPT model for decision making, setting alerts and intelligent responses. Read more on this article:
Before you begin, ensure you have Python and Docker installed on your system. This project requires Python 3.6 or later.
First, clone the repository to your local machine:
git clone https://github.com/glassflow/example-real-time-ai-alerts.git
cd example-real-time-ai-alerts
It's recommended to use a virtual environment for Python projects. Create and activate one using:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install the required Python packages:
pip install -r requirements.txt
Ensure Docker is running on your machine. Then, start the NATS server using Docker Compose:
docker compose up -d
Create a .env
file in the root directory of the project and add your OpenAI and Weather API keys:
OPENAI_API_KEY=your_openai_api_key
WEATHER_API_KEY=your_weather_api_key
Replace your_openai_api_key
and your_weather_api_key
with your actual API keys.Before running the application, ensure that the environment variables are set. If you're using a virtual environment, you can load them manually:
Run the backend server with:
python backend.py
In a new terminal, launch the Streamlit application:
streamlit run frontend.py
- Interact with the Chat: Open the Streamlit app in your web browser and try sending messages or asking questions.
- Set Weather Alerts: Use the interface to set custom weather alerts and see how the application responds.
- Monitor NATS Server: Optionally, you can monitor the NATS server at
http://localhost:8222
.
To stop the application:
-
Close the Streamlit app.
-
Terminate the backend script (
Ctrl+C
in the terminal). -
Stop the NATS server with Docker Compose:
docker compose down
Contributions to this project are welcome! Please fork the repository and submit a pull request with your changes.