The AI TOC Agent is a lightweight, intelligent tool built using OpenAI and Streamlit to generate a customized Table of Contents (TOC) for courses based on a topic keyword and duration. It leverages a structured prompt and LLMs to produce an educational outline tailored to user input.
ai_toc_agent/
│
├── app.py # Streamlit app entry point
├── toc_agent.py # Core logic to generate TOC using OpenAI
├── prompt_template.txt # Template prompt for generating TOC
├── requirements.txt # Python dependencies
├── logo.png # App logo
└── __pycache__/ # Compiled Python bytecode (auto-generated)
- Python 3.9 or later
- OpenAI API Key
- VS Code or any Python IDE
If downloaded as a ZIP file, extract it into a working folder.
cd ai_toc_agent
python -m venv venv
# For Windows:
venv\Scripts\activate
# For macOS/Linux:
source venv/bin/activate
pip install -r requirements.txt
Create a new file named .env
in the root folder (same as app.py
) and add:
OPENAI_API_KEY=your-api-key-here
Note: You can get your API key from Azure OpenAI Resouce from Azure
Or export it in your shell:
export OPENAI_API_KEY=your-api-key-here # Linux/macOS
set OPENAI_API_KEY=your-api-key-here # Windows CMD
$env:OPENAI_API_KEY="your-api-key-here" # PowerShell
streamlit run app.py
Then open the URL shown in the terminal (usually http://localhost:8501
) to access the web app.
- Enter a topic and course duration.
- The app fills in a prompt template.
- OpenAI generates a detailed course TOC.
- The result is displayed in a formatted layout.
streamlit
openai
python-dotenv
Feel free to share improvements or raise issues.