Se agrga crear formatos
This commit is contained in:
@@ -33,7 +33,7 @@ const CardContent = ({ className, children }) => <div className={`p-4 ${classNam
|
||||
const ScrollArea = ({ className, children }) => <div className={`overflow-y-auto ${className}`}>{children}</div>;
|
||||
|
||||
/* ------------- COMPONENT ------------- */
|
||||
export default function AIChatModal({ open, onClose, context, onAccept }) {
|
||||
export default function AIChatModal({ open, onClose, context, onAccept, plan_format }) {
|
||||
const [vectorStores, setVectorStores] = useState([]);
|
||||
const [vectorFiles, setVectorFiles] = useState([]);
|
||||
const [selectedVectorFile, setSelectedVectorFile] = useState(null);
|
||||
@@ -127,7 +127,7 @@ export default function AIChatModal({ open, onClose, context, onAccept }) {
|
||||
const token = session?.access_token;
|
||||
|
||||
// llamada
|
||||
const resp = await supabase.functions.invoke("modal-conversation", {
|
||||
const resp = await supabase.functions.invoke("conversation-format", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: { action: "start" , role:"system", content:context.cont_conversation, }
|
||||
});
|
||||
@@ -188,7 +188,7 @@ export default function AIChatModal({ open, onClose, context, onAccept }) {
|
||||
const token = session?.access_token;
|
||||
|
||||
// algunas implementations esperan { action: "end", conversationId }, otras { action: "end", id }
|
||||
const { data, error } = await supabase.functions.invoke("modal-conversation", {
|
||||
const { data, error } = await supabase.functions.invoke("conversation-format", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: { action: "end", conversationId: convIdToUse }
|
||||
});
|
||||
@@ -211,6 +211,8 @@ export default function AIChatModal({ open, onClose, context, onAccept }) {
|
||||
|
||||
// ---------- SEND MESSAGE (usa conversationId) ----------
|
||||
const handleConversation = async ({ text }) => {
|
||||
console.log(plan_format);
|
||||
|
||||
if (!conversationId) {
|
||||
console.warn("No hay conversación activa todavía. conversationId:", conversationId);
|
||||
// si no hay conv, opcionalmente intentar crear una sin que el usuario note
|
||||
@@ -245,6 +247,7 @@ export default function AIChatModal({ open, onClose, context, onAccept }) {
|
||||
|
||||
const payload = {
|
||||
action: "message",
|
||||
format: plan_format,
|
||||
conversationId,
|
||||
vectorStoreId: selectedVectorFile?.vector_store_id ?? null,
|
||||
fileIds: selectedVectorFile ? [selectedVectorFile.id] : [],
|
||||
@@ -259,7 +262,7 @@ export default function AIChatModal({ open, onClose, context, onAccept }) {
|
||||
]
|
||||
};
|
||||
const { data: invokeData, error } = await supabase.functions.invoke(
|
||||
"modal-conversation",
|
||||
"conversation-format",
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: payload
|
||||
|
||||
@@ -12,6 +12,7 @@ import { HistorialCambiosModal } from "../historico/HistorialCambiosModal"
|
||||
import AIChatModal from "../ai/AIChatModal"
|
||||
|
||||
|
||||
|
||||
/* =====================================================
|
||||
Query keys & fetcher
|
||||
===================================================== */
|
||||
@@ -54,6 +55,8 @@ export const planTextOptions = (planId: string) =>
|
||||
staleTime: 60_000,
|
||||
})
|
||||
|
||||
|
||||
|
||||
/* =====================================================
|
||||
Color helpers
|
||||
===================================================== */
|
||||
@@ -124,6 +127,17 @@ export function AcademicSections({ planId, color }: { planId: string; color?: st
|
||||
const [editing, setEditing] = useState<null | { key: keyof PlanTextFields; title: string }>(null)
|
||||
const [draft, setDraft] = useState("")
|
||||
|
||||
const plan_format={
|
||||
"objetivo_general": "...",
|
||||
"sistema_evaluacion": "...",
|
||||
"perfil_ingreso": "...",
|
||||
"perfil_egreso": "...",
|
||||
"competencias_genericas": "...",
|
||||
"competencias_especificas": "...",
|
||||
"indicadores_desempeno": "...",
|
||||
"pertinencia": "..."
|
||||
}
|
||||
|
||||
// --- mutation con actualización optimista ---
|
||||
const updateField = useMutation({
|
||||
mutationFn: async ({ key, value }: { key: keyof PlanTextFields; value: string | string[] | null }) => {
|
||||
@@ -309,6 +323,7 @@ export function AcademicSections({ planId, color }: { planId: string; color?: st
|
||||
/>
|
||||
|
||||
<AIChatModal
|
||||
plan_format={plan_format}
|
||||
open={openModalIa}
|
||||
onClose={() => setopenModalIa(false)}
|
||||
context={{
|
||||
|
||||
10
src/formatos/plan.json
Normal file
10
src/formatos/plan.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"objetivo_general": "...",
|
||||
"sistema_evaluacion": "...",
|
||||
"perfil_ingreso": "...",
|
||||
"perfil_egreso": "...",
|
||||
"competencias_genericas": "...",
|
||||
"competencias_especificas": "...",
|
||||
"indicadores_desempeno": "...",
|
||||
"pertinencia": "..."
|
||||
}
|
||||
Reference in New Issue
Block a user