c0599e30ab
- Created .gitignore to exclude unnecessary files - Added README.md with installation and usage instructions - Initialized package.json with dependencies and configurations - Set up tsconfig.json for TypeScript compiler options - Implemented basic index.ts file for logging - Added Supabase function structure in ai-structured directory - Created test files for user authentication and function invocation
65 lines
2.2 KiB
TypeScript
65 lines
2.2 KiB
TypeScript
import { supabase } from "./new-user";
|
|
|
|
const /* { data, error } */_ = await supabase.auth.signInWithPassword({
|
|
email: "guillermo.arrieta@lasalle.mx",
|
|
password: "admin",
|
|
});
|
|
|
|
/* if (error) {
|
|
console.error("Error signing in:", error);
|
|
process.exit(1);
|
|
} else {
|
|
console.log("Successfully signed in:", data);
|
|
} */
|
|
|
|
try {
|
|
|
|
const response = await supabase.functions.invoke("ai-structured", {
|
|
body: {
|
|
response: {
|
|
model: "gpt-5",
|
|
input: [
|
|
{ role: "system", content: "Responde SIEMPRE en JSON válido." },
|
|
{ role: "user", content: "Dame 3 ideas de proyecto de IA para educación." },
|
|
],
|
|
/* conversation: "conv_...", */ // opcional
|
|
},
|
|
structured: {
|
|
type: "json_schema",
|
|
name: "ideas",
|
|
strict: true,
|
|
schema: {
|
|
type: "object",
|
|
properties: {
|
|
ideas: {
|
|
type: "array",
|
|
items: {
|
|
type: "object",
|
|
properties: {
|
|
titulo: { type: "string" },
|
|
descripcion: { type: "string" }
|
|
},
|
|
required: ["titulo", "descripcion"],
|
|
additionalProperties: false
|
|
}
|
|
}
|
|
},
|
|
required: ["ideas"],
|
|
additionalProperties: false
|
|
}
|
|
},
|
|
references: {
|
|
/* vectorStoreIds: ["vs_..."], */ // opcional (file_search) ✅
|
|
/* openaiFileIds: ["file_..."], */ // opcional (input_file) ✅
|
|
},
|
|
usarMCP: false, // opcional ✅
|
|
},
|
|
});
|
|
console.log({ d: response.data, e: response.error });
|
|
} catch (e: any) {
|
|
const res = e?.context ?? e?.response;
|
|
console.log("status", res?.status);
|
|
if (res?.text) console.log("text", await res.text());
|
|
else console.log("raw error keys", Object.keys(e ?? {}));
|
|
}
|