How xinyi-estate-ntu/ai-agent works
Project Type and Purpose
• This is a data‑driven AI assistant application built with Streamlit. It exposes a chat interface for real‑estate queries, backed by an AI “agent” layer that loads, analyzes, and queries cached housing‐price data.
• The user interacts via a Streamlit frontend (app.py), which delegates requests to an internal API module and then through a query‑processing pipeline that in turn calls data‑loading and analysis components.
Main Components
a. Frontend Layer
• app.py: Streamlit UI and user interaction
b. API Layer
• AI_agent/api.py: single entry point for chat and real‑estate queries
c. Processing Pipeline
• AI_agent/query_processor.py: orchestrates NL query → structured request
• AI_agent/data_loader.py: loads raw data from data/, with caching
• AI_agent/data_analysis.py: computes statistics and generates charts
d. Supporting Modules
• AI_agent/config.py: holds model settings, cache settings, API keys
• AI_agent/utils.py: helper functions for logging, formatting, etc.
e. Data Store
• data/: CSV or other files with Taipei/New Taipei housing trades
f. External Services
• Groq API (via LangChain–Groq) for model inference
• LangSmith for experiment tracking
Relationships & Data Flow
• User → Streamlit (app.py)
└─calls→ API (api.py)
└─routes to→ Query Processor (query_processor.py)
├─fetches→ Raw data via Data Loader (data_loader.py)
├─computes→ Insights via Data Analysis (data_analysis.py)
└─reads configs→ (config.py)
• External: Query Processor and/or API call out to Groq and LangSmith using credentials from config.py.
Architectural Patterns & Principles
• Clear separation of concerns (UI vs. API vs. processing vs. data).
• Pipeline pattern in Query Processor for modular data operations.
• Caching layer in Data Loader to optimize repeated queries.
• Config centralization for keys and hyperparameters.