diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 3a08791..0000000 --- a/README.en.md +++ /dev/null @@ -1,166 +0,0 @@ -

Jagiellonian University Faculty Chatbot – Faculty of Mathematics and Computer Science

- -

- A RAG-based chatbot answering student and prospective-student questions about the JU Faculty of Mathematics and Computer Science. -
Built by the KSI Student Science Club. -

- -

- - - -

- -

🇵🇱 Polska wersja / Polish version (main)

- ---- - -## Table of contents - -- [About the project](#about-the-project) -- [Why this project exists](#why-this-project-exists) -- [Architecture](#architecture) -- [Installation](#installation) -- [Usage](#usage) -- [Repository structure](#repository-structure) -- [Team](#team) -- [Roadmap](#roadmap) -- [License](#license) - ---- - -## Language Versions / Wersje językowe - -- **English** — this document -- [Polish Version](README.md) - ---- - -## About the project - -Built as part of the **KSI Student Science Club (Koło Naukowe Studentów Informatyki)** at the Jagiellonian University Faculty of Mathematics and Computer Science (UJ WMI). The goal of the project is to build a dedicated chatbot using a **Retrieval-Augmented Generation (RAG)** architecture, able to answer Faculty-related questions based on verified documents and source data. - -> _The project is under active development. Some features are still being implemented._ - -**TODO (optional):** some example questions - -## Why this project exists - -Our project was born out of a need to make life easier for students (especially those just starting out at WMI), and to build a real, advanced engineering tool within the KSI Student Science Club. We wanted to combine theory with practice: - -- Use a RAG (Retrieval-Augmented Generation) architecture to search real Faculty databases and websites. -- Build a fully local AI ecosystem (based on, among others, a Qwen model). -- Create a centralized, intelligent assistant that answers questions about courses, credit requirements, or club materials in a few seconds, removing the need to click through dozens of subpages. - -## Architecture - -The system is built on a modern tech stack for RAG systems: - -- **LLM (Decoder):** `Qwen3-30B-A3B Q4_K_M` model, hosted locally. -- **Embeddings / Database:** (TODO: fill in). -- **Document processing:** `pymupdf4llm`, `BeautifulSoup4`, `pypdf`, `python-docx`. -- **Backend:** Python, (TODO: fill in). - -## Installation - -**TODO:** the project is still under construction, so a full end-to-end install guide doesn't exist yet. Below is a skeleton to fill in as each module is completed. - -### Requirements - -- Python 3.11+ -- **TODO:** remaining requirements - -### Steps - -```bash -# 1. Clone the repository -git clone -cd - -# 2. Create a virtual environment -python -m venv venv -source venv/bin/activate # Windows: venv\Scripts\activate - -# 3. Install dependencies -pip install -r requirements.txt -# TODO: create a single requirements.txt covering the whole project - -# 4. Configure environment variables -cp .env.example .env # TODO: add a .env.example file -# fill in MORDOR_COOKIE, USOS API credentials, etc. -``` - -## Usage - -Once the environment is set up (see [Installation](#installation)): - -```bash -# Scrape faculty websites and Wikipedia -python src/data/strony/scraper.py - -# Download files from Mordor -python src/data/mordor/files_downloader.py - -# Process downloaded Mordor files into chunks -python src/data/mordor/mordor_scraper.py - -# Query the USOS API (exploratory/anonymous mode) -python src/data/usos/usos_client.py services/fac/fac2 --params fac_id=WMI - -# TODO: fill in as next steps are completed -``` - -## Repository structure - -``` -. -├── docs/ -│ └── plan.txt # project plan, sprint notes -├── src/ -│ ├── backend/ -│ │ └── main.py # backend API (FastAPI) — in progress -│ └── data/ -│ ├── mordor/ # downloading and processing files from Mordor -│ ├── strony/ # scraper for faculty/club websites and Wikipedia -│ └── usos/ # USOS API client -├── README.md -└── README.en.md -``` - -**TODO:** expand this as more directories are added - -## Team - -**Mentor:** Oliwier Polak (@Kangurur) - -**Team members:** - -- **Karol Dziekan** (@Dariooo23) -- **Patrycja Jaworska** (@zazu1023) -- **Sonia Skuczeń** (@SonSku) -- **Mikołaj Suchan** (@Wuchan33) -- **Aleksandra Woźny** (@olkaa566) - -## Roadmap - -**Must have** - -- RAG (encoder + database + decoder) -- Data - -**Should have** - -- Simple website - -**Could have** - -- Nicer website -- Advanced features -- User accounts, etc. -- Automation - -**TODO:** replace with the current roadmap / link to the project board once the plan evolves. - -## License - -**TODO:** no license has been chosen yet. diff --git a/README.md b/README.md index 2343897..3027a95 100644 --- a/README.md +++ b/README.md @@ -1,137 +1,213 @@ -

Chatbot Wydziałowy UJ – Wydział Matematyki i Informatyki

+

Jagiellonian University Faculty Chatbot – Faculty of Mathematics and Computer Science

- Chatbot oparty o RAG, który odpowiada na pytania studentów i kandydatów dotyczące Wydziału Matematyki i Informatyki UJ. -
Tworzony przez Koło Naukowe KSI. + A RAG-based chatbot answering student and prospective-student questions about the UJ Faculty of Mathematics and Computer Science. +
Built by the KSI Student Science Club.

- - + +

+

+ + + + + + + +

+ --- -## Spis treści +## Table of contents + + -- [O projekcie](#o-projekcie) -- [Dlaczego ten projekt powstał](#dlaczego-ten-projekt-powstał) -- [Architektura](#architektura) -- [Instalacja](#instalacja) -- [Użycie](#użycie) -- [Struktura repozytorium](#struktura-repozytorium) -- [Zespół](#zespół) -- [Roadmapa](#roadmapa) -- [Licencja](#licencja) +- [About the project](#about-the-project) +- [Why this project exists](#why-this-project-exists) +- [Architecture](#architecture) +- [Installation](#installation) +- [Usage](#usage) +- [Repository structure](#repository-structure) +- [Team](#team) +- [License](#license) --- -## Wersje językowe / Language Versions +## About the project -- **Polski** — ten dokument -- [English Version](README.en.md) +A chatbot for the Jagiellonian University Faculty of Mathematics and Computer Science (UJ WMI), built by the **KSI Student Science Club**. It uses **Retrieval-Augmented Generation (RAG)** to answer Faculty-related questions grounded in real, verified sources instead of guessing. ---- +What it does: + +- Answers questions about credit requirements, course rules, and Faculty procedures using documents indexed from Mordor (the Faculty's internal file-sharing platform) and Faculty/club websites. +- Pulls staff contact info, office hours, and positions directly from the USOS API. +- Surfaces the actual source file (including scanned PDFs and images) behind an answer, not just a generated summary. +- Runs entirely on a self-hosted stack — local embeddings and a local LLM served through Ollama, no third-party AI API calls. + -## O projekcie +> _The project is under active development. The RAG pipeline and backend API are functional._ -Projekt realizowany w ramach **Koła Naukowego Studentów Informatyki (KSI)** przy Wydziale Matematyki i Informatyki Uniwersytetu Jagiellońskiego (UJ WMI). Celem projektu jest stworzenie dedykowanego chatbota wykorzystującego architekturę **RAG (Retrieval-Augmented Generation)**, który sprawnie odpowiada na pytania związane z wydziałem, bazując na sprawdzonych dokumentach i danych źródłowych. + -**TODO (opcjonalnie):** jakieś przykłady pytań +## Why this project exists -## Dlaczego ten projekt powstał +Our project was born out of a need to make life easier for students (especially those just starting out at WMI), and to build a real, advanced engineering tool within the KSI Student Science Club. We wanted to combine theory with practice: -Nasz projekt powstał z potrzeby ułatwienia życia studentom (szczególnie tym zaczynającym swoją przygodę na WMI) oraz stworzenia realnego, zaawansowanego narzędzia inżynierskiego w ramach Koła Naukowego Studentów Informatyki (KSI). Chcieliśmy połączyć teorię z praktyką: +- Use a RAG (Retrieval-Augmented Generation) architecture to search real Faculty databases and websites. +- Build a fully local AI ecosystem (served through Ollama, running a Qwen model). +- Create a centralized, intelligent assistant that answers questions about courses, credit requirements, or club materials in a few seconds, removing the need to click through dozens of subpages. -- Wykorzystać architekturę RAG (Retrieval-Augmented Generation) do przeszukiwania realnych, wydziałowych baz danych i stron. -- Zbudować w pełni lokalny ekosystem AI (oparty m.in. o model Qwen). -- Stworzyć scentralizowanego, inteligentnego asystenta, który w kilka sekund odpowie na pytania o przedmioty, zasady zaliczeń czy materiały z koła, eliminując konieczność przeklikiwania dziesiątek podstron. +## Architecture -## Architektura +- **LLM (Decoder):** `Qwen2.5:14b`, served locally through [Ollama](https://ollama.com/) (`src/backend/llm/client.py`). Model and host are configurable via `OLLAMA_MODEL` / `OLLAMA_HOST`. +- **Embeddings:** `sentence-transformers`, defaulting to [`sdadas/mmlw-roberta-large`](https://huggingface.co/sdadas/mmlw-roberta-large) — a model tuned for Polish retrieval (`src/backend/RAG/encoder.py`). Swappable via `RAG_EMBEDDING_MODEL` without code changes. +- **Vector store:** [ChromaDB](https://www.trychroma.com/) (`PersistentClient`), storing all three data sources in a single collection distinguished by a `source` field (`src/backend/RAG/vectorstore.py`). +- **Relational database:** SQLAlchemy + Alembic migrations, SQLite by default (configurable via `DATABASE_URL`) — stores users, conversations, and messages (`src/backend/models.py`, `src/backend/database.py`). +- **Backend API:** FastAPI (`src/backend/main.py`), exposing chat and conversation endpoints. +- **Document processing:** `pymupdf4llm`, `BeautifulSoup4`, `pypdf`, `python-docx`. +- **Frontend:** React 19 + TypeScript + Vite + Tailwind CSS (`src/frontend/`). -System opiera się na nowoczesnym stosie technologicznym dla systemów RAG: +### Data sources -- **LLM (Decoder):** Model `Qwen3-30B-A3B Q4_K_M` hostowany lokalnie. -- **Embeddings / Baza Danych:** (TODO: uzupełnić). -- **Przetwarzanie dokumentów:** `pymupdf4llm`, `BeautifulSoup4`, `pypdf`, `python-docx`. -- **Backend:** Python, (TODO: uzupełnić). +Three independent ingestion pipelines feed the vector store (`src/backend/RAG/ingest/`), unified under one CLI: -## Instalacja +- **Mordor** (`from_mordor.py`) — files downloaded from the Faculty's internal file-sharing platform via `src/data/mordor/files_downloader.py`. +- **Strony** (`from_strony.py`) — a scraper over Faculty/club websites (`src/data/strony/scraper.py`). +- **USOS** (`from_usos.py`) — data pulled through the USOS API (`src/data/usos/`), covering both anonymous and signed/authenticated calls. -**TODO:** projekt jest w trakcie budowy, więc pełna instrukcja instalacji end-to-end jeszcze nie istnieje. Poniżej szkielet do uzupełnienia w miarę powstawania poszczególnych modułów. +## Installation -### Wymagania +### Requirements -- Python 3.11+ -- **TODO:** reszta wymagań +- Python 3.10+ +- Node.js (for the frontend) +- [Ollama](https://ollama.com/) running locally with a chat model pulled (default: `qwen2.5:14b`) -### Kroki +### Steps ```bash -# 1. Sklonuj repozytorium -git clone -cd +# 1. Clone the repository +git clone git@github.com:KSIUJ/chatbot.git +cd chatbot -# 2. Utwórz środowisko wirtualne +# 2. Create a virtual environment python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate -# 3. Zainstaluj zależności +# 3. Install backend dependencies pip install -r requirements.txt -# TODO: zrobić requirements.txt obejmujące cały projekt -# 4. Skonfiguruj zmienne środowiskowe -cp .env.example .env # TODO: dodać plik .env.example -# uzupełnij m.in. MORDOR_COOKIE, dane USOS API +# 3a. Install extra dependencies needed only for the strony/mordor scrapers +# (not required if you only run the backend/RAG pipeline) +pip install -r src/data/strony/requirements.txt +pip install -r src/data/mordor/requirements.txt + +# 4. Configure environment variables +cp .env.example .env +# fill in USOS_CONSUMER_KEY / USOS_CONSUMER_SECRET if you need signed USOS calls, +# and optionally RAG_EMBEDDING_MODEL / RAG_QUERY_PREFIX / RAG_PASSAGE_PREFIX +# +# The following are NOT in .env.example but can be added manually if needed: +# MORDOR_COOKIE, DATABASE_URL, FRONTEND_ORIGINS, OLLAMA_HOST, OLLAMA_MODEL +# (see defaults in src/backend/config.py, database.py, llm/client.py) + +# 5. Apply database migrations +python -m alembic upgrade head + +# 6. Install frontend dependencies +cd src/frontend +npm install +``` + +## Usage + +### Backend API + +```bash +# from the repo root, with the venv active +uvicorn src.backend.main:app --reload ``` -## Użycie +Key endpoints: -Po skonfigurowaniu środowiska (patrz [Instalacja](#instalacja)): +- `GET /health` — health check +- `POST /conversations` — start a new conversation +- `GET /conversations/{id}` — fetch a conversation and its message history +- `POST /chat` — send a message (optionally with `conversation_id`), get back the assistant's reply plus matched source files + +### Frontend ```bash -# Pobranie danych ze stron wydziałowych i Wikipedii +cd src/frontend +npm run dev +``` + +### Data ingestion + +```bash +# Scrape faculty/club websites and Wikipedia python src/data/strony/scraper.py -# Pobranie plików z Mordoru +# Download files from Mordor python src/data/mordor/files_downloader.py -# Przetworzenie pobranych plików z Mordoru na chunki (do bazy wektorowej) -python src/data/mordor/mordor_scraper.py - -# Zapytania do USOS API (tryb eksploracyjny/anonimowy) +# Pull data from USOS (exploratory CLI) python src/data/usos/usos_client.py services/fac/fac2 --params fac_id=WMI -# TODO: uzupełnić przy następnych krokach +# Ingest all three sources into the vector store +python -m src.backend.RAG.ingest.run_ingest +# or a single source: +python -m src.backend.RAG.ingest.run_ingest --source mordor +``` + +### Tests + +```bash +pytest ``` -## Struktura repozytorium +## Repository structure ``` . -├── docs/ -│ └── plan.txt # plan projektu, notatki ze sprintów +├── alembic/ # database migrations +├── data/ # runtime output (gitignored, empty in repo) +├── dataset/ # runtime vector store output (gitignored, empty in repo) +├── docs/ # sprint notes ├── src/ │ ├── backend/ -│ │ └── main.py # API backendu (FastAPI) — w budowie -│ └── data/ -│ ├── mordor/ # pobieranie i przetwarzanie plików z Mordoru -│ ├── strony/ # scraper stron wydziałowych, kół, Wikipedii -│ └── usos/ # klient USOS API -├── README.md -└── README.en.md +│ │ ├── main.py # FastAPI app: chat + conversation endpoints +│ │ ├── database.py, models.py # SQLAlchemy models (users, conversations, messages) +│ │ ├── config.py +│ │ ├── request.py, response.py +│ │ ├── llm/ # Ollama client + prompt/answer generation +│ │ └── RAG/ +│ │ ├── encoder.py # text -> embeddings +│ │ ├── vectorstore.py # ChromaDB wrapper +│ │ ├── retriever.py, context_builder.py +│ │ └── ingest/ # per-source loaders (mordor, strony, usos) + CLI +│ ├── data/ # source code for scraping/downloading (mordor, strony, usos) +│ └── frontend/ # React + TypeScript + Vite + Tailwind app +├── tests/backend/RAG/ # pytest suite for the RAG pipeline +├── requirements.txt +└── README.md ``` -**TODO:** rozbudować opis w miarę powstawania kolejnych katalogów - -## Zespół +## Team **Mentor:** Oliwier Polak (@Kangurur) -**Członkowie zespołu:** +**Team members:** - **Karol Dziekan** (@Dariooo23) - **Patrycja Jaworska** (@zazu1023) @@ -139,26 +215,6 @@ python src/data/usos/usos_client.py services/fac/fac2 --params fac_id=WMI - **Mikołaj Suchan** (@Wuchan33) - **Aleksandra Woźny** (@olkaa566) -## Roadmapa - -**Must have** - -- RAG (encoder + baza danych + decoder) -- Dane - -**Should have** - -- Prosta strona - -**Could have** - -- Ładna strona -- Zaawansowane funkcjonalności -- Konta użytkowników itp. -- Automatyzacja - -**TODO:** zamienić na aktualną roadmapę / link do tablicy projektowej, gdy plan się rozwinie. - -## Licencja +## License -**TODO:** projekt nie ma jeszcze wybranej licencji. +**TODO:** no license has been chosen yet.