khoj 1.23.4.dev1__py3-none-any.whl → 1.23.4.dev3__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.
Files changed (47) hide show
  1. khoj/interface/compiled/404/index.html +1 -1
  2. khoj/interface/compiled/_next/static/chunks/2697-9bc8f835a3c24342.js +1 -0
  3. khoj/interface/compiled/_next/static/chunks/{9178-421e47df97ff0213.js → 9178-f5d4737cf74b7d19.js} +1 -1
  4. khoj/interface/compiled/_next/static/chunks/app/agents/page-f41c3b57b5bfc0bd.js +1 -0
  5. khoj/interface/compiled/_next/static/chunks/app/automations/{page-cc875a656df43713.js → page-e0bedd962fcfa0dd.js} +1 -1
  6. khoj/interface/compiled/_next/static/chunks/app/chat/page-1b886aa4f57af1fa.js +1 -0
  7. khoj/interface/compiled/_next/static/chunks/app/factchecker/{page-bb320ff7d4dee716.js → page-32e61af29e6b431d.js} +1 -1
  8. khoj/interface/compiled/_next/static/chunks/app/{page-60193524cf570002.js → page-a31799b4c4b78da6.js} +1 -1
  9. khoj/interface/compiled/_next/static/chunks/app/search/{page-4bceb5b0df9cfd66.js → page-b3193d46c65571c5.js} +1 -1
  10. khoj/interface/compiled/_next/static/chunks/app/settings/{page-532ed8b778a0b40d.js → page-0db9b708366606ec.js} +1 -1
  11. khoj/interface/compiled/_next/static/chunks/app/share/chat/page-7df9c23b5fec66de.js +1 -0
  12. khoj/interface/compiled/_next/static/chunks/{webpack-de28762883e5816d.js → webpack-95cfd7a1948cfeed.js} +1 -1
  13. khoj/interface/compiled/_next/static/css/2272c73fc7a3b571.css +1 -0
  14. khoj/interface/compiled/_next/static/css/553f9cdcc7a2bcd6.css +1 -0
  15. khoj/interface/compiled/_next/static/css/93c1302668e4a828.css +25 -0
  16. khoj/interface/compiled/_next/static/css/{e41ec62af8ee4e38.css → d435f28db0fd3d85.css} +1 -1
  17. khoj/interface/compiled/agents/index.html +1 -1
  18. khoj/interface/compiled/agents/index.txt +2 -2
  19. khoj/interface/compiled/automations/index.html +1 -1
  20. khoj/interface/compiled/automations/index.txt +2 -2
  21. khoj/interface/compiled/chat/index.html +1 -1
  22. khoj/interface/compiled/chat/index.txt +2 -2
  23. khoj/interface/compiled/factchecker/index.html +1 -1
  24. khoj/interface/compiled/factchecker/index.txt +2 -2
  25. khoj/interface/compiled/index.html +1 -1
  26. khoj/interface/compiled/index.txt +2 -2
  27. khoj/interface/compiled/search/index.html +1 -1
  28. khoj/interface/compiled/search/index.txt +2 -2
  29. khoj/interface/compiled/settings/index.html +1 -1
  30. khoj/interface/compiled/settings/index.txt +2 -2
  31. khoj/interface/compiled/share/chat/index.html +1 -1
  32. khoj/interface/compiled/share/chat/index.txt +2 -2
  33. {khoj-1.23.4.dev1.dist-info → khoj-1.23.4.dev3.dist-info}/METADATA +1 -1
  34. {khoj-1.23.4.dev1.dist-info → khoj-1.23.4.dev3.dist-info}/RECORD +41 -40
  35. khoj/interface/compiled/_next/static/chunks/app/agents/page-f8ad4d2944dbcf91.js +0 -1
  36. khoj/interface/compiled/_next/static/chunks/app/chat/page-3e75b0e0aa3aaaf5.js +0 -1
  37. khoj/interface/compiled/_next/static/chunks/app/share/chat/page-b5e63aabfd573dba.js +0 -1
  38. khoj/interface/compiled/_next/static/css/1105696872e3f20c.css +0 -25
  39. khoj/interface/compiled/_next/static/css/37a313cb39403a84.css +0 -1
  40. khoj/interface/compiled/_next/static/css/6bde1f2045622ef7.css +0 -1
  41. /khoj/interface/compiled/_next/static/chunks/{8423-62ac6c832be2461b.js → 8423-7f5eb790353afe24.js} +0 -0
  42. /khoj/interface/compiled/_next/static/chunks/{9417-5d14ac74aaab2c66.js → 9417-2e54c6fd056982d8.js} +0 -0
  43. /khoj/interface/compiled/_next/static/{u496AO3jlFBPp2apVnMkP → spANMOcAS4N0KrnEMGnPd}/_buildManifest.js +0 -0
  44. /khoj/interface/compiled/_next/static/{u496AO3jlFBPp2apVnMkP → spANMOcAS4N0KrnEMGnPd}/_ssgManifest.js +0 -0
  45. {khoj-1.23.4.dev1.dist-info → khoj-1.23.4.dev3.dist-info}/WHEEL +0 -0
  46. {khoj-1.23.4.dev1.dist-info → khoj-1.23.4.dev3.dist-info}/entry_points.txt +0 -0
  47. {khoj-1.23.4.dev1.dist-info → khoj-1.23.4.dev3.dist-info}/licenses/LICENSE +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{39929:function(e,t,s){Promise.resolve().then(s.bind(s,38874))},38874:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return p}});var n=s(57437),a=s(65104),o=s.n(a),i=s(2265),r=s(48861),c=s(82697),l=s(16463),d=s(58485),u=s(9557);s(7395);var g=s(69591),h=s(38423),m=s(79306);function f(e){let t=(0,l.useSearchParams)().get("conversationId"),[s,a]=(0,i.useState)(""),[r,d]=(0,i.useState)(null),[u,g]=(0,i.useState)(!1),[m,f]=(0,i.useState)(null),p=e.setQueryToProcess,x=e.onConversationIdChange;if((0,i.useEffect)(()=>{r&&e.setImage64(encodeURIComponent(r))},[r,e.setImage64]),(0,i.useEffect)(()=>{let t=localStorage.getItem("image");t&&(d(t),e.setImage64(encodeURIComponent(t)),localStorage.removeItem("image"));let s=localStorage.getItem("message");s&&(g(!0),p(s))},[p]),(0,i.useEffect)(()=>{s&&(g(!0),p(s))},[s,p]),(0,i.useEffect)(()=>{t&&(null==x||x(t))},[t,x]),(0,i.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?g(!1):a("")},[e.streamedMessages]),!t){window.location.href="/";return}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:o().chatBodyFull,children:(0,n.jsx)(c.Z,{conversationId:t,setTitle:e.setTitle,setAgent:f,pendingMessage:u?s:"",incomingMessages:e.streamedMessages})}),(0,n.jsx)("div",{className:"".concat(o().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-t-2xl rounded-b-none md:rounded-xl h-fit"),children:(0,n.jsx)(h.Z,{agentColor:null==m?void 0:m.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>a(e),sendImage:e=>d(e),sendDisabled:u,chatOptionsData:e.chatOptionsData,conversationId:t,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles})})]})}function p(){let e="Khoj AI - Chat",[t,s]=(0,i.useState)(null),[a,c]=(0,i.useState)(!0),[l,h]=(0,i.useState)(e),[p,x]=(0,i.useState)(null),[v,y]=(0,i.useState)([]),[_,j]=(0,i.useState)(""),[b,I]=(0,i.useState)(!1),[w,M]=(0,i.useState)([]),[C,S]=(0,i.useState)(""),N=(0,g.k6)(),T=(0,m.G)(),B=(0,g.IC)();async function E(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let t=e.body.getReader(),s=new TextDecoder,n="␃\uD83D\uDD1A␗",a="",o=[],i={};for(;;){let e;let{done:r,value:c}=await t.read();if(r){j(""),I(!1),S("");break}for(a+=s.decode(c,{stream:!0});-1!==(e=a.indexOf(n));){let t=a.slice(0,e);if(a=a.slice(e+n.length),t){let e=v.find(e=>!e.completed);if(!e){console.error("No current message found");return}({context:o,onlineContext:i}=(0,u.VK)(t,e,o,i)),y([...v])}}}}async function k(){if(localStorage.removeItem("message"),!_||!p)return;let e={q:_,conversation_id:p,stream:!0,...N&&{region:N.region,country:N.country,city:N.city,timezone:N.timezone},...C&&{image:C}},t=await fetch("/api/chat?client=web",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});try{await E(t)}catch(s){console.error(s);let e=v.find(e=>!e.completed);if(!e)return;let t=s.message;t.includes("Error in input stream")?e.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.rawResponse="Umm, not sure what just happened. I see this error message: ".concat(t,". Could you try again or dislike this message if the issue persists?"),e.completed=!0,y([...v]),j(""),I(!1)}}return((0,i.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{c(!1),e&&s(e)}).catch(e=>{console.error(e)}),(0,g.EK)()},[]),(0,i.useEffect)(()=>{if(_){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:_||"",uploadedImageData:decodeURIComponent(C)};y(t=>[...t,e]),I(!0)}},[_]),(0,i.useEffect)(()=>{b&&k()},[b]),a)?(0,n.jsx)(d.Z,{}):(0,n.jsxs)("div",{className:"".concat(o().main," ").concat(o().chatLayout),children:[(0,n.jsx)("title",{children:"".concat(e).concat(l&&l!==e?": ".concat(l):"")}),(0,n.jsx)("div",{children:(0,n.jsx)(r.ZP,{conversationId:p,uploadedFiles:w,isMobileWidth:B})}),(0,n.jsx)("div",{className:o().chatBox,children:(0,n.jsxs)("div",{className:o().chatBoxBody,children:[!B&&p&&(0,n.jsxs)("div",{className:"".concat(o().chatTitleWrapper," text-nowrap text-ellipsis overflow-hidden max-w-screen-md grid items-top font-bold mr-8 pt-6 col-auto h-fit"),children:[l&&(0,n.jsx)("h2",{className:"text-lg text-ellipsis whitespace-nowrap overflow-x-hidden",children:l}),(0,n.jsx)(r.En,{conversationId:p,setTitle:h,sizing:"md"})]}),(0,n.jsx)(i.Suspense,{fallback:(0,n.jsx)(d.Z,{}),children:(0,n.jsx)(f,{isLoggedIn:null!==T,streamedMessages:v,chatOptionsData:t,setTitle:h,setQueryToProcess:j,setUploadedFiles:M,isMobileWidth:B,onConversationIdChange:e=>{x(e)},setImage64:S})})]})})]})}},82697:function(e,t,s){"use strict";s.d(t,{Z:function(){return x}});var n=s(57437),a=s(15238),o=s.n(a),i=s(2265),r=s(89178),c=s(94880),l=s(58485),d=s(16288),u=s(26100),g=s(19666),h=s(50495),m=e=>{let{name:t,avatar:s,link:a,description:o}=e;return(0,n.jsx)("div",{className:"relative group flex",children:(0,n.jsx)(g.pn,{children:(0,n.jsxs)(g.u,{children:[(0,n.jsx)(g.aJ,{asChild:!0,children:(0,n.jsxs)(h.z,{variant:"ghost",className:"flex items-center justify-center",children:[s,(0,n.jsx)("div",{children:t})]})}),(0,n.jsx)(g._v,{children:(0,n.jsxs)("div",{className:"w-80 h-30",children:[(0,n.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,n.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[s,(0,n.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,n.jsx)(u.o,{weight:"bold",className:"ml-1"})]})]})}),o&&(0,n.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:o||"A Khoj agent"})]})})]})})})},f=s(89417),p=s(69591);function x(e){let[t,s]=(0,i.useState)(null),[a,u]=(0,i.useState)(0),[g,h]=(0,i.useState)(!0),x=(0,i.useRef)(null),v=(0,i.useRef)(null),y=(0,i.useRef)(null),[_,j]=(0,i.useState)(null),[b,I]=(0,i.useState)(!1),w=(0,p.IC)();(0,i.useEffect)(()=>{a<2&&((null==t?void 0:t.chat.length)||setTimeout(()=>{M()},500))},[t,a]),(0,i.useEffect)(()=>{if(!g||b)return;let n=new IntersectionObserver(n=>{n[0].isIntersecting&&g&&(I(!0),function(n){if(!g||b)return;let a=n+1,o="";if(e.conversationId)o="/api/chat/history?client=web&conversation_id=".concat(encodeURIComponent(e.conversationId),"&n=").concat(10*a);else{if(!e.publicConversationSlug)return;o="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(10*a)}fetch(o).then(e=>e.json()).then(a=>{if(e.setTitle(a.response.slug),a&&a.response&&a.response.chat&&a.response.chat.length>0){if(a.response.chat.length===(null==t?void 0:t.chat.length)){h(!1),I(!1);return}e.setAgent(a.response.agent),s(a.response),n<2&&M(),I(!1)}else{if(a.response.agent&&a.response.conversation_id){let t={chat:[],agent:a.response.agent,conversation_id:a.response.conversation_id,slug:a.response.slug};e.setAgent(a.response.agent),s(t)}h(!1),I(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(a),u(e=>e+1))},{threshold:1});return y.current&&n.observe(y.current),()=>n.disconnect()},[g,a,b]),(0,i.useEffect)(()=>{h(!0),I(!1),u(0),s(null)},[e.conversationId]),(0,i.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&j(e.incomingMessages.length-1)}C()&&M()},[e.incomingMessages]);let M=()=>{v.current&&v.current.scrollIntoView(!1)},C=()=>{if(!v.current)return!1;let{scrollTop:e,scrollHeight:t,clientHeight:s}=v.current;return e+s>=t-25};return e.conversationId||e.publicConversationSlug?(0,n.jsx)(c.x,{className:"h-[80vh]",children:(0,n.jsx)("div",{ref:x,children:(0,n.jsxs)("div",{className:o().chatHistory,ref:v,children:[(0,n.jsx)("div",{ref:y,style:{height:"1px"},children:b&&(0,n.jsx)(l.l,{message:"Loading Conversation",className:"opacity-50"})}),t&&t.chat&&t.chat.map((e,s)=>(0,n.jsx)(r.Z,{isMobileWidth:w,chatMessage:e,customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:s===t.chat.length-1},"".concat(s,"fullHistory"))),e.incomingMessages&&e.incomingMessages.map((e,s)=>(0,n.jsxs)(i.Fragment,{children:[(0,n.jsx)(r.Z,{isMobileWidth:w,chatMessage:{message:e.rawQuery,context:[],onlineContext:{},created:e.timestamp,by:"you",automationId:"",uploadedImageData:e.uploadedImageData},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500")},"".concat(s,"outgoing")),e.trainOfThought&&function(e,t,s,a){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],c=e.length-1;return(0,n.jsxs)("div",{className:"".concat(o().trainOfThought," shadow-sm"),children:[!i&&(0,n.jsx)(l.l,{className:"float-right"}),e.map((e,a)=>(0,n.jsx)(r.H,{message:e,primary:a===c&&t&&!i,agentColor:s},"train-".concat(a)))]},a)}(e.trainOfThought,s===_,(null==t?void 0:t.agent.color)||"orange","".concat(s,"trainOfThought"),e.completed),(0,n.jsx)(r.Z,{isMobileWidth:w,chatMessage:{message:e.rawResponse,context:e.context,onlineContext:e.onlineContext,created:e.timestamp,by:"khoj",automationId:"",rawQuery:e.rawQuery},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"".concat(s,"incoming"))]},"incomingMessage".concat(s))),e.pendingMessage&&(0,n.jsx)(r.Z,{isMobileWidth:w,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},created:new Date().getTime().toString(),by:"you",automationId:"",uploadedImageData:e.pendingMessage},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),t&&(0,n.jsx)("div",{className:"".concat(o().agentIndicator," pb-4"),children:(0,n.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,n.jsx)(m,{name:t&&t.agent&&t.agent.name?t.agent.name:"Agent",link:t&&t.agent&&t.agent.slug?"/agents?agent=".concat(t.agent.slug):"/agents",avatar:(0,f.T)(t.agent.icon,t.agent.color)||(0,n.jsx)(d.v,{}),description:t&&t.agent&&t.agent.persona?t.agent.persona:""})})})]})})}):null}},16463:function(e,t,s){"use strict";var n=s(71169);s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},65104: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"}},15238:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",chatLayout:"chatHistory_chatLayout__ABli_",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}}},function(e){e.O(0,[7812,3630,3170,3954,9001,3062,743,121,7071,4051,9984,1603,9417,9178,8423,2971,7023,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3111],{91955:function(e,t,s){Promise.resolve().then(s.bind(s,5506))},82697:function(e,t,s){"use strict";s.d(t,{Z:function(){return x}});var n=s(57437),a=s(15238),o=s.n(a),i=s(2265),r=s(89178),c=s(94880),l=s(58485),d=s(16288),u=s(26100),h=s(19666),g=s(50495),m=e=>{let{name:t,avatar:s,link:a,description:o}=e;return(0,n.jsx)("div",{className:"relative group flex",children:(0,n.jsx)(h.pn,{children:(0,n.jsxs)(h.u,{children:[(0,n.jsx)(h.aJ,{asChild:!0,children:(0,n.jsxs)(g.z,{variant:"ghost",className:"flex items-center justify-center",children:[s,(0,n.jsx)("div",{children:t})]})}),(0,n.jsx)(h._v,{children:(0,n.jsxs)("div",{className:"w-80 h-30",children:[(0,n.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,n.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[s,(0,n.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,n.jsx)(u.o,{weight:"bold",className:"ml-1"})]})]})}),o&&(0,n.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:o||"A Khoj agent"})]})})]})})})},f=s(89417),p=s(69591);function x(e){let[t,s]=(0,i.useState)(null),[a,u]=(0,i.useState)(0),[h,g]=(0,i.useState)(!0),x=(0,i.useRef)(null),v=(0,i.useRef)(null),y=(0,i.useRef)(null),[_,j]=(0,i.useState)(null),[b,C]=(0,i.useState)(!1),I=(0,p.IC)();(0,i.useEffect)(()=>{a<2&&((null==t?void 0:t.chat.length)||setTimeout(()=>{M()},500))},[t,a]),(0,i.useEffect)(()=>{if(!h||b)return;let n=new IntersectionObserver(n=>{n[0].isIntersecting&&h&&(C(!0),function(n){if(!h||b)return;let a=n+1,o="";if(e.conversationId)o="/api/chat/history?client=web&conversation_id=".concat(encodeURIComponent(e.conversationId),"&n=").concat(10*a);else{if(!e.publicConversationSlug)return;o="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(10*a)}fetch(o).then(e=>e.json()).then(a=>{if(e.setTitle(a.response.slug),a&&a.response&&a.response.chat&&a.response.chat.length>0){if(a.response.chat.length===(null==t?void 0:t.chat.length)){g(!1),C(!1);return}e.setAgent(a.response.agent),s(a.response),n<2&&M(),C(!1)}else{if(a.response.agent&&a.response.conversation_id){let t={chat:[],agent:a.response.agent,conversation_id:a.response.conversation_id,slug:a.response.slug};e.setAgent(a.response.agent),s(t)}g(!1),C(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(a),u(e=>e+1))},{threshold:1});return y.current&&n.observe(y.current),()=>n.disconnect()},[h,a,b]),(0,i.useEffect)(()=>{g(!0),C(!1),u(0),s(null)},[e.conversationId]),(0,i.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&j(e.incomingMessages.length-1)}N()&&M()},[e.incomingMessages]);let M=()=>{v.current&&v.current.scrollIntoView(!1)},N=()=>{if(!v.current)return!1;let{scrollTop:e,scrollHeight:t,clientHeight:s}=v.current;return e+s>=t-25};return e.conversationId||e.publicConversationSlug?(0,n.jsx)(c.x,{className:"h-[80vh]",children:(0,n.jsx)("div",{ref:x,children:(0,n.jsxs)("div",{className:o().chatHistory,ref:v,children:[(0,n.jsx)("div",{ref:y,style:{height:"1px"},children:b&&(0,n.jsx)(l.l,{message:"Loading Conversation",className:"opacity-50"})}),t&&t.chat&&t.chat.map((e,s)=>(0,n.jsx)(r.Z,{isMobileWidth:I,chatMessage:e,customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:s===t.chat.length-1},"".concat(s,"fullHistory"))),e.incomingMessages&&e.incomingMessages.map((e,s)=>(0,n.jsxs)(i.Fragment,{children:[(0,n.jsx)(r.Z,{isMobileWidth:I,chatMessage:{message:e.rawQuery,context:[],onlineContext:{},created:e.timestamp,by:"you",automationId:"",uploadedImageData:e.uploadedImageData},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500")},"".concat(s,"outgoing")),e.trainOfThought&&function(e,t,s,a){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],c=e.length-1;return(0,n.jsxs)("div",{className:"".concat(o().trainOfThought," shadow-sm"),children:[!i&&(0,n.jsx)(l.l,{className:"float-right"}),e.map((e,a)=>(0,n.jsx)(r.H,{message:e,primary:a===c&&t&&!i,agentColor:s},"train-".concat(a)))]},a)}(e.trainOfThought,s===_,(null==t?void 0:t.agent.color)||"orange","".concat(s,"trainOfThought"),e.completed),(0,n.jsx)(r.Z,{isMobileWidth:I,chatMessage:{message:e.rawResponse,context:e.context,onlineContext:e.onlineContext,created:e.timestamp,by:"khoj",automationId:"",rawQuery:e.rawQuery},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"".concat(s,"incoming"))]},"incomingMessage".concat(s))),e.pendingMessage&&(0,n.jsx)(r.Z,{isMobileWidth:I,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},created:new Date().getTime().toString(),by:"you",automationId:"",uploadedImageData:e.pendingMessage},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),t&&(0,n.jsx)("div",{className:"".concat(o().agentIndicator," pb-4"),children:(0,n.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,n.jsx)(m,{name:t&&t.agent&&t.agent.name?t.agent.name:"Agent",link:t&&t.agent&&t.agent.slug?"/agents?agent=".concat(t.agent.slug):"/agents",avatar:(0,f.T)(t.agent.icon,t.agent.color)||(0,n.jsx)(d.v,{}),description:t&&t.agent&&t.agent.persona?t.agent.persona:""})})})]})})}):null}},5506:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return f}});var n=s(57437),a=s(11930),o=s.n(a),i=s(2265),r=s(48861),c=s(82697),l=s(58485);s(7395);var d=s(69591),u=s(79306),h=s(38423),g=s(9557);function m(e){let[t,s]=(0,i.useState)(""),[a,r]=(0,i.useState)(null),[l,d]=(0,i.useState)(!1),[u,g]=(0,i.useState)(null),m=e.setQueryToProcess,f=e.streamedMessages;return((0,i.useEffect)(()=>{a&&e.setImage64(encodeURIComponent(a))},[a,e.setImage64]),(0,i.useEffect)(()=>{t&&(d(!0),m(t))},[t,m]),(0,i.useEffect)(()=>{f&&f.length>0&&f[f.length-1].completed?d(!1):s("")},[f]),e.publicConversationSlug||e.conversationId)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:o().chatBodyFull,children:(0,n.jsx)(c.Z,{publicConversationSlug:e.publicConversationSlug,conversationId:e.conversationId||"",setAgent:g,setTitle:e.setTitle,pendingMessage:l?t:"",incomingMessages:e.streamedMessages})}),(0,n.jsx)("div",{className:"".concat(o().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-t-2xl rounded-b-none md:rounded-xl"),children:(0,n.jsx)(h.Z,{isLoggedIn:e.isLoggedIn,sendMessage:e=>s(e),sendImage:e=>r(e),sendDisabled:l,chatOptionsData:e.chatOptionsData,conversationId:e.conversationId,agentColor:null==u?void 0:u.color,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles})})]}):(0,n.jsx)("div",{className:o().suggestions,children:"Whoops, nothing to see here!"})}function f(){let[e,t]=(0,i.useState)(null),[s,a]=(0,i.useState)(!0),[c,h]=(0,i.useState)("Khoj AI - Chat"),[f,p]=(0,i.useState)(void 0),[x,v]=(0,i.useState)([]),[y,_]=(0,i.useState)(""),[j,b]=(0,i.useState)(!1),[C,I]=(0,i.useState)([]),[M,N]=(0,i.useState)(void 0),[S,w]=(0,i.useState)(""),O=(0,d.k6)(),T=(0,u.G)(),B=(0,d.IC)();async function k(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let t=e.body.getReader(),s=new TextDecoder,n="␃\uD83D\uDD1A␗",a="";for(;;){let e;let{done:o,value:i}=await t.read();if(o){_(""),b(!1),w("");break}for(a+=s.decode(i,{stream:!0});-1!==(e=a.indexOf(n));){let t=a.slice(0,e);if(a=a.slice(e+n.length),t){let e=x.find(e=>!e.completed);if(!e){console.error("No current message found");return}(0,g.VK)(t,e),v([...x])}}}}async function L(){if(!y||!f)return;let e={q:y,conversation_id:f,stream:!0,...O&&{region:O.region,country:O.country,city:O.city,timezone:O.timezone},...S&&{image:S}},t=await fetch("/api/chat?client=web",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});try{await k(t)}catch(e){console.error(e)}}return((0,i.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{a(!1),e&&t(e)}).catch(e=>{console.error(e)}),(0,d.EK)(),N(window.location.pathname.split("/").pop()||"")},[]),(0,i.useEffect)(()=>{if(y&&!f){fetch("/api/chat/share/fork?public_conversation_slug=".concat(M),{method:"POST",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{p(e.conversation_id)}).catch(e=>{console.error(e)});return}if(y){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:y||"",uploadedImageData:decodeURIComponent(S)};v(t=>[...t,e]),b(!0)}},[y,f,M]),(0,i.useEffect)(()=>{j&&L()},[j]),s)?(0,n.jsx)(l.Z,{}):M?(0,n.jsxs)("div",{className:"".concat(o().main," ").concat(o().chatLayout),children:[(0,n.jsx)("title",{children:c}),(0,n.jsx)("div",{className:o().sidePanel,children:(0,n.jsx)(r.ZP,{conversationId:null!=f?f:null,uploadedFiles:C,isMobileWidth:B})}),(0,n.jsx)("div",{className:o().chatBox,children:(0,n.jsx)("div",{className:o().chatBoxBody,children:(0,n.jsx)(i.Suspense,{fallback:(0,n.jsx)(l.Z,{}),children:(0,n.jsx)(m,{conversationId:f,streamedMessages:x,setQueryToProcess:_,isLoggedIn:null!==T,publicConversationSlug:M,chatOptionsData:e,setTitle:h,setUploadedFiles:I,isMobileWidth:B,setImage64:w})})})})]}):(0,n.jsx)("div",{className:o().suggestions,children:"Whoops, nothing to see here!"})}},15238:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",chatLayout:"chatHistory_chatLayout__ABli_",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}},11930:function(e){e.exports={main:"sharedChat_main__7Nayy",suggestions:"sharedChat_suggestions__V8kr_",inputBox:"sharedChat_inputBox__wRW5A",chatBodyFull:"sharedChat_chatBodyFull__O1MOv",chatBody:"sharedChat_chatBody__OnHDL",chatLayout:"sharedChat_chatLayout__gutlc",chatBox:"sharedChat_chatBox__PmAPg",titleBar:"sharedChat_titleBar__vOHp_",chatBoxBody:"sharedChat_chatBoxBody__ef2Nl",agentIndicator:"sharedChat_agentIndicator__ORCl4"}}},function(e){e.O(0,[7849,3630,3170,3954,9001,3062,743,121,7071,4051,9984,1603,9417,9178,8423,2971,7023,1744],function(){return e(e.s=91955)}),_N_E=e.O()}]);