Commit 39e28feb authored by Kantz's avatar Kantz
Browse files

update readme

parent 69da1c59
## Run the app # DER Tutor
## Prequisits
- Postgres-Database [Database (pgvector) setup]
- sources folder with your markdown files structured with section, subsection and child
- OpenAI endpoint
- Ollama Instanz
if you want to use the task mode you need :
- task folder in sources with your tasks
- `_subsection_map.json`.
## Setup
Configurate the `backend/.env`-file based on the `backend/.env-example`. You can che following modes:
- QA : Direct answer based on the retrieval
- Tutor: Helps with tips on a task given by the user
- Task: A mode where you can select from the list in the taskfolder and get help with this Task.
Backend (Python): Backend (Python):
```powershell
``` powershell
cd math-tutor/backend cd math-tutor/backend
python -m venv .venv python -m venv .venv
.\.venv\Scripts\Activate.ps1 .\.venv\Scripts\Activate.ps1
pip install -r requirements.txt pip install -r requirements.txt
```
Frontend (Vite):
```
cd math-tutor/frontend
npm install
```
## Run the app
Backend (Python):
```powershell
cd math-tutor/backend
.\.venv\Scripts\Activate.ps1
python -m uvicorn app.main:app --reload python -m uvicorn app.main:app --reload
``` ```
Frontend (Vite): Frontend (Vite):
```powershell ```powershell
cd math-tutor/frontend cd math-tutor/frontend
npm install
npm run dev npm run dev
``` ```
To make it accessible over the network. To make it accessible over the network.
Add the frontend- and backend-adress in the .env file in the frontend- and backend-folder. Add the frontend- and backend-adress in the `backend/.env`-file in the frontend- and backend-folder. Use the following command to run the front- and backend.
```powershell
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
npm run dev -- --host 0.0.0.0 npm run dev -- --host 0.0.0.0
```
## Database (pgvector) setup ## Database (pgvector) setup
Ensure `POSTGRES_URL` and embedding env vars are in `backend/.env`: Ensure `POSTGRES_URL` and embedding env vars are in `backend/.env`:
```
``` env
POSTGRES_URL=postgresql://user:pass@host:5432/db POSTGRES_URL=postgresql://user:pass@host:5432/db
OPENAI_BASE_URL=... OPENAI_BASE_URL=...
OPENAI_API_KEY=... OPENAI_API_KEY=...
...@@ -33,6 +75,7 @@ OPENAI_EMBED_MODEL=... ...@@ -33,6 +75,7 @@ OPENAI_EMBED_MODEL=...
Create the Postgres database before running init. Create the Postgres database before running init.
Init DB schema: Init DB schema:
```powershell ```powershell
cd math-tutor/backend cd math-tutor/backend
.\.venv\Scripts\Activate.ps1 .\.venv\Scripts\Activate.ps1
...@@ -40,6 +83,7 @@ python -m scripts.retrieval_cli init-db ...@@ -40,6 +83,7 @@ python -m scripts.retrieval_cli init-db
``` ```
Ingest markdown docs (expects `markdown/sections`, `markdown/subsections`, `markdown/childs`): Ingest markdown docs (expects `markdown/sections`, `markdown/subsections`, `markdown/childs`):
```powershell ```powershell
cd math-tutor/backend cd math-tutor/backend
.\.venv\Scripts\Activate.ps1 .\.venv\Scripts\Activate.ps1
...@@ -47,6 +91,7 @@ python -m scripts.retrieval_cli ingest --base markdown --clear ...@@ -47,6 +91,7 @@ python -m scripts.retrieval_cli ingest --base markdown --clear
``` ```
Query via CLI: Query via CLI:
```powershell ```powershell
cd math-tutor/backend cd math-tutor/backend
.\.venv\Scripts\Activate.ps1 .\.venv\Scripts\Activate.ps1
...@@ -56,9 +101,11 @@ python -m scripts.retrieval_cli query --q "Was ist eine Teilmenge?" --k 8 --expa ...@@ -56,9 +101,11 @@ python -m scripts.retrieval_cli query --q "Was ist eine Teilmenge?" --k 8 --expa
## Configuration ## Configuration
Differend Orchestrators: Differend Orchestrators:
- Edit `math-tutor/backend/app/api/chat.py` and update `SYSTEM_PROMPT`. - Edit `math-tutor/backend/app/api/chat.py` and update `SYSTEM_PROMPT`.
Retrieval settings: Retrieval settings:
- Frontend request parameters live in `math-tutor/frontend/src/pages/App.tsx`: - Frontend request parameters live in `math-tutor/frontend/src/pages/App.tsx`:
- `k` - `k`
- `expand_links` - `expand_links`
...@@ -67,8 +114,17 @@ Retrieval settings: ...@@ -67,8 +114,17 @@ Retrieval settings:
- Core retrieval logic is in `math-tutor/backend/app/services/vector_store.py` (`retrieve`). - Core retrieval logic is in `math-tutor/backend/app/services/vector_store.py` (`retrieve`).
## Testing ## Testing
currently there a multiple test to test some components seperatly. Check the test files for specific calling. Here are some example calls.
```powershell
python -m test.hint_test --chat-id draft_session_mlgmxxzc_avmjfb python -m test.hint_test --chat-id draft_session_mlgmxxzc_avmjfb
python -m test.retrieval_store_test --query "Was ist eine Teilmenge?" --k 8 --expand python -m test.retrieval_store_test --query "Was ist eine Teilmenge?" --k 8 --expand
python -m test.retrieval_store_test --query "Was ist eine Teilmenge?" --k 3 --subsections 1:1 python -m test.retrieval_store_test --query "Was ist eine Teilmenge?" --k 3 --subsections 1:1
python -m test.math_intent_test --input "Integrate x^2" --input "Was ist 2+2?" python -m test.math_intent_test --input "Integrate x^2" --input "Was ist 2+2?"
python -m test.decision_test --chat-id draft_session_mlgmxxzc_avmjfb python -m test.decision_test --chat-id draft_session_mlgmxxzc_avmjfb
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment