import{d as Q}from"../chunks/environment.9aa685ef.js";import{S as x,i as I,s as k,k as f,q as w,a as O,l as _,m as y,r as S,h,c as T,n as j,b as M,D as l,Q as D,F as E,R as N,E as P,G as q}from"../chunks/index.463cc238.js";const A=Q,C=!0,B=Object.freeze(Object.defineProperty({__proto__:null,csr:A,prerender:C},Symbol.toStringTag,{value:"Module"}));function F(d){let e,u,t,o,s,n,c,r,m,g,p;return{c(){e=f("div"),u=f("p"),t=w("Documents Indexed! Query below."),o=O(),s=f("form"),n=f("input"),c=O(),r=f("button"),m=w("Ask Question"),this.h()},l(a){e=_(a,"DIV",{});var i=y(e);u=_(i,"P",{});var b=y(u);t=S(b,"Documents Indexed! Query below."),b.forEach(h),o=T(i),s=_(i,"FORM",{});var v=y(s);n=_(v,"INPUT",{type:!0}),c=T(v),r=_(v,"BUTTON",{type:!0});var $=y(r);m=S($,"Ask Question"),$.forEach(h),v.forEach(h),i.forEach(h),this.h()},h(){j(n,"type","text"),j(r,"type","submit")},m(a,i){M(a,e,i),l(e,u),l(u,t),l(e,o),l(e,s),l(s,n),D(n,d[0]),l(s,c),l(s,r),l(r,m),g||(p=[E(n,"input",d[2]),E(s,"submit",N(d[1]))],g=!0)},p(a,[i]){i&1&&n.value!==a[0]&&D(n,a[0])},i:P,o:P,d(a){a&&h(e),g=!1,q(p)}}}function R(d,e,u){let t="What is gradient descent?",o=[];async function s(c){c.preventDefault(),console.log("event",c),o=[...o,{user:"me",message:`${t}`}];let r={message:t};console.log("todo",r);const m=o.map(a=>a.message).join(`
`);console.log("messages",m);const p=await(await fetch(`/api/inference/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json();console.log("response",p),p.answer,o=[...o,{user:"gpt",message:`${p.answer}`}]}function n(){t=this.value,u(0,t)}return[t,s,n]}class G extends x{constructor(e){super(),I(this,e,R,F,k,{})}}export{G as component,B as universal};
