How bagumeow/iuh_fit_chatbot works
Main Components
• Frontend/Client: Although not elaborated in the repository, the browser-based interaction (http://localhost:5000 from the README) implies a client interface.
• Backend API: The FastAPI application defined in main_app.py which serves as the entry point.
• Routers: Under the “router” directory, you have modules like chatbot.py, tools.py, and user.py. These represent different endpoints that handle specific API calls.
• Service/Business Logic:
• ChatbotFIT/src: Contains two major submodules:
• base/llm_model.py: Likely handles interaction with the Language Model.
• rag: This directory includes the core of the RAG pipeline with file_loader (to load PDF files from the “data” folder), rag_chain (to manage the RAG workflow), main (possibly an entry point for RAG tasks), and vector_store (for managing embedding storage and similarity search).
• Data Layer:
• The “data” directory stores PDF files, which are used as the knowledge base for the RAG process.
• Tools:
• Supplementary utilities in “tools/tools.py” which might support additional functionalities.
• Database:
• PostgreSQL or Supabase is referenced in the README for persistent storage of application data.
Relationships and Interactions
• The client (browser) sends requests which are routed through FastAPI (main_app.py) to the appropriate endpoints in the “router” modules.
• When a chat request is made, the chatbot endpoint interacts with the RAG components:
• The LLM model (from base/llm_model.py) is used to process language.
• The RAG chain (in src/rag/rag_chain.py) leverages file_loader and vector_store to retrieve data from PDFs and generate informed responses.
• Database interactions occur to handle user data, configuration, or caching responses and search indexes; this can be integrated within business logic or router-level functions.
• Additional utilities in the “tools” directory provide other support features.
Architectural Patterns
• Separation of Concerns: There is a clear division between the API layer (FastAPI, routers), business logic (LLM models, RAG pipeline), and the data layer (PDF data and external database).
• Modular Design: Distinct modules for different functionalities (LLM, RAG, routing) make the system easier to understand and scale.
• RAG Pipeline: The use of file loaders, vector stores, and chain processing indicates a typical RAG architecture where documents are ingested and embeddings are generated for retrieval.
Relevant Technologies and Frameworks
• FastAPI for the backend server.
• LangChain for managing interactions with language models and the RAG pipeline.
• PostgreSQL/Supabase for database operations.
• Possibly Uvicorn as the server runner (as mentioned in the README).
Detail and Clarity
• Brief notes on important functions like language model integration and document retrieval which are central to the RAG approach.