nueva edge function para la generación de sugerencais de asignaturas con IA

This commit is contained in:
2026-02-10 12:22:39 -06:00
parent a9b77cd792
commit 93c7f11621
6 changed files with 68 additions and 0 deletions
+11
View File
@@ -37,3 +37,14 @@ entrypoint = "./functions/ai-generate-subject/index.ts"
# Specifies static files to be bundled with the function. Supports glob patterns.
# For example, if you want to serve static HTML pages in your function:
# static_files = [ "./functions/ai-generate-subject/*.html" ]
[functions.generate-subject-suggestions]
enabled = true
verify_jwt = true
import_map = "./functions/generate-subject-suggestions/deno.json"
# Uncomment to specify a custom file path to the entrypoint.
# Supported file extensions are: .ts, .js, .mjs, .jsx, .tsx
entrypoint = "./functions/generate-subject-suggestions/index.ts"
# Specifies static files to be bundled with the function. Supports glob patterns.
# For example, if you want to serve static HTML pages in your function:
# static_files = [ "./functions/generate-subject-suggestions/*.html" ]
@@ -93,6 +93,7 @@ export type Database = {
asignatura_hash: string | null;
codigo: string | null;
contenido_tematico: Json;
conversation_id: string | null;
creado_en: string;
creado_por: string | null;
creditos: number;
@@ -118,6 +119,7 @@ export type Database = {
asignatura_hash?: string | null;
codigo?: string | null;
contenido_tematico?: Json;
conversation_id?: string | null;
creado_en?: string;
creado_por?: string | null;
creditos: number;
@@ -143,6 +145,7 @@ export type Database = {
asignatura_hash?: string | null;
codigo?: string | null;
contenido_tematico?: Json;
conversation_id?: string | null;
creado_en?: string;
creado_por?: string | null;
creditos?: number;
@@ -0,0 +1,3 @@
# Configuration for private npm package dependencies
# For more information on using private registries with Edge Functions, see:
# https://supabase.com/docs/guides/functions/import-maps#importing-from-private-registries
@@ -0,0 +1,3 @@
{
"imports": {}
}
@@ -0,0 +1,32 @@
// Follow this setup guide to integrate the Deno language server with your editor:
// https://deno.land/manual/getting_started/setup_your_environment
// This enables autocomplete, go to definition, etc.
// Setup type definitions for built-in Supabase Runtime APIs
import "jsr:@supabase/functions-js/edge-runtime.d.ts"
console.log("Hello from Functions!")
Deno.serve(async (req) => {
const { name } = await req.json()
const data = {
message: `Hello ${name}!`,
}
return new Response(
JSON.stringify(data),
{ headers: { "Content-Type": "application/json" } },
)
})
/* To invoke locally:
1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start)
2. Make an HTTP request:
curl -i --location --request POST 'http://127.0.0.1:54321/functions/v1/generate-subject-suggestions' \
--header 'Authorization: Bearer eyJhbGciOiJFUzI1NiIsImtpZCI6ImI4MTI2OWYxLTIxZDgtNGYyZS1iNzE5LWMyMjQwYTg0MGQ5MCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjIwODYxMDc1NTl9.68Q-uYZ-5EHQfzzqL38ivfGTUYyQ_ncJ34eAivWwl2So5NcvWGL9DSjg-fJ8UA9NKqnH5r-i8Z1bONE9LPMwBg' \
--header 'Content-Type: application/json' \
--data '{"name":"Functions"}'
*/
@@ -0,0 +1,16 @@
drop view if exists "public"."plantilla_plan";
alter table "public"."asignaturas" add column "conversation_id" text;
CREATE UNIQUE INDEX asignaturas_conversation_id_key ON public.asignaturas USING btree (conversation_id);
alter table "public"."asignaturas" add constraint "asignaturas_conversation_id_key" UNIQUE using index "asignaturas_conversation_id_key";
create or replace view "public"."plantilla_plan" as SELECT plan.id AS plan_estudio_id,
struct.id AS estructura_id,
struct.template_id
FROM (public.planes_estudio plan
JOIN public.estructuras_plan struct ON ((plan.estructura_id = struct.id)));