Author: Ehtesham Siddiqui
IntelliCast 2.0 is a production-quality, agentic political chatbot designed for advanced reasoning, strict neutrality, and real-time factuality. It leverages OpenAI’s GPT-4, aggregates data from multiple APIs and authoritative sources, and enforces principled boundaries. Each session maintains its own persistent memory profile, enabling context-rich, multi-turn conversations with robust bias mitigation and multi-perspective analysis. The system is engineered for reliability, transparency, and compliance with best practices in political information delivery.
- Strict Neutrality: Enforces unbiased, factual answers with both Republican and Democratic perspectives where relevant.
- Principled Boundaries: Uses an LLM-based YES/NO classifier to strictly refuse non-political questions with a fixed message (no sources shown).
- Real-Time Information Retrieval: Aggregates up-to-date data from NewsAPI, The Guardian, Serper, Brave, Congress, FEC, and scrapes Wikipedia/White House for authoritative facts.
- Multi-Perspective Analysis: Always presents multiple viewpoints on partisan or controversial issues.
- Session Memory: Each chat session has its own persistent memory and conversation history, supporting context-rich, multi-turn interactions.
- Advanced Prompt Engineering: System prompt enforces neutrality, disables LLM-generated sources, and includes the last 4 turns of conversation for continuity.
- Bias Mitigation: After each answer, the LLM self-reflects for bias and revises if needed.
- Citations & Confidence: Only URLs actually referenced in the answer are cited at the bottom; every answer includes a confidence score.
- Modern Web UI: Responsive, ChatGPT-style interface with sidebar, chat bubbles, and persistent chat history.
- API Integration: Modular design makes it easy to add or swap data sources.
-
Install dependencies:
pip install -r requirements.txt -
Create a
.envfile with your API keys:OPENAI_API_KEY=your_openai_key_here NEWS_API_KEY=your_newsapi_key_here GUARDIAN_API_KEY=your_guardian_key_here BRAVE_API_KEY=your_brave_key_here CONGRESS_API_KEY=your_congress_key_here FEC_API_KEY=your_fec_key_here SERPER_API_KEY=your_serper_key_hereOnly the keys you provide will be used. The more you add, the richer the answers.
-
Run the chatbot (web UI):
python app.pyThen open http://localhost:5000 in your browser.
- Start a new chat, switch between sessions, or delete old ones from the sidebar.
- Ask any political, government, or public policy question — the bot will answer with both perspectives, sources, and a confidence score.
- The bot will strictly refuse non-political questions with a fixed message and no sources.
- Click "Summarize" to get a quick overview of any session.
- All your chats are saved and can be revisited anytime.
- You can also run the CLI version:
python main.py - Use
historyto see your conversation,summaryfor stats, andquitto exit.
OPENAI_API_KEY=sk-...
NEWS_API_KEY=...
GUARDIAN_API_KEY=...
BRAVE_API_KEY=...
CONGRESS_API_KEY=...
FEC_API_KEY=...
SERPER_API_KEY=...
app.py— Flask backend for the web UImain.py— CLI version (optional)politics_bot.py— Core agentic chatbot logic (neutrality, bias/citation checks, session memory)news_sources.py— API clients for news/search/government datatopic_classifier.py— LLM-based classifier for political queriessettings.py— Loads config and API keysstatic/— CSS and JS for the web UItemplates/— HTML for the web UI
- If you get "Invalid session" errors, try refreshing the page or starting a new chat.
- If answers seem limited, check your
.envfor missing or expired API keys. - For best results, provide as many API keys as possible.
- The bot will politely refuse non-political questions (e.g., "What's the weather?").
- All code and UI are written and organized by me, Ehtesham Siddiqui.
This project is a showcase of advanced prompt engineering, agentic reasoning, API integration, and user-friendly AI tool design. If you have feedback or want to extend the bot with more sources or features, feel free to reach out!