feat: Expand user data query, refine LLM course generation prompt with temperature, and update default local LLM model to llama3.2:1b.

This commit is contained in:
2026-01-17 03:06:12 -03:00
parent 62677f1beb
commit dd2c3f666d
2 changed files with 17 additions and 18 deletions
+2 -2
View File
@@ -111,7 +111,7 @@ update_env() {
if [ "$HAS_NVIDIA" = true ]; then if [ "$HAS_NVIDIA" = true ]; then
update_env "WHISPER_IMAGE" "fedirz/faster-whisper-server:latest-cuda" update_env "WHISPER_IMAGE" "fedirz/faster-whisper-server:latest-cuda"
update_env "WHISPER_DEVICE" "cuda" update_env "WHISPER_DEVICE" "cuda"
update_env "LOCAL_LLM_MODEL" "llama3:8b" update_env "LOCAL_LLM_MODEL" "llama3.2:1b"
# Uncomment GPU deploy section in docker-compose.yml while preserving indentation # Uncomment GPU deploy section in docker-compose.yml while preserving indentation
sed -i 's/^ #deploy:/ deploy:/' docker-compose.yml sed -i 's/^ #deploy:/ deploy:/' docker-compose.yml
sed -i 's/^ # resources:/ resources:/' docker-compose.yml sed -i 's/^ # resources:/ resources:/' docker-compose.yml
@@ -163,7 +163,7 @@ fi
until curl -s http://localhost:11434/api/tags &> /dev/null; do sleep 2; done until curl -s http://localhost:11434/api/tags &> /dev/null; do sleep 2; done
if [ "$HAS_NVIDIA" = true ]; then if [ "$HAS_NVIDIA" = true ]; then
ollama pull llama3:8b ollama pull llama3.2:1b
else else
ollama pull phi3:mini ollama pull phi3:mini
fi fi
+15 -16
View File
@@ -2473,7 +2473,7 @@ pub async fn get_all_users(
} }
let users = sqlx::query_as::<_, UserResponse>( let users = sqlx::query_as::<_, UserResponse>(
"SELECT id, email, full_name, role, organization_id FROM users WHERE organization_id = $1", "SELECT id, email, full_name, role, organization_id, xp, level, avatar_url, bio, language FROM users WHERE organization_id = $1",
) )
.bind(org_ctx.id) .bind(org_ctx.id)
.fetch_all(&pool) .fetch_all(&pool)
@@ -2897,27 +2897,25 @@ pub async fn generate_course(
) )
}; };
let system_prompt = r#"You are an expert curriculum designer. let system_prompt = r#"You are a curriculum expert.
Design a structured course based on the topic provided. Generate a course in JSON.
If the topic is for children or youth, use interactive content types: Structure:
- 'hotspot': Identifying image parts.
- 'memory-match': Card matching game.
- 'quiz': Standard questions.
Return ONLY a valid JSON object with the following structure:
{ {
"title": "Clear and Engaging Course Title", "title": "Course Title",
"description": "Short overview and objectives", "description": "Description",
"modules": [ "modules": [
{ {
"title": "Module Name", "title": "Module Title",
"position": 1,
"lessons": [ "lessons": [
{ "title": "Lesson Name", "position": 1, "content_type": "text|video|hotspot|memory-match|quiz" } { "title": "Lesson Title", "content_type": "text" }
] ]
} }
] ]
}"#; }
RULES:
1. content_type MUST be one of: text, video, quiz.
2. NO nested lessons.
3. Return ONLY the JSON object."#;
let mut request = client.post(&url).json(&json!({ let mut request = client.post(&url).json(&json!({
"model": model, "model": model,
@@ -2925,7 +2923,8 @@ Return ONLY a valid JSON object with the following structure:
{ "role": "system", "content": system_prompt }, { "role": "system", "content": system_prompt },
{ "role": "user", "content": format!("Create a course about: {}", payload.prompt) } { "role": "user", "content": format!("Create a course about: {}", payload.prompt) }
], ],
"response_format": { "type": "json_object" } "response_format": { "type": "json_object" },
"temperature": 0.1
})); }));
if !auth_header.is_empty() { if !auth_header.is_empty() {