TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DavidCevallos15/inforario-IA-null/llms.txt
Use this file to discover all available pages before exploring further.
extract-schedule function is a Deno Edge Function deployed on Supabase. It receives raw text extracted from a UTM schedule PDF, forwards it to Groq’s llama-3.3-70b-versatile model with a strict system prompt, and returns a validated array of structured class sessions. The function handles all session normalisation and virtual-class detection internally — the caller only needs to supply the plain PDF text.
Endpoint
POST requests only. An OPTIONS preflight request returns the shared CORS headers and a 200 ok response without executing any LLM logic.
CORS headers
All responses (includingOPTIONS preflight) include the following headers defined in _shared/cors.ts:
| Header | Value |
|---|---|
Access-Control-Allow-Origin | * |
Access-Control-Allow-Headers | authorization, x-client-info, apikey, content-type |
Access-Control-Allow-Methods | POST, GET, OPTIONS, PUT, DELETE |
Authentication
Pass the Supabase anon key as a Bearer token in theAuthorization header. This is the public client key found in your Supabase project settings — no user session is needed.
Request
Headers
| Header | Required | Value |
|---|---|---|
Authorization | ✅ | Bearer <supabase-anon-key> |
Content-Type | ✅ | application/json |
Body
The raw plain-text content extracted from a UTM schedule PDF. The string must be non-empty after trimming whitespace. The function sends this verbatim to Groq inside a user-role message:
"Extrae el horario del siguiente texto:\n{pdfText}".Example request
Response
200 — Success
Returns a JSON object with a singlesessions key containing an array of validated, normalised class sessions. Sessions that fail validation (missing subject, invalid day, or malformed time on a non-virtual class) are silently dropped before the response is sent.
Array of validated class session objects. May be empty if none of the model’s output passes validation.
Example response
Virtual sessions omit
day, startTime, and endTime entirely from the JSON output because those fields are set to undefined in the TypeScript response object and are therefore not serialised by JSON.stringify.Error responses
| Status | Condition | Body |
|---|---|---|
400 | pdfText is missing or blank | { "error": "pdfText es obligatorio." } |
405 | Request method is not POST | { "error": "Método no permitido." } |
500 | GROQ_API_KEY environment variable is not set | { "error": "Falta GROQ_API_KEY" } |
500 | Unexpected runtime error | { "error": "<error message>" } |
502 | Groq API returned a non-OK status | { "error": "<groq error message>" } |
502 | Groq response body was empty or not valid JSON (no content) | { "error": "Groq respondió sin contenido parseable." } |
502 | Groq response content was not valid JSON | { "error": "Groq devolvió contenido no JSON." } |
Environment variables
Secret API key for the Groq platform. Set this in your Supabase project’s Edge Function secrets (
supabase secrets set GROQ_API_KEY=...). The function returns 500 immediately if this variable is absent.Groq model identifier to use for extraction. Defaults to
llama-3.3-70b-versatile when not set. Override this to switch models without redeploying.Session validation rules
The function runs a multi-step validation pipeline on every object returned by the model before including it in the response.Sessions that fail validation are silently filtered out. The caller should check the length of the returned
sessions array and prompt the user to retry if it is unexpectedly low.- Type coercion — Every field is cast to a string and trimmed. Non-string values fall back to sensible defaults (
"N/A"for teacher/floor,""for day/times,"Virtual"for location). - Virtual detection — A session is marked
isVirtual = trueifisVirtualis alreadytrue, OR thelocationstring contains"VIRTUAL"(case-insensitive), ORday,startTime, andendTimeare all empty strings after coercion. - Virtual field clearing — On virtual sessions,
day,startTime, andendTimeare set toundefinedandlocationis overwritten with"Virtual". - Filter pass — A session is kept only if
subjectis non-empty AND eitherisVirtualistrueOR all three ofday(must be one of the five allowed days),startTime, andendTime(both matchingHH:MM) are valid.
Allowed days
TheALLOWED_DAYS set contains exactly: 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes'. Any other value (including 'Sábado', 'Domingo', or misspellings) causes the session to be dropped.
Time format
Times are validated against the regex/^([01]\d|2[0-3]):[0-5]\d$/. Values such as "7:00" (missing leading zero) or "24:00" will fail validation and cause the session to be dropped.
LLM system prompt rules
The system prompt sent to Groq instructs the model to:- Return only a valid JSON object with a root key
"sessions"containing an array — no markdown fences or prose. - Include every class session found, including virtual ones (
isVirtual: true). - Set
temperature: 0.1andresponse_format: { type: "json_object" }to maximise determinism.
- Extract only the real subject name — no career or programme name prefix.
- Forbidden prefixes:
"TECNOLOGÍAS DE LA ", degree programme name. - Forbidden suffixes: parenthetical mesh/curriculum codes such as
"(A19)","(ITINERARIO)","(VIRTUAL)". - Correct:
"SISTEMAS DISTRIBUIDOS"— Incorrect:"TECNOLOGÍAS DE LA SISTEMAS DISTRIBUIDOS (A19)".