How amsterdam-ai-team/citizen-signals-rag-chatbot-system works
Project Type and Purpose
• This project is an agentic Retrieval Augmented Generation (RAG) system aimed at automating responses for citizen reports in Amsterdam.
• Its purpose is to retrieve and combine relevant information from various data sources, enabling quick, context-aware responses to citizen reports while reducing municipal workload.
File Structure
• The top-level files indicate configuration (.flake8, .gitignore, requirements.txt) and licensing, demonstrating proper development discipline.
• The key directories include:
• src: Contains the core Python modules including the central agent (central_agentic_agent.py), configuration (config.py), process logic (process_melding.py), database population scripts (populate_permit_db_faiss.py, populate_policy_db_chroma.py), and a tools folder which houses individual tool scripts (for tasks such as address handling, license plate processing, etc.).
• helpers: Under src/helpers, utility functions (embedding_helpers, geo_utils, melding_helpers) support the central logic.
• static and templates: Provide the front-end components, suggesting that the system includes a web-based chatbot UI (app.py in src is used to start this interface).
• media: Contains demonstration media (demo.mov and demo-image) used in the README.
• The architecture exhibits a separation between:
• The core orchestration/logic layer (central agent).
• Supporting tool components for specialized tasks.
• Frontend/Interface (via static assets, templates, and app.py).
• Configuration and deployment scripts (e.g., pre-commit hooks, blobfuse for internal storage integration).
Key Components to Highlight
• Frontend/UI Component:
• app.py serves as the entry point for the web interface.
• Static assets (styles.css, scripts.js, images) and HTML template (index.html) are used for presenting the chatbot.
• Core Logic (Backend):
• The central agent (central_agentic_agent.py) orchestrates the processing by receiving citizen reports and delegating tasks to specific tools.
• The configuration module (config.py) sets up the agent’s parameters, guidelines, and instructions.
• Tools and Helper Modules:
• Various tool scripts in src/tools (e.g., address_owner_tool, license_plate_permit_tool, etc.), each designed to process different types of citizen reports.
• Helper functions (embedding_helpers, geo_utils, melding_helpers) for preprocessing data, embeddings, or geospatial calculations.
• Data Ingestion/Population:
• Scripts like populate_permit_db_faiss.py and populate_policy_db_chroma.py indicate processes for populating or interfacing with internal databases (likely for historical or contextual data).
• External Services/Integration:
• Integration with an LLM (e.g., GPT-4o or other open-source models) is a central part of the reasoning and result assembly.
• Built-in instructions for API keys (via a secrets file, API_KEYS) and potential external services like Azure ML for deployment.
• Internal Storage:
• A blobfuse script suggests that there is mounting of internal storage containers for sensitive meldingen data.
Relationships and Interactions
• The central agent takes input (a report or query) from the frontend and then:
• Retrieves necessary information via calls to appropriate tool components.
• Interacts with helper modules for data processing.
• Interfaces with the LLM to generate the final response.
• Data flows should indicate:
• From user entry (chat interface) → central agent.
• The agent routes to various tools (each represented as separate components) → collates results and delivers a consolidated output.
Architectural Patterns and Technologies
• Emphasis on decoupling (central agent vs. individual tool modules).
• Clearly separate presentation (frontend web UI) from business logic (backend central agent and tools).
• RAG (Retrieval Augmented Generation) pattern where retrieval (database lookups, tool functions) feeds into a generation module (LLM).
• Technologies and frameworks:
• Python for backend logic; templates and static assets for the frontend.
• Use of API integrations (e.g., with OpenAI and Azure ML) and configuration management.