Leveraging AI in the Local Government
December 2024
Intensify the data driven culture in the Richmond and Wandsworth Council. Image by OpenAI.
This is a Proof-of-Concept AI-powered application for analyzing my council’s Call Center data. Combining FastAPI, Streamlit, and LLMs, this app is designed for performance, transparency, and cost-efficiency.
🌟 Key Features:
- Natural Language Query Parsing
• Input plain English questions like “What’s the average time to close requests per category?”.
• Automatically converts the query into optimized SQL or Pandas code.
• Executes the query in real time, fetching precise results without expensive agentic looping.
- FastAPI for Backend Excellence
• No database data is ever read by the AI – all queries are processed and executed locally for full data security.
• Ensures fast execution without relying on slow or costly AI-driven agentic methods.
• Provides full transparency – no black-box operations; you see exactly how your data is processed.
- Streamlit Frontend for Intuitive Interaction
• Clean, user-friendly UI built with Streamlit, enabling effortless interaction with data.
• Predefined queries for common tasks (e.g., “List all unresolved calls”).
• Real-time display of query results – scalar values, tabular data, or JSON.
- Gemini AI for LLM-Powered Queries
• Uses Google Gemini AI (1.5 Pro) to convert natural language questions into highly accurate SQL or Pandas queries.
• Avoids unnecessary complexity by focusing solely on query generation, keeping the process simple and efficient.
- Lightweight and Scalable with Docker
• Fully Dockerized for deployment anywhere – from local environments to Hugging Face Spaces (a cloud platform).
• Possibly it is likely being planned to deploy it to Azure using their services, such as Azure App Service, Azure Kubernetes Service (AKS), or Azure Container Instances (ACI).
- Secure Environment Management
• Sensitive API keys (e.g., OpenAI API, Google Gemini API Key) are managed securely using environment variables (e.g. Azure's Key Vault), ensuring safe deployment.
Technical Stack:
- FastAPI: High-performance backend for query processing and external API integration.
- Streamlit: Dynamic, responsive frontend that makes interacting with the app a breeze.
- Google Gemini AI: Converts natural language inputs into precise SQL and Pandas queries.
- SQLite/Pandas: Executes queries on structured and tabular data with ease.
- Docker: Ensures portability and scalability with containerized deployments.
How It Works:
- Ask: Input queries like “How many requests are unresolved?” or “Show the top request categories.”
- Process: FastAPI and AI handle the query conversion in real time.
- Execute: SQL or Pandas runs the query, ensuring secure and efficient execution.
- Analyze: Results are instantly displayed on the Streamlit UI – no delays, no guesswork.
🌟 Why CallDataAI Stands Out
- No Database Data is Sent to AI
• Unlike many agentic or black-box solutions, CallDataAI ensures that sensitive database data remains local.
• The AI (Google’s Gemini) only receives natural language input and returns the corresponding SQL/Pandas query – no raw or processed data ever leaves your environment.
- Fast and Efficient Execution
• The FastAPI backend will execute database queries directly to Azure datalate, ensuring low latency and lightning-fast results.
• No agentic looping or trial-and-error query generation – the system generates and executes the query in one clean pass.
- No Expensive Agentic Dependencies
• Many AI-driven systems rely on costly agentic frameworks that iterate unnecessarily. CallDataAI is streamlined, reducing costs and enhancing performance.
- Explainable, Not a Black Box
• All generated queries are fully visible to the user, ensuring transparency and trust.
• No ambiguous "magic" – users can review, validate, and refine their queries for complete control over their analysis if the user has technical background.
- Built for Real-World Applications
• Designed with data security, scalability, usability, and budget optimisation in mind, CallDataAI is perfect for handling sensitive government data and beyond.
Why It Matters
This project demonstrates how AI Engineering principles can make data analysis smarter and more secure:
- No external data sharing ensures compliance with sensitive data requirements.
- Fast and efficient query generation minimizes runtime costs while maximizing productivity.
- Transparency in generated code fosters trust and allows full user control.
Whether you’re a government analyst, data professional, or AI enthusiast, CallDataAI bridges the gap between natural language understanding and data operations, making data insights more accessible to non technical executive-level managers.
Please be kindly reminded that this is only an app for demo purpose only in the prototype stage. The final product may vary from the demo.
Back To The Top