Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3983ee4
feedback for plg
Dec 17, 2025
0f908b9
feedback for plg
Dec 17, 2025
d39118a
Feedback payload fixed
Dec 19, 2025
51fc035
rubric evaluation
manua-glitch Jan 19, 2026
5247664
rubric evaluation
manua-glitch Jan 19, 2026
01580b5
changed LMS payload
manua-glitch Jan 20, 2026
c9c7d49
feedback transalation
manua-glitch Jan 30, 2026
3e28c94
feedback translation
manua-glitch Jan 30, 2026
3f20132
video analysis
Feb 9, 2026
7c850ae
video analysis
manua-glitch Feb 9, 2026
6118388
stock messages
manua-glitch Feb 12, 2026
0dc59d1
video analysis
manua-glitch Feb 12, 2026
0484766
plg change
manua-glitch Feb 17, 2026
0db4070
gemini settings
manua-glitch Feb 17, 2026
a05c81f
different evaluation types
manua-glitch Apr 27, 2026
f0bb0d2
New submission types
manua-glitch Apr 29, 2026
92cae9e
added submission types
manua-glitch May 12, 2026
c8b240f
handling incorrect input payload
manua-glitch May 20, 2026
ed2c0c7
get student details
manua-glitch May 23, 2026
18c2739
pip package
Jun 1, 2026
f37066f
handling failed messges
Jun 1, 2026
d12be8c
smaller model for text evaluation
Jun 1, 2026
9617f87
cache assignments
manua-glitch Jun 1, 2026
b48fe7e
json fix
manua-glitch Jun 1, 2026
3b58adc
assignment fix
manua-glitch Jun 2, 2026
b6079f6
test_consumer
manua-glitch Jun 2, 2026
ad0462a
submission rules fix
manua-glitch Jun 2, 2026
31da16f
Merge branch 'video_analysis' of https://github.com/theapprenticeproj…
manua-glitch Jun 2, 2026
47428b4
consumer runner
Aug 4, 2026
3e371e2
valid/invalid submission
Aug 4, 2026
6634889
api chagne
Aug 4, 2026
b6926c2
api change
Aug 4, 2026
b24c33e
api change
Aug 4, 2026
fff65b6
submission flow
Aug 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
*.swp
tags
node_modules
__pycache__
__pycache__
*scratch*
*.vscode
*/private/*
*test_consumer_payload.py
24 changes: 24 additions & 0 deletions deploy/systemd/rag-service-consumer.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Unit]
Description=RAG Service RabbitMQ Consumer for rag.evalix.xyz
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=frappe
Group=frappe
WorkingDirectory=/home/frappe/frappe-bench
Environment=PYTHONUNBUFFERED=1
Environment=PATH=/home/frappe/frappe-bench/env/bin:/usr/local/bin:/usr/bin:/bin
ExecStart=/usr/local/bin/bench --site rag.evalix.xyz execute rag_service.scripts.console_consumer.start_consumer
Restart=always
RestartSec=10
StartLimitIntervalSec=0
KillSignal=SIGINT
TimeoutStopSec=30
StandardOutput=journal
StandardError=journal
SyslogIdentifier=rag-service-consumer

[Install]
WantedBy=multi-user.target
112 changes: 112 additions & 0 deletions private/local_docker_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Local Docker setup for rag_service

This guide creates a fresh local Frappe site named `rag_service.localhost` using Docker, Postgres, Redis, and the local `rag_service` app source from this repository.

The recommended path is the root stack script:

```sh
cd /Users/TAP/Documents/Git/LMS
cp .env.example env.local
./scripts/start_local_docker.sh
```

## External RabbitMQ

RabbitMQ is created externally in CloudAMQP:

```text
https://customer.cloudamqp.com/login
```

Fill these root `env.local` values from the CloudAMQP instance:

```dotenv
RABBITMQ_HOST=
RABBITMQ_PORT=5672
RABBITMQ_VIRTUAL_HOST=
RABBITMQ_USERNAME=
RABBITMQ_PASSWORD=
RABBITMQ_PLAGIARISM_RESULTS_QUEUE=plagiarism_feedback
RABBITMQ_FEEDBACK_RESULTS_QUEUE=feedback_results
```

## Required local DocTypes discovered in code

The active folders reviewed were:

- `rag_service/core`
- `rag_service/feedback_utils`
- `rag_service/utils`
- `rag_service/rag_service/doctype`

The local setup needs these settings available:

- `RabbitMQ Settings`: used by `utils/rabbitmq_consumer.py` and `utils/queue_manager.py`.
- `GCS Settings`: used by `utils/gcp_service_client.py`.
- `RAG Settings`: used by `core/assignment_context_manager.py` to fetch assignment and student context from CRM.
- `LLM Settings`: used by most feedback generation paths.
- `Gemini Settings`: used by Gemini-specific image evaluation paths.
- `Prompt Segment` and `Prompt Template`: required by template-driven feedback generation.

The root script symlinks `/home/frappe/frappe-bench/apps/rag_service` to `/workspace/rag_service`, installs `rag_service` in editable mode, installs `business_theme_v14`, and seeds `RabbitMQ Settings`, `GCS Settings`, and `RAG Settings` from `env.local`. It also creates optional `LLM Settings` and `Gemini Settings` rows when the related env values are present.

## Values to set before use

In root `env.local`, set:

```dotenv
RAG_TAP_LMS_BASE_URL=http://tap_lms.localhost:8000
RAG_ASSIGNMENT_CONTEXT_ENDPOINT=/api/method/tap_lms.api.get_assignment_context
RAG_STUDENT_CONTEXT_ENDPOINT=/api/method/tap_lms.api.get_student_context
RAG_TAP_LMS_API_KEY=
RAG_TAP_LMS_API_SECRET=
RAG_ENABLE_CACHING=1
RAG_CACHE_DURATION_DAYS=1
```

For model-backed feedback generation, also set one of:

```dotenv
RAG_LLM_PROVIDER=Gemini
RAG_LLM_MODEL_NAME=
RAG_LLM_API_KEY=
RAG_LLM_API_SECRET=
```

or:

```dotenv
RAG_GEMINI_MODEL_NAME=
RAG_GEMINI_PROJECT_ID=
RAG_GEMINI_LOCATION=us-central1
RAG_GEMINI_CREDENTIALS_JSON={}
```

## Start RAG after setup

```sh
docker compose --env-file env.local -f docker/local/docker-compose.yml exec rag-dev bash -lc "cd /home/frappe/frappe-bench && bench start"
```

Open:

```text
http://rag_service.localhost:8001
```

Login:

```text
User: Administrator
Password: the RAG_ADMIN_PASSWORD value from `env.local`
```

## Consumer

The app exposes a Frappe command for the RabbitMQ consumer. After the site is installed and RabbitMQ settings are valid, run it from the RAG dev container:

```sh
docker compose --env-file env.local -f docker/local/docker-compose.yml exec rag-dev bash -lc "cd /home/frappe/frappe-bench && bench --site rag_service.localhost start-rag-consumer"
```

If the command path changes, inspect `rag_service/hooks.py` and `rag_service/commands`.
67 changes: 67 additions & 0 deletions private/local_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os

import frappe


def _as_float(value, default):
try:
return float(value)
except (TypeError, ValueError):
return default


def _as_int(value, default):
try:
return int(value)
except (TypeError, ValueError):
return default


def seed_optional_records():
"""Seed optional local LLM records from environment variables.

Single DocTypes are set from the shell script. These regular DocTypes need
insert/update logic and are only useful when credentials are present.
"""
llm_model_name = os.getenv("RAG_LLM_MODEL_NAME")
llm_api_key = os.getenv("RAG_LLM_API_KEY")
gemini_model_name = os.getenv("RAG_GEMINI_MODEL_NAME")
gemini_project_id = os.getenv("RAG_GEMINI_PROJECT_ID")

if llm_model_name and llm_api_key:
name = f"Local {os.getenv('RAG_LLM_PROVIDER', 'Gemini')} {llm_model_name}"
if frappe.db.exists("LLM Settings", name):
doc = frappe.get_doc("LLM Settings", name)
else:
doc = frappe.new_doc("LLM Settings")
doc.name = name

doc.provider = os.getenv("RAG_LLM_PROVIDER", "Gemini")
doc.model_name = llm_model_name
doc.api_key = llm_api_key
doc.api_secret = os.getenv("RAG_LLM_API_SECRET", "")
doc.temperature = _as_float(os.getenv("RAG_LLM_TEMPERATURE"), 0)
doc.max_tokens = _as_int(os.getenv("RAG_LLM_MAX_TOKENS"), 2000)
doc.is_active = 1
doc.is_default = 1
doc.save(ignore_permissions=True)

if gemini_model_name and gemini_project_id:
name = f"Local Gemini {gemini_model_name}"
if frappe.db.exists("Gemini Settings", name):
doc = frappe.get_doc("Gemini Settings", name)
else:
doc = frappe.new_doc("Gemini Settings")
doc.name = name

doc.model_name = gemini_model_name
doc.project_id = gemini_project_id
doc.location = os.getenv("RAG_GEMINI_LOCATION", "us-central1")
doc.credentials_json = os.getenv("RAG_GEMINI_CREDENTIALS_JSON", "{}")
doc.temperature = _as_float(os.getenv("RAG_LLM_TEMPERATURE"), 0)
doc.max_tokens = _as_int(os.getenv("RAG_LLM_MAX_TOKENS"), 2000)
doc.is_active = 1
doc.is_default = 1
doc.save(ignore_permissions=True)

frappe.db.commit()
33 changes: 0 additions & 33 deletions rag_service/api/test_api.py

This file was deleted.

Empty file removed rag_service/config/__init__.py
Empty file.
Loading