Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/diazdavilajesus16-stack/IA-LUMINA/llms.txt

Use this file to discover all available pages before exploring further.

The Chat page is the heart of Lumina AI. It gives students a single, conversational space to ask academic questions, get explanations, and access study tools—without navigating away from the conversation. The interface is deliberately minimal: a dark galaxy-themed background with animated twinkling stars, a left sidebar for navigation and stats, and a centered message thread that keeps the focus on learning.

Chat interface overview

When you open Lumina AI, the Chat page loads immediately. The layout has three zones:
  • Galaxy background — A deep-space visual with 140 procedurally placed stars that twinkle using CSS animations. If assets/galaxy.png is present it is loaded as a base64 background image; otherwise a CSS radial gradient fallback is used.
  • Left sidebar — Persistent across all pages. Shows the Lumina robot avatar, navigation buttons, quick-action shortcuts, gamification stats, and the PDF upload panel.
  • Chat thread — A scrollable message area (max-width: 980px, centered) with animated message bubbles. Assistant messages appear on the left with an avatar; user messages appear on the right in a purple gradient bubble.
Each message bubble displays the message content and a timestamp formatted as H:MM AM/PM. User bubbles show a double-checkmark (✓✓) after the timestamp.
Lumina AI responds entirely in Spanish. All built-in prompts, quick actions, and chatbot responses are in Spanish (es-ES). The voice recognition engine is also configured for Spanish.

Text input

Students type questions in a fixed bottom input bar that stays visible as the conversation scrolls. The bar is styled as a pill-shaped field (border-radius: 56px) anchored at the bottom center of the viewport (position: fixed; bottom: 24px). It is limited to max-width: 880px and spans 90% of the viewport width on desktop, adjusting to 95% on mobile. Pressing Enter or clicking the send button calls send_message(), which:
  1. Checks for a PDF context first (see PDF context below).
  2. Falls back to get_response() from the intent-matching system.
  3. Appends both the user message and the assistant reply to st.session_state.messages.
  4. Awards XP and updates the streak via update_streak_and_xp().
Each message stored in session state has the following structure:
{
    "role": "user" | "assistant",
    "content": "message text",
    "ts": "3:45 PM"   # from now_time()
}

Voice input

Students can speak their questions instead of typing them. The transcribe_audio() function in Main.py handles audio-to-text conversion using the Google Speech Recognition API with the es-ES locale.
text = recognizer.recognize_google(audio_data, language="es-ES")
The function uses pydub to convert the incoming audio (WebM format from the browser) to WAV before passing it to the recognizer. If pydub is not installed, it falls back to writing the raw file to a temporary .webm file and attempting recognition directly.
Voice input requires ffmpeg to be installed on the server. Without it, pydub cannot decode audio formats and transcription will fail. Lumina AI shows a warning message directing users to install ffmpeg from https://ffmpeg.org. Until ffmpeg is available, use the text input instead.
Dependencies for voice input:
SpeechRecognition
pydub
ffmpeg  # system dependency, not a Python package

PDF context

Students can upload a PDF document to ground Lumina AI’s answers in their own study material. The PDF panel lives inside a collapsible 📄 Cargar PDF expander in the left sidebar.

How it works

1

Upload a PDF

Click the expander in the sidebar and select a .pdf file. Lumina reads it with extract_text_from_pdf(), which uses PyPDF2 to extract text from every page and concatenate the results.
2

Ask a question

Type or speak your question normally. Before querying the chatbot, send_message() calls query_pdf() to search the extracted text.
3

Get a grounded answer

If a relevant passage is found, Lumina responds with that excerpt instead of the standard chatbot response. The reply is prefixed with 📄 Según tu PDF:.

Relevance scoring

query_pdf() splits the PDF text into paragraphs (separated by blank lines) and scores each one by counting how many words from the user’s question appear in the paragraph. A paragraph must score at least 2 keyword matches to be considered relevant. The highest-scoring paragraph wins.
score = sum(1 for w in q_words if w in para.lower())
if score > best_score and score >= 2:
    best_score = score
    best_para = para.strip()
If the winning paragraph exceeds 500 characters, it is truncated with an ellipsis. PDF answers take priority over chatbot responses—if a PDF is loaded and a relevant passage is found, the neural network is never consulted for that message. To remove the PDF context, click the Limpiar button that appears below the filename in the sidebar.

Quick actions

The sidebar includes six one-tap prompts that send a pre-written message to the chat, triggering an immediate response from the chatbot. These are useful for standard study tasks without having to type a full question.

Explícame esto con una analogía

Ask Lumina to explain the current topic using an everyday comparison or metaphor.

Dame ejemplos prácticos

Request concrete, real-world examples to illustrate an abstract concept.

Haz un resumen claro del tema

Generate a concise summary of whatever topic is being discussed.

Hazme un quiz sobre esto

Start a quiz session to test your understanding of the topic.

Dame técnicas de memorización

Get science-backed memorization strategies such as spaced repetition and the memory palace.

Dame motivación para estudiar

Receive an encouraging message to help you push through a difficult study session.
Each button calls send_message() with the corresponding prompt string, so the interaction is identical to typing that prompt manually.

Text-to-speech

Every assistant message has a button below the bubble. Clicking it generates an MP3 audio file from the message text using gTTS (Google Text-to-Speech) with lang="es", then plays it inline via Streamlit’s audio widget.
from gtts import gTTS

tts = gTTS(text, lang="es")
tts.save(fp.name)
The audio file is written to a temporary .mp3 file, which is passed to st.audio() with format="audio/mp3". Each message gets its own button keyed by message index (speak_{idx}), so multiple messages can be played without conflict.

Build docs developers (and LLMs) love