khoj 1.36.7.dev22__py3-none-any.whl → 1.36.7.dev25__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- khoj/database/migrations/0086_alter_texttoimagemodelconfig_model_type.py +26 -0
- khoj/database/models/__init__.py +4 -3
- khoj/interface/compiled/404/index.html +2 -2
- khoj/interface/compiled/_next/static/chunks/{1199-80c79778c44ad4ec.js → 1199-73b3a84de8752d5d.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/2327-759b19a673b5aecf.js +1 -0
- khoj/interface/compiled/_next/static/chunks/3072.00280770bc15e09f.js +1 -0
- khoj/interface/compiled/_next/static/chunks/{4357-73c05a7c905ffc9f.js → 4357-d86d3401f6f6f802.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/{4363-9870bda67c2cf031.js → 4363-4efaf12abe696251.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/4986-130a93adbd4aee1f.js +1 -0
- khoj/interface/compiled/_next/static/chunks/5473-921e17a6177f9729.js +1 -0
- khoj/interface/compiled/_next/static/chunks/6663-133d5db72d2d5f24.js +1 -0
- khoj/interface/compiled/_next/static/chunks/7200-cabc57d26c4b32da.js +1 -0
- khoj/interface/compiled/_next/static/chunks/{8155-87b4d2ea2cf725cc.js → 8515-f305779d95dd5780.js} +8 -8
- khoj/interface/compiled/_next/static/chunks/90542734.9e6e44b1b45b30fe.js +1 -0
- khoj/interface/compiled/_next/static/chunks/9259-d8bcd9da9e80c81e.js +1 -0
- khoj/interface/compiled/_next/static/chunks/94ca1967.1b3402358e0e1255.js +1 -0
- khoj/interface/compiled/_next/static/chunks/964ecbae.d5be7c49c320d695.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/agents/{layout-447b58869479276c.js → layout-5961c3717e1d8813.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/agents/{page-fbe2c1c661cd14ac.js → page-013290d1487a8879.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/automations/{page-ad620b194fd508fe.js → page-03ba7391a044d9c7.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/{layout-4d0b1ba93124fccb.js → layout-603285e3b1400e74.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/page-53cab1cceb3cf72b.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/{layout-6dba801826c4fe59.js → layout-bd8210ff1de491d7.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/{page-f91e6a6a849baf5e.js → page-a6f9c95dd4e3fe49.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/search/{layout-ab5dbb69fb914900.js → layout-9ccd090dcc2aa58a.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/search/{page-30e231665f1f3796.js → page-cc57aeac88ca2e26.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/settings/{layout-bef0e00bb3873a84.js → layout-a7262b2bb8c7ae64.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/settings/{page-c580520d59d92267.js → page-2e7b5c20a07b00da.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/share/chat/{layout-2ce0cb95b1219d97.js → layout-991b6deed2f9eae2.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-ffcb3ce5c6af9988.js → page-df6bbbb0f2010e76.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/d3ac728e-07f1976c92cfb109.js +1 -0
- khoj/interface/compiled/_next/static/chunks/webpack-9081d211e77f6283.js +1 -0
- khoj/interface/compiled/_next/static/css/{a3411982c232c7be.css → 09214671efd6003c.css} +1 -1
- khoj/interface/compiled/_next/static/css/55d4a822f8d94b67.css +1 -0
- khoj/interface/compiled/_next/static/css/{8051073dc55b92b3.css → 804ceddd6c935d4a.css} +1 -1
- khoj/interface/compiled/agents/index.html +2 -2
- khoj/interface/compiled/agents/index.txt +3 -3
- khoj/interface/compiled/automations/index.html +2 -2
- khoj/interface/compiled/automations/index.txt +4 -4
- khoj/interface/compiled/chat/index.html +2 -2
- khoj/interface/compiled/chat/index.txt +3 -3
- khoj/interface/compiled/index.html +2 -2
- khoj/interface/compiled/index.txt +3 -3
- khoj/interface/compiled/search/index.html +2 -2
- khoj/interface/compiled/search/index.txt +3 -3
- khoj/interface/compiled/settings/index.html +2 -2
- khoj/interface/compiled/settings/index.txt +5 -5
- khoj/interface/compiled/share/chat/index.html +2 -2
- khoj/interface/compiled/share/chat/index.txt +3 -3
- khoj/processor/conversation/google/utils.py +4 -4
- khoj/processor/image/generate.py +35 -0
- khoj/routers/helpers.py +5 -1
- {khoj-1.36.7.dev22.dist-info → khoj-1.36.7.dev25.dist-info}/METADATA +3 -3
- {khoj-1.36.7.dev22.dist-info → khoj-1.36.7.dev25.dist-info}/RECORD +66 -67
- khoj/interface/compiled/_next/static/chunks/0d8bff65.4b1018183a8be7c2.js +0 -1
- khoj/interface/compiled/_next/static/chunks/2327-36d17f2483e80f60.js +0 -1
- khoj/interface/compiled/_next/static/chunks/3727.dcea8f2193111552.js +0 -1
- khoj/interface/compiled/_next/static/chunks/3861-8662fce65c02717d.js +0 -1
- khoj/interface/compiled/_next/static/chunks/4986-d19b9ab0079521d7.js +0 -1
- khoj/interface/compiled/_next/static/chunks/5473-02d1709b2a3f4a4b.js +0 -1
- khoj/interface/compiled/_next/static/chunks/6663-61c3f91791968671.js +0 -1
- khoj/interface/compiled/_next/static/chunks/90542734.fecd4dc1a89ed166.js +0 -1
- khoj/interface/compiled/_next/static/chunks/9259-fa40e7cf2ca28e04.js +0 -1
- khoj/interface/compiled/_next/static/chunks/94ca1967.1d9b42d929a1ee8c.js +0 -1
- khoj/interface/compiled/_next/static/chunks/9597.83583248dfbf6e73.js +0 -1
- khoj/interface/compiled/_next/static/chunks/964ecbae.51d6faf8801d15e6.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/page-4108f46796c1c606.js +0 -1
- khoj/interface/compiled/_next/static/chunks/d3ac728e-953b1c3bad7316d7.js +0 -1
- khoj/interface/compiled/_next/static/chunks/webpack-f83765a7accac982.js +0 -1
- khoj/interface/compiled/_next/static/css/f29752d6e1be7624.css +0 -1
- /khoj/interface/compiled/_next/static/{w25ObnntxL_4D4MY2j-Yc → XLZb8V8RokZAEGkgKpBmx}/_buildManifest.js +0 -0
- /khoj/interface/compiled/_next/static/{w25ObnntxL_4D4MY2j-Yc → XLZb8V8RokZAEGkgKpBmx}/_ssgManifest.js +0 -0
- /khoj/interface/compiled/_next/static/chunks/{1915-233ac8a122732d6b.js → 1915-ab4353eaca76f690.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{2117-ce1f0a4598f5e4fe.js → 2117-f99825f0a867a42d.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{2509-79b3ce8040bc0bcf.js → 2509-fe7409b49255d54a.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{4447-6e47461d1100c3cc.js → 4447-5d44807c40355b1a.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{7647-469de84d236fc7fd.js → 7647-2aa4cf0e69b7a84d.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{8667-8136f74e9a086fca.js → 8667-adbe6017a66cef10.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9334-3047e20b503f086b.js → 9334-b22127fe2d39bc60.js} +0 -0
- {khoj-1.36.7.dev22.dist-info → khoj-1.36.7.dev25.dist-info}/WHEEL +0 -0
- {khoj-1.36.7.dev22.dist-info → khoj-1.36.7.dev25.dist-info}/entry_points.txt +0 -0
- {khoj-1.36.7.dev22.dist-info → khoj-1.36.7.dev25.dist-info}/licenses/LICENSE +0 -0
@@ -1 +0,0 @@
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{39929:function(e,s,t){Promise.resolve().then(t.bind(t,42780))},42780:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return eo}});var a=t(57437),n=t(63136),l=t.n(n),i=t(2265),o=t(74986),r=t(99376),d=t(14308),c=t(59199);t(2446);var u=t(7436),m=t(5477),h=t(56937),x=t(55287),f=t(60729),p=t(34124),g=t(6512),j=t(37104),v=t(62869),N=t(632),b=t(47615),y=t(96108),w=t(36360),_=t(60906),S=t(36720),C=t(61563),k=t(82123),O=t(76818),I=t(78299),M=t(38513),E=t(94508),T=t(23518),z=t(57054),B=t(16605);let R=B.fC,L=B.xz,F=i.forwardRef((e,s)=>{let{className:t,align:n="center",sideOffset:l=4,...i}=e;return(0,a.jsx)(B.VY,{ref:s,align:n,sideOffset:l,className:(0,E.cn)("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...i})});F.displayName=B.VY.displayName;var Z=t(54036);function P(e){var s;let{...t}=e,[n,l]=i.useState(!1),[o,r]=(0,i.useState)(void 0),[d,c]=(0,i.useState)(void 0),{data:m,error:x,isLoading:f}=(0,h.h2)(!0),[p,g]=(0,i.useState)([]),j=(0,u.IC)();return((0,i.useEffect)(()=>{if(!f&&m){if(g(m.chat_model_options),t.initialModel)c(m.chat_model_options.find(e=>e.name===t.initialModel));else{let e=m.chat_model_options.find(e=>e.id===m.selected_chat_model_config);if(e)c(e);else{c(m.chat_model_options[0]);return}}}},[m,t.initialModel,f]),(0,i.useEffect)(()=>{if(t.selectedModel&&d&&t.selectedModel!==d.name)c(p.find(e=>e.name===t.selectedModel));else if(null===t.selectedModel&&m){let e=m.chat_model_options.find(e=>e.id===m.selected_chat_model_config);if(e)t.onSelect(e,!1);else{t.onSelect(m.chat_model_options[0],!1);return}}},[t.selectedModel,p]),(0,i.useEffect)(()=>{if(d){let e=d.id!==(null==m?void 0:m.selected_chat_model_config);t.selectedModel!==d.name&&t.onSelect(d,e)}},[d]),f)?(0,a.jsx)(Z.O,{className:"w-full h-10"}):x?(0,a.jsx)("div",{className:"text-sm text-error",children:x.message}):(0,a.jsx)("div",{className:"grid gap-2 w-[250px]",children:(0,a.jsxs)(z.J2,{open:n,onOpenChange:l,...t,children:[(0,a.jsx)(z.xo,{asChild:!0,children:(0,a.jsxs)(v.z,{variant:"outline",role:"combobox","aria-expanded":n,"aria-label":"Select a model",className:"w-full justify-between text-left",disabled:null!==(s=t.disabled)&&void 0!==s&&s,children:[(0,a.jsx)("p",{className:"truncate",children:d?d.name.substring(0,20):"Select a model..."}),(0,a.jsx)(I.K,{className:"opacity-50"})]})}),(0,a.jsx)(z.yk,{align:"end",className:"w-[250px] p-0",children:j?(0,a.jsx)("div",{children:(0,a.jsx)(T.mY,{loop:!0,children:(0,a.jsxs)(T.e8,{className:"h-[var(--cmdk-list-height)]",children:[(0,a.jsx)(T.sZ,{placeholder:"Search Models..."}),(0,a.jsx)(T.rb,{children:"No Models found."}),(0,a.jsx)(T.fu,{heading:"Models",children:p&&p.length>0&&p.map(e=>(0,a.jsx)(W,{model:e,isSelected:(null==d?void 0:d.id)===e.id,onPeek:e=>r(e),onSelect:()=>{c(e),l(!1)}},e.id))},"models")]})})}):(0,a.jsxs)(R,{children:[(0,a.jsx)(F,{side:"left",align:"start",forceMount:!0,className:"min-h-[280px]",children:(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsx)("h4",{className:"font-medium leading-none",children:null==o?void 0:o.name}),(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:null==o?void 0:o.description}),(null==o?void 0:o.strengths)?(0,a.jsxs)("div",{className:"mt-4 grid gap-2",children:[(0,a.jsx)("h5",{className:"text-sm font-medium leading-none",children:"Strengths"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:o.strengths})]}):null]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)(L,{}),(0,a.jsx)(T.mY,{loop:!0,children:(0,a.jsxs)(T.e8,{className:"h-[var(--cmdk-list-height)]",children:[(0,a.jsx)(T.sZ,{placeholder:"Search Models..."}),(0,a.jsx)(T.rb,{children:"No Models found."}),(0,a.jsx)(T.fu,{heading:"Models",children:p&&p.length>0&&p.map(e=>(0,a.jsx)(W,{model:e,isSelected:(null==d?void 0:d.id)===e.id,onPeek:e=>r(e),onSelect:()=>{c(e),l(!1)}},e.id))},"models")]})})]})]})})]})})}function W(e){let{model:s,isSelected:t,onSelect:n,onPeek:l}=e,o=i.useRef(null);return(0,u.Iy)(o,e=>{e.forEach(e=>{var t;"attributes"===e.type&&"aria-selected"===e.attributeName&&(null===(t=o.current)||void 0===t?void 0:t.getAttribute("aria-selected"))==="true"&&l(s)})}),(0,a.jsxs)(T.di,{onSelect:n,ref:o,className:"data-[selected=true]:bg-muted data-[selected=true]:text-secondary-foreground",children:[s.name,(0,a.jsx)(M.J,{className:(0,E.cn)("ml-auto",t?"opacity-100":"opacity-0")})]},s.id)}var A=t(63861),D=t(69304),J=t(42225),K=t(26815),U=t(9270),V=t(30401);let G=i.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(U.fC,{ref:s,className:(0,E.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-secondary-foreground ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-gray-500 data-[state=checked]:text-primary-foreground",t),...n,children:(0,a.jsx)(U.z$,{className:(0,E.cn)("flex items-center justify-center text-current"),children:(0,a.jsx)(V.Z,{className:"h-4 w-4"})})})});G.displayName=U.fC.displayName;var H=t(81103),Q=t(61312),Y=t(26110),$=t(53647),q=t(84671),X=t(95186),ee=t(27648),es=t(40521);let et=e=>fetch(e).then(e=>e.json());function ea(e){let{...s}=e;return s.isMobileWidth?(0,a.jsx)(D.yo,{open:s.isOpen,onOpenChange:s.onOpenChange,children:(0,a.jsx)(D.ue,{className:"w-[300px] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",children:(0,a.jsx)(el,{...s})})}):(0,a.jsx)("div",{className:"relative",children:(0,a.jsx)(el,{...s})})}function en(e){let s=(0,J.BI)(),t=q.xF,[n,l]=(0,i.useState)(!1),[o,r]=(0,i.useState)(),[d,c]=(0,i.useState)(),[u,m]=(0,i.useState)(),[h,x]=(0,i.useState)(!1),[f,p]=(0,i.useState)(),[g,j]=(0,i.useState)(!1),[N,S]=(0,i.useState)();return(0,i.useEffect)(()=>{o&&d&&u?j(!0):j(!1)},[o,d,u]),(0,a.jsxs)(Y.Vq,{children:[(0,a.jsx)(Y.hg,{asChild:!0,children:(0,a.jsx)(v.z,{className:"w-full",variant:"secondary",children:"Create Agent"})}),(0,a.jsxs)(Y.cZ,{children:[(0,a.jsxs)(Y.fK,{children:[h&&f?(0,a.jsxs)(Y.$N,{children:["Created ",o]}):(0,a.jsx)(Y.$N,{children:"Create a New Agent"}),(0,a.jsx)(Y.GG,{}),(0,a.jsx)(Y.Be,{children:"If these settings have been helpful, create a dedicated agent you can re-use across conversations."})]}),(0,a.jsx)("div",{className:"py-4",children:h&&f?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,a.jsx)(es.E.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:260,damping:20},children:(0,a.jsx)(b.f,{className:"w-16 h-16 text-green-500",weight:"fill"})}),(0,a.jsx)(es.E.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},className:"text-center text-lg font-medium text-accent-foreground",children:"Created successfully!"}),(0,a.jsx)(es.E.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4},children:(0,a.jsx)(ee.default,{href:"/agents?agent=".concat(f),children:(0,a.jsx)(v.z,{variant:"secondary",className:"mt-2",children:"Manage Agent"})})})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(K._,{htmlFor:"agent_name",children:"Name"}),(0,a.jsx)(X.I,{id:"agent_name",className:"w-full p-2 border mt-4 border-slate-500 rounded-lg",disabled:n,value:o,onChange:e=>r(e.target.value)})]}),(0,a.jsxs)("div",{className:"flex gap-4",children:[(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsxs)($.Ph,{onValueChange:m,defaultValue:u,children:[(0,a.jsx)($.i4,{className:"w-full dark:bg-muted",disabled:n,children:(0,a.jsx)($.ki,{placeholder:"Color"})}),(0,a.jsx)($.Bw,{className:"items-center space-y-1 inline-flex flex-col",children:t.map(e=>(0,a.jsx)($.Ql,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(y.C,{className:"w-6 h-6 mr-2 ".concat((0,q.oz)(e)),weight:"fill"}),e]})},e))})]})}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsxs)($.Ph,{onValueChange:c,defaultValue:d,children:[(0,a.jsx)($.i4,{className:"w-full dark:bg-muted",disabled:n,children:(0,a.jsx)($.ki,{placeholder:"Icon"})}),(0,a.jsx)($.Bw,{className:"items-center space-y-1 inline-flex flex-col",children:s.map(e=>(0,a.jsx)($.Ql,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,J.TI)(e,null!=u?u:"gray","w-6","h-6"),e]})},e))})]})})]})]})}),(0,a.jsxs)(Y.cN,{children:[N&&(0,a.jsx)("div",{className:"text-red-500 text-sm",children:N}),!h&&(0,a.jsxs)(v.z,{type:"submit",onClick:()=>void(!n&&(l(!0),fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o,icon:d,color:u,persona:e.customPrompt,chat_model:e.selectedModel,input_tools:e.inputTools,output_modes:e.outputModes,privacy_level:"private"})}).then(e=>e.json()).then(e=>{if(console.log("Success:",e),"detail"in e){S("Error creating agent: ".concat(e.detail)),l(!1);return}x(!0),p(e.slug),l(!1)}).catch(e=>{console.error("Error:",e),S("Error creating agent: ".concat(e)),l(!1)}))),disabled:n||!g,children:[n?(0,a.jsx)(w.U,{className:"animate-spin"}):(0,a.jsx)(_.R,{}),"Create"]}),(0,a.jsx)(Y.GG,{})]})]})]})}function el(e){var s,t,n,l;let{...o}=e,[r,d]=(0,i.useState)(!1),{data:c,error:u}=(0,A.ZP)("/api/agents/options",et),{data:m,isLoading:p,error:g}=(0,A.ZP)("/api/agents/conversation?conversation_id=".concat(o.conversationId),et),{data:j,error:N,isLoading:b}=(0,h.GW)(),[y,_]=(0,i.useState)(""),[I,M]=(0,i.useState)(),[E,T]=(0,i.useState)(),[B,R]=(0,i.useState)(),[L,F]=(0,i.useState)(!1),[Z,W]=(0,i.useState)((null==m?void 0:m.slug.toLowerCase())==="khoj"),[D,U]=(0,i.useState)(!1),V=null!==(s=null==j?void 0:j.is_active)&&void 0!==s&&s;function Y(){m&&(T(m.input_tools),(void 0===m.input_tools||0===m.input_tools.length)&&T((null==c?void 0:c.input_tools)?Object.keys(c.input_tools):[]),R(m.output_modes),(void 0===m.output_modes||0===m.output_modes.length)&&R((null==c?void 0:c.output_modes)?Object.keys(c.output_modes):[]),("khoj"===m.name.toLowerCase()||!0===m.is_hidden)&&d(!0),"khoj"===m.slug.toLowerCase()?(M(void 0),_(void 0),W(!0)):(W(!1),_(m.persona),M(m.chat_model)))}function $(e,s){return(F(!0),s.includes(e))?s.filter(s=>s!==e):[...s,e]}return(0,i.useEffect)(()=>{Y()},[m]),(0,a.jsxs)(f.DD,{collapsible:"none",className:"ml-auto opacity-30 rounded-lg p-2 transition-all transform duration-300 ease-in-out\n ".concat(o.isOpen?"translate-x-0 opacity-100 w-[300px] relative":"translate-x-full opacity-100 w-0 p-0 m-0","\n "),variant:"floating",children:[(0,a.jsxs)(f.TZ,{children:[(0,a.jsx)(f.$l,{children:m&&!r?(0,a.jsx)("div",{className:"flex items-center relative text-sm",children:(0,a.jsxs)("a",{className:"text-lg font-bold flex flex-row items-center",href:"/agents?agent=".concat(m.slug),children:[(0,J.TI)(m.icon,m.color),m.name]})}):(0,a.jsx)("div",{className:"flex items-center relative text-sm justify-between",children:(0,a.jsx)("p",{children:"Chat Options"})})}),(0,a.jsx)(f.Hz,{className:"border-b last:border-none",children:(0,a.jsx)(f.Ks,{className:"gap-0",children:(0,a.jsx)(f.w3,{className:"p-0 m-0",children:m&&m.has_files?(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2 rounded-full",children:[(0,a.jsx)("div",{className:"text-muted-foreground",children:(0,a.jsx)(S.J,{})}),(0,a.jsx)("div",{className:"text-muted-foreground text-sm",children:"Using custom knowledge base"})]})},"agent_knowledge"):null})})},"knowledge"),(0,a.jsx)(f.Hz,{children:(0,a.jsxs)(f.Ks,{children:[(0,a.jsx)(f.nO,{children:"Instructions"}),(0,a.jsx)(f.w3,{className:"p-0 m-0",children:(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsx)(O.g,{className:"w-full h-32 resize-none hover:resize-y",value:y,onChange:e=>{_(e.target.value),F(!0)},readOnly:!r,disabled:!r})})})]})},"instructions"),!p&&m&&(0,a.jsx)(f.Hz,{children:(0,a.jsxs)(f.Ks,{children:[(0,a.jsxs)(f.nO,{children:["Model",!V&&(0,a.jsx)("a",{href:"/settings",className:"hover:font-bold text-accent-foreground m-2 bg-accent bg-opacity-10 p-1 rounded-lg",children:"Upgrade"})]}),(0,a.jsx)(f.w3,{className:"p-0 m-0",children:(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsx)(P,{disabled:!r||!V,onSelect:(e,s)=>(function(e){let s=!(arguments.length>1)||void 0===arguments[1]||arguments[1];M(e),s&&F(!0)})(e.name,s),initialModel:Z?void 0:null==m?void 0:m.chat_model,selectedModel:I})},"model")})]})},"model"),(0,a.jsx)(z.J2,{defaultOpen:!1,children:(0,a.jsxs)(f.Hz,{children:[(0,a.jsx)(f.nO,{asChild:!0,children:(0,a.jsxs)(z.xo,{children:["Tools",(0,a.jsx)(C._,{className:"ml-auto transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),(0,a.jsx)(z.yk,{children:(0,a.jsx)(f.Ks,{children:(0,a.jsxs)(f.w3,{className:"p-1 m-0",children:[Object.entries(null!==(t=null==c?void 0:c.input_tools)&&void 0!==t?t:{}).map(e=>{let[s,t]=e;return(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsxs)(H.u,{children:[(0,a.jsx)(H.aJ,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2 py-1 justify-between",children:[(0,a.jsxs)(K._,{htmlFor:s,className:"flex items-center gap-2 text-accent-foreground p-1 cursor-pointer",children:[(0,J.vH)(s),(0,a.jsx)("p",{className:"text-sm my-auto flex items-center",children:s})]}),(0,a.jsx)(G,{id:s,className:"".concat(r?"cursor-pointer":""),checked:(null!=E?E:[]).includes(s),onCheckedChange:()=>T($(s,null!=E?E:[])),disabled:!r,children:s})]})},s),(0,a.jsx)(Q._v,{sideOffset:5,side:"left",align:"start",className:"text-sm bg-background text-foreground shadow-sm border border-slate-500 border-opacity-20 p-2 rounded-lg",children:t})]})},s)}),Object.entries(null!==(n=null==c?void 0:c.output_modes)&&void 0!==n?n:{}).map(e=>{let[s,t]=e;return(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsxs)(H.u,{children:[(0,a.jsx)(H.aJ,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2 py-1 justify-between",children:[(0,a.jsxs)(K._,{htmlFor:s,className:"flex items-center gap-2 p-1 rounded-lg cursor-pointer",children:[(0,J.vH)(s),(0,a.jsx)("p",{className:"text-sm my-auto flex items-center",children:s})]}),(0,a.jsx)(G,{id:s,className:"".concat(r?"cursor-pointer":""),checked:(null!=B?B:[]).includes(s),onCheckedChange:()=>R($(s,null!=B?B:[])),disabled:!r,children:s})]})},s),(0,a.jsx)(Q._v,{sideOffset:5,side:"left",align:"start",className:"text-sm bg-background text-foreground shadow-sm border border-slate-500 border-opacity-20 p-2 rounded-lg",children:t})]})},s)})]})})})]})}),(0,a.jsx)(f.Hz,{children:(0,a.jsxs)(f.Ks,{children:[(0,a.jsx)(f.nO,{children:"Files"}),(0,a.jsx)(f.w3,{className:"p-0 m-0",children:(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsx)(x.J_,{conversationId:o.conversationId,uploadedFiles:[],isMobileWidth:null!==(l=o.isMobileWidth)&&void 0!==l&&l})},"files-conversation")})]})},"files")]}),o.isOpen&&(0,a.jsx)(f.ZW,{children:(0,a.jsx)(f.w3,{className:"p-0 m-0",children:m&&!r&&m.is_creator?(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsx)(v.z,{className:"w-full",variant:"ghost",onClick:()=>window.location.href="/agents?agent=".concat(null==m?void 0:m.slug),children:"Manage"})})}):(0,a.jsxs)(a.Fragment,{children:[!L&&r&&y&&!Z&&I&&(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsx)(en,{customPrompt:y,selectedModel:I,inputTools:null!=E?E:[],outputModes:null!=B?B:[]})})}),(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsx)(v.z,{className:"w-full",onClick:()=>void(Y(),F(!1)),variant:"ghost",disabled:!r||!L,children:"Reset"})})}),(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsxs)(v.z,{className:"w-full ".concat(L?"bg-accent-foreground text-accent":""),variant:"secondary",onClick:()=>(function(){if(L){if(!Z&&(null==m?void 0:m.is_hidden)===!1){alert("This agent is not a hidden agent. It cannot be modified from this interface.");return}let e="PATCH";Z&&(e="POST");let s={persona:y,chat_model:I,input_tools:E,output_modes:B,...Z?{}:{slug:null==m?void 0:m.slug}};U(!0),fetch(Z?"/api/agents/hidden?conversation_id=".concat(o.conversationId):"/api/agents/hidden",{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}).then(e=>{U(!1),e.json()}).then(e=>{(0,A.JG)("/api/agents/conversation?conversation_id=".concat(o.conversationId)),F(!1)}).catch(e=>{console.error("Error:",e),U(!1)})}})(),disabled:!r||!L||D,children:[D?(0,a.jsx)(w.U,{className:"animate-spin"}):(0,a.jsx)(k.Z,{}),D?"Saving":"Save"]})})})]})})},"actions")]})}function ei(e){let s=(0,r.useSearchParams)().get("conversationId"),[t,n]=(0,i.useState)(""),[d,c]=(0,i.useState)([]),[u,h]=(0,i.useState)(!1),[x,f]=(0,i.useState)(null),[p,g]=(0,i.useState)(!1),j=(0,i.useRef)(null),v=e.setQueryToProcess,N=e.onConversationIdChange,b=e.isMobileWidth?"w-full":"w-4/6";if((0,i.useEffect)(()=>{if(d.length>0){let s=d.map(e=>encodeURIComponent(e));e.setImages(s)}},[d,e.setImages]),(0,i.useEffect)(()=>{let s=localStorage.getItem("images");if(s){let t=JSON.parse(s);c(t);let a=t.map(e=>encodeURIComponent(e));e.setImages(a),localStorage.removeItem("images")}let t=localStorage.getItem("message");t&&(h(!0),v(t),t.trim().startsWith("/research")&&g(!0));let a=localStorage.getItem("uploadedFiles");if(a){let s=a?JSON.parse(a):[],t=[];for(let e of s)t.push({name:e.name,file_type:e.file_type,content:e.content,size:e.size});localStorage.removeItem("uploadedFiles"),e.setUploadedFiles(t)}},[v,e.setImages,s]),(0,i.useEffect)(()=>{t&&(h(!0),v(t))},[t,v]),(0,i.useEffect)(()=>{s&&(null==N||N(s))},[s,N]),(0,i.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?(h(!1),c([]),e.setUploadedFiles(void 0)):n("")},[e.streamedMessages]),!s){window.location.href="/";return}return(0,a.jsxs)("div",{className:"flex flex-row h-full w-full",children:[(0,a.jsxs)("div",{className:"flex flex-col h-full w-full",children:[(0,a.jsx)("div",{className:l().chatBodyFull,children:(0,a.jsx)(o.Z,{conversationId:s,setTitle:e.setTitle,setAgent:f,pendingMessage:u?t:"",incomingMessages:e.streamedMessages,setIncomingMessages:e.setStreamedMessages,customClassName:b,setIsChatSideBarOpen:e.setIsChatSideBarOpen})}),(0,a.jsx)("div",{className:"".concat(l().inputBox," p-1 md:px-2 shadow-md bg-background align-middle items-center justify-center dark:bg-neutral-700 dark:border-0 dark:shadow-sm rounded-2xl md:rounded-xl h-fit ").concat(b," mr-auto ml-auto mt-auto"),children:(0,a.jsx)(m.a,{agentColor:null==x?void 0:x.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>n(e),sendImage:e=>c(s=>[...s,e]),sendDisabled:u,chatOptionsData:e.chatOptionsData,conversationId:s,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles,ref:j,isResearchModeEnabled:p,setTriggeredAbort:e.setTriggeredAbort})})]}),(0,a.jsx)(ea,{conversationId:s,isOpen:e.isChatSideBarOpen,onOpenChange:e.setIsChatSideBarOpen,isMobileWidth:e.isMobileWidth})]})}function eo(){let e="Khoj AI - Chat",[s,t]=(0,i.useState)(null),[n,o]=(0,i.useState)(!0),[r,m]=(0,i.useState)(e),[b,y]=(0,i.useState)(null),[w,_]=(0,i.useState)([]),[S,C]=(0,i.useState)(""),[k,O]=(0,i.useState)(!1),[I,M]=(0,i.useState)(void 0),[E,T]=(0,i.useState)([]),[z,B]=(0,i.useState)(null),[R,L]=(0,i.useState)(!1),{locationData:F,locationDataError:Z,locationDataLoading:P}=(0,u.k6)()||{locationData:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}},{data:W,error:A,isLoading:D}=(0,h.GW)(),J=(0,u.IC)(),[K,U]=(0,i.useState)(!1);async function V(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let s=e.body.getReader(),t=new TextDecoder,a="␃\uD83D\uDD1A␗",n="",l=[],i={},o={};for(;;){let e;let{done:r,value:d}=await s.read();if(r){C(""),O(!1),T([]),b&&(0,c.tQ)(b,m);break}for(n+=t.decode(d,{stream:!0});-1!==(e=n.indexOf(a));){let s=n.slice(0,e);if(n=n.slice(e+a.length),s){let e=w.find(e=>!e.completed);if(!e){console.error("No current message found");return}({context:l,onlineContext:i,codeContext:o}=(0,c.VK)(s,e,l,i,o)),_([...w])}}}}async function G(){if(localStorage.removeItem("message"),!S||!b)return;let e={q:S,conversation_id:b,stream:!0,...F&&{city:F.city,region:F.region,country:F.country,country_code:F.countryCode,timezone:F.timezone},...E.length>0&&{images:E},...I&&{files:I}},s=await fetch("/api/chat?client=web",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:null==z?void 0:z.signal});try{await V(s)}catch(l){let e;try{e=await s.json()}catch(s){e={streamError:"Error reading API error response stream. Expected JSON response."}}console.error(e);let t=w.find(e=>!e.completed);if(!t)return;let a=l.message,n=l.name;a.includes("Error in input stream")?t.rawResponse="Woops! The connection broke while I was writing my thoughts down. Maybe try again in a bit or dislike this message if the issue persists?":e.streamError?t.rawResponse="Umm, not sure what just happened but I lost my train of thought. Could you try again or ask my developers to look into this if the issue persists? They can be contacted at the Khoj Github, Discord or team@khoj.dev.":429===s.status?"detail"in e?t.rawResponse="".concat(e.detail):t.rawResponse="I'm a bit overwhelmed at the moment. Could you try again in a bit or dislike this message if the issue persists?":"AbortError"===n?t.rawResponse="I've stopped processing this message. If you'd like to continue, please send the message again.":t.rawResponse="Umm, not sure what just happened. I see this error message: ".concat(a,". Could you try again or dislike this message if the issue persists?"),t.completed=!0,_([...w]),C(""),O(!1)}}return(0,i.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{o(!1),e&&t(e)}).catch(e=>{console.error(e)}),(0,u.EK)()},[]),(0,i.useEffect)(()=>{R&&(null==z||z.abort(),function(){let e=w.find(e=>!e.completed);e&&(e.completed=!0,_([...w]),C(""),O(!1))}(),L(!1))}),(0,i.useEffect)(()=>{if(S){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},codeContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:S||"",images:E,queryFiles:I};_(s=>[...s,e]),O(!0),B(new AbortController)}},[S]),(0,i.useEffect)(()=>{k&&!P&&G()},[k,P]),n?(0,a.jsx)(d.Z,{}):(0,a.jsxs)(f.Hn,{children:[(0,a.jsx)(p.S,{conversationId:b||""}),(0,a.jsxs)(f.kV,{children:[(0,a.jsxs)("header",{className:"flex h-16 shrink-0 items-center gap-2 border-b px-4",children:[(0,a.jsx)(f.vP,{className:"-ml-1"}),(0,a.jsx)(g.Z,{orientation:"vertical",className:"mr-2 h-4"}),b&&(0,a.jsx)("div",{className:"".concat(l().chatTitleWrapper," text-nowrap text-ellipsis overflow-hidden max-w-screen-md grid items-top font-bold mx-2 md:mr-8 col-auto h-fit"),children:J?(0,a.jsx)("a",{className:"p-0 no-underline",href:"/",children:(0,a.jsx)(j.VO,{className:"h-auto w-16"})}):r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h2",{className:"text-lg text-ellipsis whitespace-nowrap overflow-x-hidden mr-4",children:r}),(0,a.jsx)(x.En,{conversationId:b,setTitle:m,sizing:"md"})]})}),(0,a.jsx)("div",{className:"flex justify-end items-start gap-2 text-sm ml-auto",children:(0,a.jsx)(v.z,{variant:"ghost",size:"icon",className:"h-12 w-12 data-[state=open]:bg-accent",onClick:()=>U(!K),children:(0,a.jsx)(N.T,{className:"w-6 h-6"})})})]}),(0,a.jsxs)("div",{className:"".concat(l().main," ").concat(l().chatLayout),children:[(0,a.jsx)("title",{children:"".concat(e).concat(r&&r!==e?": ".concat(r):"")}),(0,a.jsx)("div",{className:l().chatBox,children:(0,a.jsx)("div",{className:l().chatBoxBody,children:(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(d.Z,{}),children:(0,a.jsx)(ei,{isLoggedIn:!!W,streamedMessages:w,setStreamedMessages:_,chatOptionsData:s,setTitle:m,setQueryToProcess:C,setUploadedFiles:M,isMobileWidth:J,onConversationIdChange:e=>{y(e)},setImages:T,setTriggeredAbort:L,isChatSideBarOpen:K,setIsChatSideBarOpen:U})})})})]})]})]})}},26815:function(e,s,t){"use strict";t.d(s,{_:function(){return d}});var a=t(57437),n=t(2265),l=t(6394),i=t(90535),o=t(94508);let r=(0,i.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(l.f,{ref:s,className:(0,o.cn)(r(),t),...n})});d.displayName=l.f.displayName},53647:function(e,s,t){"use strict";t.d(s,{Bw:function(){return f},Ph:function(){return c},Ql:function(){return p},i4:function(){return m},ki:function(){return u}});var a=t(57437),n=t(2265),l=t(56873),i=t(40875),o=t(22135),r=t(30401),d=t(94508);let c=l.fC;l.ZA;let u=l.B4,m=n.forwardRef((e,s)=>{let{className:t,children:n,...o}=e;return(0,a.jsxs)(l.xz,{ref:s,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...o,children:[n,(0,a.jsx)(l.JO,{asChild:!0,children:(0,a.jsx)(i.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=l.xz.displayName;let h=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(l.u_,{ref:s,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",t),...n,children:(0,a.jsx)(o.Z,{className:"h-4 w-4"})})});h.displayName=l.u_.displayName;let x=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(l.$G,{ref:s,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",t),...n,children:(0,a.jsx)(i.Z,{className:"h-4 w-4"})})});x.displayName=l.$G.displayName;let f=n.forwardRef((e,s)=>{let{className:t,children:n,position:i="popper",...o}=e;return(0,a.jsx)(l.h_,{children:(0,a.jsxs)(l.VY,{ref:s,className:(0,d.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===i&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:i,...o,children:[(0,a.jsx)(h,{}),(0,a.jsx)(l.l_,{className:(0,d.cn)("p-1","popper"===i&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),(0,a.jsx)(x,{})]})})});f.displayName=l.VY.displayName,n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(l.__,{ref:s,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...n})}).displayName=l.__.displayName;let p=n.forwardRef((e,s)=>{let{className:t,children:n,...i}=e;return(0,a.jsxs)(l.ck,{ref:s,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...i,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(l.wU,{children:(0,a.jsx)(r.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(l.eT,{children:n})]})});p.displayName=l.ck.displayName,n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(l.Z0,{ref:s,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",t),...n})}).displayName=l.Z0.displayName},63136:function(e){e.exports={main:"chat_main__8xQu5",suggestions:"chat_suggestions__m8n2t",inputBox:"chat_inputBox__LOFws",chatBodyFull:"chat_chatBodyFull__FfKEK",chatBody:"chat_chatBody__sS1LX",chatLayout:"chat_chatLayout__pR203",chatBox:"chat_chatBox__FBct_",titleBar:"chat_titleBar__R5QlK",chatBoxBody:"chat_chatBoxBody__qT_SC",agentIndicator:"chat_agentIndicator__8V55w",chatTitleWrapper:"chat_chatTitleWrapper__6ChWq"}}},function(e){e.O(0,[4842,2663,3954,1919,3861,9259,8667,4363,4447,4357,8155,9334,2327,5477,4986,2971,2117,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);
|