Welcome to the Fact Finder Streamlit App repository. This app fetches and displays facts based on user-selected topics and personas, leveraging OpenAI's GPT models for content generation and SQLAlchemy for data persistence, and Streamlit as a front end.
The app is deployed using Streamlit cloud, and can be accessed here: https://fact-finder.streamlit.app/
- Fetch facts from OpenAI based on selected topics and personas.
- Cache facts in a SQLite database for quick retrieval.
- User interface built with Streamlit for an interactive experience.
The project has the following structure:
app/
: Directory containing the main application logic.streamlit_app.py
: The main Streamlit application file.database.py
: Contains SQLAlchemy database operations for storing and retrieving facts.config.py
: Configuration settings for the application, including environment variables.openai_retrieval.py
: Handles fetching data from OpenAI.prompts.py
: Constructs prompts for querying OpenAI.
Dockerfile
: Contains information about building a Docker image for the repository..pre-commit-config.yaml
: Contains linting and formatting commit hooks for maintaining consistency in this repositorydata/
: Contains information about topics and topic associations.
To run in Docker:
To run locally:
- Python 3.8+
- pip
- Virtual environment (recommended)
- Docker (for containerization)
To run this app in Docker or locally, you must have your own 'OPENAI_API_KEY'.
-
Instructions for setting up an
OPENAI_API_KEY
can be found here. -
To export your
OPENAI_API_KEY
to your.zshrc
or.bashrc
file to have them available for any terminal session, you can use the following commands.
-
Exporting the Environment Variable:
- For
.zshrc
(Zsh shell):echo 'export OPENAI_API_KEY=your_openai_api_key_here' >> ~/.zshrc
- For
.bashrc
(Bash shell):echo 'export OPENAI_API_KEY=your_openai_api_key_here' >> ~/.bashrc
- For
-
Reloading the Shell Configuration:
- For Zsh:
source ~/.zshrc
- For Bash:
source ~/.bashrc
- For Zsh:
If you want to export the OPENAI_API_KEY
in a single terminal session without modifying the shell configuration files, you can do it directly in the terminal:
export OPENAI_API_KEY=your_openai_api_key_here
This command sets the OPENAI_API_KEY
environment variable for the current terminal session. Remember that this approach will only persist for the duration of that terminal session.
To run the Fact Finder Streamlit App using Docker, you can pull the pre-built image from Docker Hub and run it in a container.
Pull the latest version of the Fact Finder Streamlit App image from Docker Hub:
docker pull smithla02/fact-finder
To run the Docker container and open in your browser, pass the OPENAI_API_KEY
as an environment variable and map port 8501 for access:
docker run -e OPENAI_API_KEY -p 8501:8501 smithla02/fact-finder & sleep 2 && open http://localhost:8501
After starting the container, open your web browser and navigate to http://localhost:8501
to view the app.
To stop the running container, find the container using docker ps | grep 'fact-finder'
, then stop it using docker stop <container_id>
.
- Clone the repository to your local machine.
- Navigate to the project directory.
- Create a virtual environment:
- Linux/macOS:
python3 -m venv venv
- Windows:
py -m venv venv
- Linux/macOS:
- Activate the virtual environment:
- Linux/macOS:
source venv/bin/activate
- Windows:
.\venv\Scripts\activate
- Linux/macOS:
- Install the required dependencies:
pip install -r requirements.txt
With the environment set up and activated, run the Streamlit app using:
streamlit run streamlit_app.py
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.