khoj 1.26.4.dev2__py3-none-any.whl → 1.26.5.dev29__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/interface/compiled/404/index.html +1 -1
- khoj/interface/compiled/_next/static/chunks/1210.132a7e1910006bbb.js +1 -0
- khoj/interface/compiled/_next/static/chunks/1279-f37ee4a388ebf544.js +1 -0
- khoj/interface/compiled/_next/static/chunks/1459.690bf20e7d7b7090.js +1 -0
- khoj/interface/compiled/_next/static/chunks/1603-b9d95833e0e025e8.js +1 -0
- khoj/interface/compiled/_next/static/chunks/1970-1d6d0c1b00b4f343.js +1 -0
- khoj/interface/compiled/_next/static/chunks/2697-61fcba89fd87eab4.js +1 -0
- khoj/interface/compiled/_next/static/chunks/3423-aad88d6c1f029135.js +1 -0
- khoj/interface/compiled/_next/static/chunks/394-6bcb8c429f168f21.js +3 -0
- khoj/interface/compiled/_next/static/chunks/4602-8eeb4b76385ad159.js +1 -0
- khoj/interface/compiled/_next/static/chunks/5512-94c7c2bbcf58c19d.js +1 -0
- khoj/interface/compiled/_next/static/chunks/7113-f2e114d7034a0835.js +1 -0
- khoj/interface/compiled/_next/static/chunks/{4086-2c74808ba38a5a0f.js → 8840-b8d7b9f0923c6651.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/9417-759984ad62caa3dc.js +1 -0
- khoj/interface/compiled/_next/static/chunks/9479-4b443fdcc99141c9.js +1 -0
- khoj/interface/compiled/_next/static/chunks/94ca1967.5584df65931cfe83.js +1 -0
- khoj/interface/compiled/_next/static/chunks/964ecbae.ea4eab2a3a835ffe.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/agents/page-5ae1e540bb5be8a9.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/automations/{page-5480731341f34450.js → page-774ae3e033f938cd.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/page-97f5b61aaf46d364.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/factchecker/{page-e7b34316ec6f44de.js → page-d82403db2866bad8.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/{page-10a5aad6e04f3cf8.js → page-75bbfb564884054b.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/search/{page-d56541c746fded7d.js → page-9b64f61caa5bd7f9.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/settings/{page-e044a999468a7c5d.js → page-989cf38b87b19427.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/share/chat/page-eb9e282691858f2e.js +1 -0
- khoj/interface/compiled/_next/static/chunks/webpack-8f4afe09848e24e1.js +1 -0
- khoj/interface/compiled/_next/static/css/{c808691c459e3887.css → 3cf13271869a4aeb.css} +1 -1
- khoj/interface/compiled/_next/static/css/4cae6c0e5c72fb2d.css +1 -0
- khoj/interface/compiled/_next/static/css/76d55eb435962b19.css +25 -0
- khoj/interface/compiled/_next/static/css/{3e1f1fdd70775091.css → 80bd6301fc657983.css} +1 -1
- khoj/interface/compiled/_next/static/css/ddcc0cf73e062476.css +1 -0
- khoj/interface/compiled/agents/index.html +1 -1
- khoj/interface/compiled/agents/index.txt +2 -2
- khoj/interface/compiled/automations/index.html +1 -1
- khoj/interface/compiled/automations/index.txt +2 -2
- khoj/interface/compiled/chat/index.html +1 -1
- khoj/interface/compiled/chat/index.txt +2 -2
- khoj/interface/compiled/factchecker/index.html +1 -1
- khoj/interface/compiled/factchecker/index.txt +2 -2
- khoj/interface/compiled/index.html +1 -1
- khoj/interface/compiled/index.txt +2 -2
- khoj/interface/compiled/search/index.html +1 -1
- khoj/interface/compiled/search/index.txt +2 -2
- khoj/interface/compiled/settings/index.html +1 -1
- khoj/interface/compiled/settings/index.txt +2 -2
- khoj/interface/compiled/share/chat/index.html +1 -1
- khoj/interface/compiled/share/chat/index.txt +2 -2
- khoj/processor/conversation/google/gemini_chat.py +28 -13
- khoj/processor/conversation/google/utils.py +34 -12
- khoj/processor/conversation/openai/gpt.py +4 -4
- khoj/processor/conversation/prompts.py +144 -0
- khoj/processor/conversation/utils.py +22 -13
- khoj/processor/image/generate.py +5 -5
- khoj/processor/tools/online_search.py +4 -4
- khoj/routers/api.py +4 -2
- khoj/routers/api_agents.py +41 -20
- khoj/routers/api_chat.py +85 -46
- khoj/routers/helpers.py +225 -29
- khoj/routers/web_client.py +0 -11
- khoj/utils/helpers.py +7 -3
- {khoj-1.26.4.dev2.dist-info → khoj-1.26.5.dev29.dist-info}/METADATA +1 -1
- {khoj-1.26.4.dev2.dist-info → khoj-1.26.5.dev29.dist-info}/RECORD +67 -62
- khoj/interface/compiled/_next/static/chunks/121-7024f479c297aef0.js +0 -1
- khoj/interface/compiled/_next/static/chunks/1603-fa3ee48860b9dc5c.js +0 -1
- khoj/interface/compiled/_next/static/chunks/2697-a38d01981ad3bdf8.js +0 -1
- khoj/interface/compiled/_next/static/chunks/4051-2cf66369d6ca0f1d.js +0 -3
- khoj/interface/compiled/_next/static/chunks/477-ec86e93db10571c1.js +0 -1
- khoj/interface/compiled/_next/static/chunks/51-e8f5bdb69b5ea421.js +0 -1
- khoj/interface/compiled/_next/static/chunks/7762-79f2205740622b5c.js +0 -1
- khoj/interface/compiled/_next/static/chunks/9178-899fe9a6b754ecfe.js +0 -1
- khoj/interface/compiled/_next/static/chunks/9417-46ed3aaa639c85ef.js +0 -1
- khoj/interface/compiled/_next/static/chunks/9479-ea776e73f549090c.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/agents/page-88aa3042711107b7.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/page-702057ccbcf27881.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/share/chat/page-fbbd66a4d4633438.js +0 -1
- khoj/interface/compiled/_next/static/chunks/webpack-2651a68f46ac3cb7.js +0 -1
- khoj/interface/compiled/_next/static/css/2de69f0be774c768.css +0 -1
- khoj/interface/compiled/_next/static/css/592ca99f5122e75a.css +0 -1
- khoj/interface/compiled/_next/static/css/b9a6bf04305d98d7.css +0 -25
- /khoj/interface/compiled/_next/static/{wyjqS7cuSX-u62BTNYqhU → ZLHCGFLxZSUj0jEJSc99T}/_buildManifest.js +0 -0
- /khoj/interface/compiled/_next/static/{wyjqS7cuSX-u62BTNYqhU → ZLHCGFLxZSUj0jEJSc99T}/_ssgManifest.js +0 -0
- {khoj-1.26.4.dev2.dist-info → khoj-1.26.5.dev29.dist-info}/WHEEL +0 -0
- {khoj-1.26.4.dev2.dist-info → khoj-1.26.5.dev29.dist-info}/entry_points.txt +0 -0
- {khoj-1.26.4.dev2.dist-info → khoj-1.26.5.dev29.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2697],{82697:function(e,t,n){"use strict";n.d(t,{Z:function(){return x}});var s=n(57437),o=n(15238),a=n.n(o),i=n(2265),l=n(53423),r=n(94880),c=n(58485),u=n(16288),d=n(20721),g=n(26100),h=n(19666),m=n(50495),v=e=>{let{name:t,avatar:n,link:o,description:a}=e;return(0,s.jsx)("div",{className:"relative group flex",children:(0,s.jsx)(h.pn,{children:(0,s.jsxs)(h.u,{delayDuration:0,children:[(0,s.jsx)(h.aJ,{asChild:!0,children:(0,s.jsxs)(m.z,{variant:"ghost",className:"flex items-center justify-center",children:[n,(0,s.jsx)("div",{children:t})]})}),(0,s.jsx)(h._v,{children:(0,s.jsxs)("div",{className:"w-80 h-30",children:[(0,s.jsx)("a",{href:o,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,s.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[n,(0,s.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,s.jsx)(g.o,{weight:"bold",className:"ml-1"})]})]})}),a&&(0,s.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:a||"A Khoj agent"})]})})]})})})},f=n(89417),p=n(69591);function x(e){var t,n,o,g,h,m,x,b,y;let[j,M]=(0,i.useState)(null),[C,w]=(0,i.useState)(0),[N,_]=(0,i.useState)(!0),I=(0,i.useRef)(null),S=(0,i.useRef)(null),k=(0,i.useRef)(null),H=(0,i.useRef)(null),[T,E]=(0,i.useState)(null),[L,q]=(0,i.useState)(!1),[O,A]=(0,i.useState)(!0),R=(0,p.IC)(),Q="[data-radix-scroll-area-viewport]";(0,i.useEffect)(()=>{var e;let t=null===(e=S.current)||void 0===e?void 0:e.querySelector(Q);if(!t)return;let n=()=>{let{scrollTop:e,scrollHeight:n,clientHeight:s}=t;A(n-(e+s)<=50)};return t.addEventListener("scroll",n),()=>t.removeEventListener("scroll",n)},[]),(0,i.useEffect)(()=>{e.incomingMessages&&e.incomingMessages.length>0&&O&&Z()},[e.incomingMessages,O]),(0,i.useEffect)(()=>{j&&j.chat&&j.chat.length>0&&C<2&&requestAnimationFrame(()=>{var e;null===(e=k.current)||void 0===e||e.scrollIntoView({behavior:"auto",block:"start"})})},[j,C]),(0,i.useEffect)(()=>{if(!N||L)return;let t=new IntersectionObserver(t=>{t[0].isIntersecting&&N&&(q(!0),function(t){if(!N||L)return;let n=(t+1)*10,s="";if(e.conversationId)s="/api/chat/history?client=web&conversation_id=".concat(encodeURIComponent(e.conversationId),"&n=").concat(n);else{if(!e.publicConversationSlug)return;s="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(n)}fetch(s).then(e=>e.json()).then(n=>{if(e.setTitle(n.response.slug),n&&n.response&&n.response.chat&&n.response.chat.length>0){if(w(Math.ceil(n.response.chat.length/10)),n.response.chat.length===(null==j?void 0:j.chat.length)){_(!1),q(!1);return}e.setAgent(n.response.agent),M(n.response),q(!1),0===t?Z(!0):W()}else{if(n.response.agent&&n.response.conversation_id){let t={chat:[],agent:n.response.agent,conversation_id:n.response.conversation_id,slug:n.response.slug};e.setAgent(n.response.agent),M(t)}_(!1),q(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(C))},{threshold:1});return I.current&&t.observe(I.current),()=>t.disconnect()},[N,C,L]),(0,i.useEffect)(()=>{_(!0),q(!1),w(0),M(null)},[e.conversationId]),(0,i.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&(E(e.incomingMessages.length-1),e.setTitle(t.rawQuery))}},[e.incomingMessages]);let W=()=>{var e;let t=null===(e=S.current)||void 0===e?void 0:e.querySelector(Q);requestAnimationFrame(()=>{var e;null===(e=H.current)||void 0===e||e.scrollIntoView({behavior:"auto",block:"start"}),null==t||t.scrollBy({behavior:"smooth",top:-150})})},Z=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=null===(e=S.current)||void 0===e?void 0:e.querySelector(Q);requestAnimationFrame(()=>{null==n||n.scrollTo({top:n.scrollHeight,behavior:t?"auto":"smooth"})}),A(!0)};return e.conversationId||e.publicConversationSlug?(0,s.jsx)(r.x,{className:"h-[80vh] relative",ref:S,children:(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"".concat(a().chatHistory," ").concat(e.customClassName),children:[(0,s.jsx)("div",{ref:I,style:{height:"1px"},children:L&&(0,s.jsx)(c.l,{message:"Loading Conversation",className:"opacity-50"})}),j&&j.chat&&j.chat.map((e,t)=>{var n;return(0,s.jsx)(l.Z,{ref:t===j.chat.length-2?k:t===j.chat.length-(C-1)*10?H:null,isMobileWidth:R,chatMessage:e,customClassName:"fullHistory",borderLeftColor:"".concat(null==j?void 0:null===(n=j.agent)||void 0===n?void 0:n.color,"-500"),isLastMessage:t===j.chat.length-1},"".concat(t,"fullHistory"))}),e.incomingMessages&&e.incomingMessages.map((e,t)=>{var n,o,r;return(0,s.jsxs)(i.Fragment,{children:[(0,s.jsx)(l.Z,{isMobileWidth:R,chatMessage:{message:e.rawQuery,context:[],onlineContext:{},created:e.timestamp,by:"you",automationId:"",images:e.images},customClassName:"fullHistory",borderLeftColor:"".concat(null==j?void 0:null===(n=j.agent)||void 0===n?void 0:n.color,"-500")},"".concat(t,"outgoing")),e.trainOfThought&&function(e,t,n,o){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=e.length-1;return(0,s.jsxs)("div",{className:"".concat(a().trainOfThought," shadow-sm"),children:[!i&&(0,s.jsx)(c.l,{className:"float-right"}),e.map((e,o)=>(0,s.jsx)(l.H,{message:e,primary:o===r&&t&&!i,agentColor:n},"train-".concat(o)))]},o)}(e.trainOfThought,t===T,(null==j?void 0:null===(o=j.agent)||void 0===o?void 0:o.color)||"orange","".concat(t,"trainOfThought"),e.completed),(0,s.jsx)(l.Z,{isMobileWidth:R,chatMessage:{message:e.rawResponse,context:e.context,onlineContext:e.onlineContext,created:e.timestamp,by:"khoj",automationId:"",rawQuery:e.rawQuery,intent:{type:e.intentType||"",query:e.rawQuery,"memory-type":"","inferred-queries":e.inferredQueries||[]}},customClassName:"fullHistory",borderLeftColor:"".concat(null==j?void 0:null===(r=j.agent)||void 0===r?void 0:r.color,"-500"),isLastMessage:!0},"".concat(t,"incoming"))]},"incomingMessage".concat(t))}),e.pendingMessage&&(0,s.jsx)(l.Z,{isMobileWidth:R,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},created:new Date().getTime().toString(),by:"you",automationId:""},customClassName:"fullHistory",borderLeftColor:"".concat(null==j?void 0:null===(t=j.agent)||void 0===t?void 0:t.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),j&&(0,s.jsx)("div",{className:"".concat(a().agentIndicator," pb-4"),children:(0,s.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,s.jsx)(v,{name:j&&j.agent&&(null===(g=j.agent)||void 0===g?void 0:g.name)?null===(h=j.agent)||void 0===h?void 0:h.name:"Agent",link:j&&j.agent&&(null===(m=j.agent)||void 0===m?void 0:m.slug)?"/agents?agent=".concat(null===(x=j.agent)||void 0===x?void 0:x.slug):"/agents",avatar:(0,f.TI)(null===(n=j.agent)||void 0===n?void 0:n.icon,null===(o=j.agent)||void 0===o?void 0:o.color)||(0,s.jsx)(u.v,{}),description:j&&j.agent&&(null===(b=j.agent)||void 0===b?void 0:b.persona)?null===(y=j.agent)||void 0===y?void 0:y.persona:"Your agent is no longer available. You will be reset to the default agent."})})})]}),(0,s.jsx)("div",{className:"".concat(e.customClassName," fixed bottom-[15%] z-10"),children:!O&&(0,s.jsx)("button",{title:"Scroll to bottom",className:"absolute bottom-0 right-0 bg-white dark:bg-[hsl(var(--background))] text-neutral-500 dark:text-white p-2 rounded-full shadow-xl",onClick:()=>{Z(),A(!0)},children:(0,s.jsx)(d.K,{size:24})})})]})}):null}},15238:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3423],{53423:function(e,t,a){"use strict";a.d(t,{H:function(){return en},Z:function(){return er}});var s=a(57437),n=a(34531),l=a.n(n),r=a(14944),o=a(39952),c=a.n(o),i=a(2265),d=a(34040);a(7395);var h=a(26100),u=a(36013),m=a(13304),g=a(12218),p=a(74697),f=a(37440);let x=m.fC,j=m.xz;m.x8;let w=m.h_,b=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.aV,{className:(0,f.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n,ref:t})});b.displayName=m.aV.displayName;let y=(0,g.j)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),N=i.forwardRef((e,t)=>{let{side:a="right",className:n,children:l,...r}=e;return(0,s.jsxs)(w,{children:[(0,s.jsx)(b,{}),(0,s.jsxs)(m.VY,{ref:t,className:(0,f.cn)(y({side:a}),n),...r,children:[l,(0,s.jsxs)(m.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,s.jsx)(p.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});N.displayName=m.VY.displayName;let k=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,f.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};k.displayName="SheetHeader";let C=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.Dx,{ref:t,className:(0,f.cn)("text-lg font-semibold text-foreground",a),...n})});C.displayName=m.Dx.displayName;let M=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.dk,{ref:t,className:(0,f.cn)("text-sm text-muted-foreground",a),...n})});M.displayName=m.dk.displayName;var _=a(19573),v=a(11838),R=a.n(v),E=a(89417);let T=new r.Z({html:!0,linkify:!0,typographer:!0});function D(e){let t=(0,E.Le)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?R().sanitize(T.render(t)):R().sanitize(t)}(e),[n,l]=(0,i.useState)(!1);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:n&&!e.showFullContent,onOpenChange:l,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsxs)(u.Zb,{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg p-2 bg-muted border-none"),children:[(0,s.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.title]}),(0,s.jsx)("p",{className:"".concat(e.showFullContent?"block":"overflow-hidden line-clamp-2"),dangerouslySetInnerHTML:{__html:a}})]})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsxs)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg p-2 border-none",children:[(0,s.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,s.jsx)("p",{className:"overflow-hidden line-clamp-3",dangerouslySetInnerHTML:{__html:a}})]})})]})})}function L(e){let[t,a]=(0,i.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let n="https://www.google.com/s2/favicons?domain=globe",l="unknown";try{l=new URL(e.link).hostname,n="https://www.google.com/s2/favicons?domain=".concat(l)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsx)(u.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words rounded-lg text-balance p-2 bg-muted border-none"),children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2 flex-shrink-0"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]})})})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsx)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-3"),children:e.description})]})})})})]})})}function S(e){let[t,a]=(0,i.useState)(3);(0,i.useEffect)(()=>{a(e.isMobileWidth?1:3)},[e.isMobileWidth]);let n=e.notesReferenceCardData.slice(0,t),l=n.length<t?e.onlineReferenceCardData.slice(0,t-n.length):[],r=e.notesReferenceCardData.length>0||e.onlineReferenceCardData.length>0,o=e.notesReferenceCardData.length+e.onlineReferenceCardData.length;return 0===o?null:(0,s.jsxs)("div",{className:"pt-0 px-4 pb-4 md:px-6",children:[(0,s.jsxs)("h3",{className:"inline-flex items-center",children:["References",(0,s.jsxs)("p",{className:"text-gray-400 m-2",children:[o," sources"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[n.map((e,t)=>(0,i.createElement)(D,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),l.map((e,t)=>(0,i.createElement)(L,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),r&&(0,s.jsx)(F,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData})]})]})}function F(e){return e.notesReferenceCardData||e.onlineReferenceCardData?(0,s.jsxs)(x,{children:[(0,s.jsxs)(j,{className:"text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center !m-2 inline-flex",children:["View references",(0,s.jsx)(h.o,{className:"m-1"})]}),(0,s.jsxs)(N,{className:"overflow-y-scroll",children:[(0,s.jsxs)(k,{children:[(0,s.jsx)(C,{children:"References"}),(0,s.jsx)(M,{children:"View all references for this response"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.notesReferenceCardData.map((e,t)=>(0,i.createElement)(D,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,i.createElement)(L,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]}):null}var B=a(34149),H=a(29386),A=a(31784),O=a(60665),W=a(96006),Z=a(18444),q=a(35304),z=a(8589),P=a(13493),G=a(63205),U=a(32970),I=a(84120),V=a(92880),$=a(48408),J=a(67722),Y=a(58485),K=a(58575),Q=a(25800);let X=(0,a(57818).default)(()=>Promise.all([a.e(6555),a.e(7293),a.e(1459),a.e(1210)]).then(a.bind(a,51210)).then(e=>e.default),{loadableGenerated:{webpack:()=>[51210]},ssr:!1});function ee(e){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)(Y.Z,{}),children:(0,s.jsx)(X,{data:e.data})})}let et=new r.Z({html:!0,linkify:!0,typographer:!0});function ea(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function es(e){let{uquery:t,kquery:a}=e,[n,r]=(0,i.useState)(null);return(0,i.useEffect)(()=>{null!==n&&setTimeout(()=>{r(null)},2e3)},[n]),(0,s.jsxs)("div",{className:"".concat(l().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,s.jsx)("button",{title:"Like",className:l().thumbsUpButton,disabled:null!==n,onClick:()=>{ea(t,a,"positive"),r(!0)},children:!0===n?(0,s.jsx)(B.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,s.jsx)(B.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,s.jsx)("button",{title:"Dislike",className:l().thumbsDownButton,disabled:null!==n,onClick:()=>{ea(t,a,"negative"),r(!1)},children:!1===n?(0,s.jsx)(H.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,s.jsx)(H.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function en(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),n="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,s.jsx)(A.a,{className:"".concat(n)}):a.includes("generating")?(0,s.jsx)(O.Z,{className:"".concat(n)}):a.includes("data sources")||a.includes("notes")?(0,s.jsx)(W.g,{className:"".concat(n)}):a.includes("read")?(0,s.jsx)(Z.f,{className:"".concat(n)}):a.includes("search")?(0,s.jsx)(q.Y,{className:"".concat(n)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,s.jsx)(z.u,{className:"".concat(n)}):a.includes("diagram")?(0,s.jsx)(P.j,{className:"".concat(n)}):a.includes("paint")?(0,s.jsx)(G.Y,{className:"".concat(n)}):(0,s.jsx)(A.a,{className:"".concat(n)})}(t?t[1]:"",e.primary?(0,K.oz)(e.agentColor):"text-gray-500"),n=R().sanitize(et.render(e.message));return(0,s.jsxs)("div",{className:"".concat(l().trainOfThoughtElement," break-all items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(l().trainOfThought," ").concat(e.primary?l().primary:""),children:[a,(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}et.use(c(),{inline:!0,code:!0});let el=(0,i.forwardRef)((e,t)=>{var a,n;let r,o,c,h,u;let[m,g]=(0,i.useState)(!1),[p,f]=(0,i.useState)(!1),[x,j]=(0,i.useState)(""),[w,b]=(0,i.useState)(""),[y,N]=(0,i.useState)(!1),[k,C]=(0,i.useState)(!1),[M,_]=(0,i.useState)(""),v=(0,i.useRef)(!1),E=(0,i.useRef)(null);async function T(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;N(!0);let a=D(t[0]);for(let e=0;e<t.length&&!v.current;e++){let s=a;e<t.length-1&&(a=D(t[e+1]));try{let e=await s,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let s=new Audio(e);s.onended=t,s.onerror=a,s.play()})}(t)}catch(e){console.error("Error:",e);break}}N(!1),C(!1)}async function D(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}(0,i.useEffect)(()=>{v.current=k},[k]),(0,i.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(E.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]})});return E.current&&e.observe(E.current,{childList:!0}),()=>e.disconnect()},[E.current]),(0,i.useEffect)(()=>{let t=e.chatMessage.message;if(e.chatMessage.intent&&"excalidraw"==e.chatMessage.intent.type&&(t=e.chatMessage.intent["inferred-queries"][0],_(e.chatMessage.message)),t=t.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET"),e.chatMessage.images&&e.chatMessage.images.length>0){let a=e.chatMessage.images.map((e,t)=>{let a=e.startsWith("data%3Aimage")?decodeURIComponent(e):e,s=R().sanitize(a);return'<div class="'.concat(l().imageWrapper,'"><img src="').concat(s,'" alt="uploaded image ').concat(t+1,'" /></div>')}).join("");t='<div class="'.concat(l().imagesContainer,'">').concat(a,"</div>").concat(t)}let a={"text-to-image":e=>""),"text-to-image2":e=>""),"text-to-image-v3":e=>""),excalidraw:e=>e};if(e.chatMessage.intent){let{type:s,"inferred-queries":n}=e.chatMessage.intent;console.log("intent type",s),s in a&&(t=a[s](t)),s.includes("text-to-image")&&(null==n?void 0:n.length)>0&&(t+="\n\n".concat(n[0]))}j(t);let s=et.render(t);s=s.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),b(R().sanitize(s))},[e.chatMessage.message,e.chatMessage.images,e.chatMessage.intent]),(0,i.useEffect)(()=>{m&&setTimeout(()=>{g(!1)},2e3)},[m]),(0,i.useEffect)(()=>{E.current&&(E.current.querySelectorAll("pre > .hljs").forEach(e=>{if(!e.querySelector("".concat(l().codeCopyButton))){let t=document.createElement("button"),a=(0,s.jsx)(U.w,{size:24});(0,d.createRoot)(t).render(a),t.className="hljs ".concat(l().codeCopyButton),t.addEventListener("click",()=>{let a=e.textContent||"";a=(a=(a=a.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(a);let n=(0,s.jsx)(I.J,{size:24});(0,d.createRoot)(t).render(n)}),e.prepend(t)}}),(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]}))},[w,p,E]);let L=function(e,t){let a=[],s=[];if(t){let e=[];for(let[a,s]of Object.entries(t)){if(s.answerBox&&e.push({title:s.answerBox.title,description:s.answerBox.answer,link:s.answerBox.source}),s.knowledgeGraph&&e.push({title:s.knowledgeGraph.title,description:s.knowledgeGraph.description,link:s.knowledgeGraph.descriptionLink}),s.webpages){if(s.webpages instanceof Array){let t=s.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=s.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(s.organic){let t=s.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}a.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:a}}(e.chatMessage.context,e.chatMessage.onlineContext);return(0,s.jsxs)("div",{ref:t,className:(a=e.chatMessage,(r=[l().chatMessageContainer,"shadow-md"]).push(l()[a.by]),a.message||r.push(l().emptyChatMessage),e.customClassName&&r.push(l()["".concat(a.by).concat(e.customClassName)]),r.join(" ")),onMouseLeave:e=>f(!1),onMouseEnter:e=>f(!0),children:[(0,s.jsxs)("div",{className:(n=e.chatMessage,(o=[l().chatMessageWrapper]).push(l()[n.by]),"khoj"===n.by&&o.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),o.join(" ")),children:[(0,s.jsx)("div",{ref:E,className:l().chatMessage,dangerouslySetInnerHTML:{__html:w}}),M&&(0,s.jsx)(ee,{data:M})]}),(0,s.jsx)("div",{className:l().teaserReferencesContainer,children:(0,s.jsx)(S,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:L.notesReferenceCardData,onlineReferenceCardData:L.onlineReferenceCardData})}),(0,s.jsx)("div",{className:l().chatFooter,children:(p||e.isMobileWidth||e.isLastMessage||y)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{title:(h=(c=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),u=c.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(h," on ").concat(u)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,s.jsxs)("div",{className:"".concat(l().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(y?k?(0,s.jsx)(Y.l,{iconClassName:"p-0",className:"m-0"}):(0,s.jsx)("button",{title:"Pause Speech",onClick:e=>C(!0),children:(0,s.jsx)(V.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,s.jsx)("button",{title:"Speak",onClick:e=>T(),children:(0,s.jsx)($.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),(0,s.jsx)("button",{title:"Copy",className:"".concat(l().copyButton),onClick:()=>{navigator.clipboard.writeText(x),g(!0)},children:m?(0,s.jsx)(J.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,s.jsx)(J.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,s.jsx)(es,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,s.jsx)(es,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})});el.displayName="ChatMessage";var er=el},34531:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",emptyChatMessage:"chatMessage_emptyChatMessage__J9JRn",imagesContainer:"chatMessage_imagesContainer__HTRjT",imageWrapper:"chatMessage_imageWrapper__DF92M",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}}}]);
|