khoj 1.27.2.dev130__py3-none-any.whl → 1.27.2.dev167__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 (54) hide show
  1. khoj/configure.py +1 -1
  2. khoj/database/adapters/__init__.py +16 -2
  3. khoj/interface/compiled/404/index.html +1 -1
  4. khoj/interface/compiled/_next/static/chunks/1467-b331e469fe411347.js +1 -0
  5. khoj/interface/compiled/_next/static/chunks/1603-c1568f45947e9f2c.js +1 -0
  6. khoj/interface/compiled/_next/static/chunks/3423-ff7402ae1dd66592.js +1 -0
  7. khoj/interface/compiled/_next/static/chunks/8423-e80647edf6c92c27.js +1 -0
  8. khoj/interface/compiled/_next/static/chunks/app/chat/page-bfc70b16ba5e51b4.js +1 -0
  9. khoj/interface/compiled/_next/static/chunks/app/factchecker/page-340bcf53abf6a2cc.js +1 -0
  10. khoj/interface/compiled/_next/static/chunks/{webpack-8ae5ce45161bd98e.js → webpack-878569182b3af4c6.js} +1 -1
  11. khoj/interface/compiled/_next/static/css/{e9c5fe555dd3050b.css → a795ee88875f4853.css} +1 -1
  12. khoj/interface/compiled/_next/static/css/{b70402177a7c3207.css → d738728883c68af8.css} +1 -1
  13. khoj/interface/compiled/agents/index.html +1 -1
  14. khoj/interface/compiled/agents/index.txt +2 -2
  15. khoj/interface/compiled/automations/index.html +1 -1
  16. khoj/interface/compiled/automations/index.txt +2 -2
  17. khoj/interface/compiled/chat/index.html +1 -1
  18. khoj/interface/compiled/chat/index.txt +2 -2
  19. khoj/interface/compiled/factchecker/index.html +1 -1
  20. khoj/interface/compiled/factchecker/index.txt +2 -2
  21. khoj/interface/compiled/index.html +1 -1
  22. khoj/interface/compiled/index.txt +2 -2
  23. khoj/interface/compiled/search/index.html +1 -1
  24. khoj/interface/compiled/search/index.txt +2 -2
  25. khoj/interface/compiled/settings/index.html +1 -1
  26. khoj/interface/compiled/settings/index.txt +2 -2
  27. khoj/interface/compiled/share/chat/index.html +1 -1
  28. khoj/interface/compiled/share/chat/index.txt +2 -2
  29. khoj/processor/conversation/offline/chat_model.py +8 -1
  30. khoj/processor/conversation/openai/utils.py +7 -0
  31. khoj/processor/conversation/prompts.py +36 -38
  32. khoj/processor/conversation/utils.py +15 -8
  33. khoj/processor/embeddings.py +4 -4
  34. khoj/processor/tools/online_search.py +8 -4
  35. khoj/routers/api_chat.py +38 -25
  36. khoj/routers/helpers.py +16 -1
  37. khoj/routers/research.py +17 -18
  38. khoj/utils/helpers.py +12 -3
  39. {khoj-1.27.2.dev130.dist-info → khoj-1.27.2.dev167.dist-info}/METADATA +2 -2
  40. {khoj-1.27.2.dev130.dist-info → khoj-1.27.2.dev167.dist-info}/RECORD +48 -48
  41. khoj/interface/compiled/_next/static/chunks/1467-5a191c1cd5bf0b83.js +0 -1
  42. khoj/interface/compiled/_next/static/chunks/1603-5d70d9dfcdcb1f10.js +0 -1
  43. khoj/interface/compiled/_next/static/chunks/3423-fa918f4e5365a35e.js +0 -1
  44. khoj/interface/compiled/_next/static/chunks/8423-3ad0bfb299801220.js +0 -1
  45. khoj/interface/compiled/_next/static/chunks/app/chat/page-7dc98df9c88828f0.js +0 -1
  46. khoj/interface/compiled/_next/static/chunks/app/factchecker/page-d887f55fe6d4f35d.js +0 -1
  47. /khoj/interface/compiled/_next/static/chunks/{1970-444843bea1d17d61.js → 1970-90dd510762d820ba.js} +0 -0
  48. /khoj/interface/compiled/_next/static/chunks/{9417-19cfd1a9cb758e71.js → 9417-951f46451a8dd6d7.js} +0 -0
  49. /khoj/interface/compiled/_next/static/chunks/app/{page-d46244282af16509.js → page-f249666a0cbdaa0d.js} +0 -0
  50. /khoj/interface/compiled/_next/static/{N19uqHAJYqRAVxvuVwHfE → vUFFjGuewOr_h39o6kbfT}/_buildManifest.js +0 -0
  51. /khoj/interface/compiled/_next/static/{N19uqHAJYqRAVxvuVwHfE → vUFFjGuewOr_h39o6kbfT}/_ssgManifest.js +0 -0
  52. {khoj-1.27.2.dev130.dist-info → khoj-1.27.2.dev167.dist-info}/WHEEL +0 -0
  53. {khoj-1.27.2.dev130.dist-info → khoj-1.27.2.dev167.dist-info}/entry_points.txt +0 -0
  54. {khoj-1.27.2.dev130.dist-info → khoj-1.27.2.dev167.dist-info}/licenses/LICENSE +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6894],{71884:function(e,t,n){Promise.resolve().then(n.bind(n,69769))},18642:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var i=n(57437),a=n(90837),r=n(50495),o=n(83102),s=n(67135),l=n(34797);function c(e){var t;return(0,i.jsxs)(a.Vq,{children:[(0,i.jsx)(a.hg,{asChild:!0,onClick:e.onShare,children:(0,i.jsxs)(r.z,{size:"sm",className:"".concat(e.buttonClassName||"px-3"),variant:null!==(t=e.buttonVariant)&&void 0!==t?t:"default",children:[e.includeIcon&&(0,i.jsx)(l.m,{className:"w-4 h-4 mr-2"}),e.buttonTitle]})}),(0,i.jsxs)(a.cZ,{children:[(0,i.jsxs)(a.fK,{children:[(0,i.jsx)(a.$N,{children:e.title}),(0,i.jsx)(a.Be,{children:e.description})]}),(0,i.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,i.jsxs)("div",{className:"grid flex-1 gap-2",children:[(0,i.jsx)(s._,{htmlFor:"link",className:"sr-only",children:"Link"}),(0,i.jsx)(o.I,{id:"link",defaultValue:e.url,readOnly:!0})]}),(0,i.jsx)(r.z,{type:"submit",size:"sm",className:"px-3",onClick:()=>(function(e){let t=navigator.clipboard;t&&t.writeText(e)})(e.url),children:(0,i.jsx)("span",{children:"Copy"})})]})]})]})}},69769:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return E}});var i=n(57437),a=n(34209),r=n.n(a),o=n(79306),s=n(2265),l=n(53423),c=n(29039),d=n(6780),f=n(53907),h=n.n(f);let u=async e=>(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}})).json(),m=e=>{let{data:t,error:n}=(0,c.ZP)(e,u);return{data:t,isLoading:!n&&!t,isError:n}},p=async e=>(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}})).json(),x=e=>{let{data:t,error:n}=(0,c.ZP)(e,p);return{data:t,isLoading:!n&&!t,isError:n}},k=e=>{let{data:t}=m("/api/model/chat/options"),{data:n}=x("/api/model/chat"),[a,r]=s.useState(!1),l=(0,o.GW)(),c=e.setModelUsed;return((0,s.useEffect)(()=>{c&&n&&c(n)},[n,c]),t)?(0,i.jsxs)("div",{className:h().modelPicker,children:[(0,i.jsx)("select",{className:h().modelPicker,onChange:n=>{let i=Number(n.target.value),a=t.find(e=>e.id===i);a?function(t){if(!l){r(!0);return}e.setModelUsed&&e.setModelUsed(t),fetch("/api/model/chat?id="+String(t.id),{method:"POST",body:JSON.stringify(t)}).then(e=>{if(!e.ok)throw Error("Failed to select model")}).catch(e=>{console.error("Failed to select model",e)})}(a):console.error("Selected model not found",n.target.value)},disabled:e.disabled,children:null==t?void 0:t.map(t=>(0,i.jsx)("option",{value:t.id,selected:e.initialModel?t.id===e.initialModel.id:(null==n?void 0:n.id)===t.id,children:t.chat_model},t.id))}),(0,i.jsx)(d.aR,{open:a,onOpenChange:r,children:(0,i.jsxs)(d._T,{children:[(0,i.jsxs)(d.fY,{children:[(0,i.jsx)(d.f$,{children:"You must be logged in to configure your model."}),(0,i.jsxs)(d.yT,{children:["Once you create an account with Khoj, you can configure your model and use a whole suite of other features. Check out our"," ",(0,i.jsx)("a",{href:"https://docs.khoj.dev/",children:"documentation"})," to learn more."]})]}),(0,i.jsxs)(d.xo,{children:[(0,i.jsx)(d.le,{children:"Cancel"}),(0,i.jsx)(d.OL,{onClick:()=>{window.location.href=window.location.origin+"/login"},children:"Sign in"})]})]})})]}):(0,i.jsx)("div",{children:"Loading..."})};var j=n(18642),v=n(83102),b=n(50495),g=n(36013),y=n(87138),C=n(48861),_=n(69591);let w=()=>(0,i.jsx)("div",{className:r().loading,children:(0,i.jsxs)("div",{className:r().loadingVerification,children:["Researching...",(0,i.jsxs)("div",{className:r().spinner,children:[(0,i.jsx)("div",{className:"".concat(r().dot1," bg-blue-300")}),(0,i.jsx)("div",{className:"".concat(r().dot2," bg-blue-300")})]})]})});async function N(e,t,n,i,a){n(!0);let r="".concat("Limit your search to reputable sources. Search the internet for relevant supporting or refuting information. Do not reference my notes. Refuse to answer any queries that are not falsifiable by informing me that you will not answer the question. You're not permitted to ask follow-up questions, so do the best with what you have. Respond with **TRUE** or **FALSE** or **INCONCLUSIVE**, then provide your justification. Fact Check:"," ").concat(e);try{var o;let e=await fetch("".concat("/api/chat","?client=web"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:r,conversation_id:t,stream:!0})});if(!e.body)throw Error("No response body found");let n=null===(o=e.body)||void 0===o?void 0:o.getReader(),s=new TextDecoder,l="";for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=s.decode(t,{stream:!0});if(r.includes("### compiled references:")){let e=function(e,t){let n=e.split("### compiled references:")[1],i=e.split("### compiled references:")[0],a={};a.response=t+i;let r=JSON.parse(n);return r instanceof Array?a.context=r:"object"==typeof r&&null!==r&&(a.online=r),a}(r,l);e.response&&(l=e.response,i(e.response),a(e))}else l+=r,i(l)}}catch(e){console.error("Error verifying statement: ",e)}finally{n(!1)}}async function S(e){let t=await fetch("/api/chat/sessions?client=web",{method:"POST"});e((await t.json()).conversation_id)}function T(e){let[t,n]=(0,s.useState)(""),[a,r]=(0,s.useState)(!0),o="".concat(e.message,". Use this link for reference: ").concat(e.additionalLink),c=(0,_.IC)();return(0,s.useEffect)(()=>{e.prefilledResponse?(n(e.prefilledResponse),r(!1)):N(o,e.conversationId,r,n,()=>{})},[o,e.conversationId,e.prefilledResponse]),(0,s.useEffect)(()=>{""!==t&&(e.prefilledResponse||a||e.setChildReferencesCallback(e.additionalLink,t,e.linkTitle))},[t,a,e]),(0,i.jsxs)("div",{children:[a&&(0,i.jsx)(w,{}),(0,i.jsx)(l.Z,{chatMessage:{automationId:"",by:"AI",message:t,context:[],created:new Date().toISOString(),onlineContext:{},codeContext:{}},isMobileWidth:c})]})}function I(e){var t,n,a;let o=e.linkTitle||(null===(a=e.onlineData)||void 0===a?void 0:null===(n=a.organic)||void 0===n?void 0:null===(t=n[0])||void 0===t?void 0:t.title)||"Reference",s={link:e.additionalLink};return(0,i.jsxs)(g.Zb,{className:"mt-2 mb-4",children:[(0,i.jsxs)(g.Ol,{children:[(0,i.jsx)("a",{className:r().titleLink,href:e.additionalLink,target:"_blank",rel:"noreferrer",children:o}),(0,i.jsx)(L,{...s})]}),(0,i.jsx)(g.aY,{children:(0,i.jsx)(T,{additionalLink:e.additionalLink,message:e.officialFactToVerify,linkTitle:o,conversationId:e.conversationId,setChildReferencesCallback:e.setChildReferencesCallback,prefilledResponse:e.prefilledResponse})})]})}let L=e=>{let t=new URL(e.link).hostname;return(0,i.jsx)("div",{className:r().subLinks,children:(0,i.jsx)("a",{className:"".concat(r().subLinks," bg-blue-200 px-2"),href:e.link,target:"_blank",rel:"noreferrer",children:t})})};function E(){let[e,t]=(0,s.useState)(""),[n,a]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1),[f,h]=(0,s.useState)(""),[u,m]=(0,s.useState)(!1),[p,x]=(0,s.useState)(),[T,E]=(0,s.useState)(),[R,F]=(0,s.useState)(),O=(0,_.IC)(),[A,P]=(0,s.useState)(""),[V,M]=(0,s.useState)(""),[U,D]=(0,s.useState)(!1),[q,Z]=(0,s.useState)();function B(e,t,n){let i=T||[];i.find(t=>t.additionalLink===e)||(i.push({additionalLink:e,response:t,linkTitle:n}),E(i))}let z=(0,o.GW)();function W(){if(u)return;if(!e){alert("Please enter a fact to verify.");return}if(m(!0),!z){let e=window.location.href;window.location.href="/login?next=".concat(e)}x(void 0),h(""),S(P);let t=[...Array(16)].map(()=>Math.random().toString(36)[2]).join("");M(t),window.history.pushState({},document.title,window.location.pathname+"?runId=".concat(t)),a(e),m(!1)}(0,s.useEffect)(()=>{e?document.title="AI Fact Check: ".concat(e):document.title="AI Fact Checker"},[e]),(0,s.useEffect)(()=>{let e=localStorage.getItem("factToVerify");e&&t(e);let n=new URLSearchParams(window.location.search),i=n.get("factToVerify");i&&t(i);let r=n.get("runId");r&&(M(r),(async()=>{try{let e=await fetch("/api/chat/store/factchecker?runId=".concat(r));if(200!==e.status)throw Error("Failed to fetch stored data");let t=JSON.parse(await e.json());t&&(a(t.factToVerify),h(t.response),x(t.references),E(t.childReferences),Z(t.modelUsed)),D(!0)}catch(e){console.error("Error fetching stored data: ",e)}})())},[]),(0,s.useEffect)(()=>{A&&N(n,A,d,h,x)},[A,n]),(0,s.useEffect)(()=>{localStorage.setItem("factToVerify",e)},[e]),(0,s.useEffect)(()=>{let e=document.querySelector('meta[name="description"]');e&&e.setAttribute("content",f);let t=document.querySelector('meta[property="og:description"]');t||((t=document.createElement("meta")).setAttribute("property","og:description"),document.getElementsByTagName("head")[0].appendChild(t)),t.setAttribute("content",f)},[f]);let J=e=>e.map((e,t)=>(0,i.jsx)(I,{additionalLink:e.additionalLink,officialFactToVerify:n,conversationId:A,linkTitle:e.linkTitle,setChildReferencesCallback:B,prefilledResponse:e.response},t)),Y=e=>e instanceof Array?e.map((e,t)=>L(e)):L(e);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"relative md:fixed h-full",children:(0,i.jsx)(C.ZP,{conversationId:null,uploadedFiles:[],isMobileWidth:O})}),(0,i.jsxs)("div",{className:r().factCheckerContainer,children:[(0,i.jsx)("h1",{className:"".concat(r().response," pt-8 md:pt-4 font-large outline-slate-800 dark:outline-slate-200"),children:"AI Fact Checker"}),(0,i.jsx)("footer",{className:"".concat(r().footer," mt-4"),children:"This is an experimental AI tool. It may make mistakes."}),f&&p&&T?(0,i.jsxs)("div",{className:r().reportActions,children:[(0,i.jsx)(b.z,{asChild:!0,variant:"secondary",children:(0,i.jsx)(y.default,{href:"/factchecker",target:"_blank",rel:"noopener noreferrer",children:"Try Another"})}),(0,i.jsx)(j.Z,{buttonTitle:"Share report",title:"AI Fact Checking Report",description:"Share this fact checking report with others. Anyone who has this link will be able to view the report.",url:function(){let e=new URL(window.location.href);return e.searchParams.set("runId",V),e.href}(),onShare:U?()=>{}:function(){fetch("/api/chat/store/factchecker",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runId:V,storeData:{factToVerify:e,response:f,references:p,childReferences:T,runId:V,modelUsed:R}})})}})]}):(0,i.jsxs)("div",{className:r().newReportActions,children:[(0,i.jsxs)("div",{className:"".concat(r().inputFields," mt-4"),children:[(0,i.jsx)(v.I,{type:"text",maxLength:200,placeholder:"Enter a falsifiable statement to verify",disabled:c,onChange:e=>t(e.target.value),value:e,onKeyDown:e=>{"Enter"===e.key&&W()},onFocus:e=>e.target.placeholder="",onBlur:e=>e.target.placeholder="Enter a falsifiable statement to verify"}),(0,i.jsx)(b.z,{disabled:u,onClick:()=>W(),children:"Verify"})]}),(0,i.jsxs)("h3",{className:"mt-4 mb-4",children:["Try with a particular model. You must be"," ",(0,i.jsx)("a",{href:"/settings",className:"font-medium text-blue-600 dark:text-blue-500 hover:underline",children:"subscribed"})," ","to configure the model."]})]}),(0,i.jsx)(k,{disabled:c||U,setModelUsed:F,initialModel:q}),c&&(0,i.jsx)("div",{className:r().loading,children:(0,i.jsx)(w,{})}),f&&(0,i.jsxs)(g.Zb,{className:"mt-4",children:[(0,i.jsx)(g.Ol,{children:(0,i.jsx)(g.ll,{children:n})}),(0,i.jsx)(g.aY,{children:(0,i.jsx)("div",{className:r().responseText,children:(0,i.jsx)(l.Z,{chatMessage:{automationId:"",by:"AI",message:f,context:[],created:new Date().toISOString(),onlineContext:{},codeContext:{}},isMobileWidth:O})})}),(0,i.jsx)(g.eW,{children:p&&p.online&&Object.keys(p.online).length>0&&(0,i.jsx)("div",{className:r().subLinks,children:Object.entries(p.online).map((e,t)=>{let[n,i]=e;return Y((null==i?void 0:i.webpages)||[])})})})]}),p&&(0,i.jsxs)("div",{className:r().referenceContainer,children:[(0,i.jsx)("h2",{className:"mt-4 mb-4",children:"Supplements"}),(0,i.jsx)("div",{className:r().references,children:void 0!==p.online&&((e,t,n,a,r)=>{if(a&&r)return J(r);let o=new Set;return Object.entries(t.online||{}).map((e,t)=>{let[n,i]=e,a=(null==i?void 0:i.webpages)||[];if(a instanceof Array)for(let e=0;e<a.length;e++){let t=a[e].link||"";if(o.has(t))return null;o.add(t)}else{let e=a.link||"";if(o.has(e))return null;o.add(e)}}),Object.entries(t.online||{}).map((t,a)=>{var r,s;let[l,c]=t,d="";for(let e=0;e<(null==c?void 0:null===(r=c.organic)||void 0===r?void 0:r.length)&&(d=(null==c?void 0:null===(s=c.organic)||void 0===s?void 0:s[e]).link||"",o.has(d));e++);return(o.add(d),""===d)?null:(0,i.jsx)(I,{onlineData:c,officialFactToVerify:n,conversationId:e,additionalLink:d,setChildReferencesCallback:B},a)}).filter(Boolean)})(A,p,n,U,T)})]})]})]})}},67135:function(e,t,n){"use strict";n.d(t,{_:function(){return c}});var i=n(57437),a=n(2265),r=n(38364),o=n(12218),s=n(37440);let l=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,i.jsx)(r.f,{ref:t,className:(0,s.cn)(l(),n),...a})});c.displayName=r.f.displayName},53907:function(e){e.exports={modelPicker:"modelPicker_modelPicker__chlCh"}},34209:function(e){e.exports={factVerification:"factChecker_factVerification__UCbIf",factCheckerContainer:"factChecker_factCheckerContainer__Brqjv",responseText:"factChecker_responseText__HzSck",response:"factChecker_response__HaFuc",titleLink:"factChecker_titleLink__FA5mt",subLinks:"factChecker_subLinks__iaFHn",reference:"factChecker_reference___6Fwh",footer:"factChecker_footer__Tbj3t",reportActions:"factChecker_reportActions__2_tFq",factCheckButton:"factChecker_factCheckButton__2XPTv",spinner:"factChecker_spinner__T26Jv","sk-rotate":"factChecker_sk-rotate__ogES_",inputFields:"factChecker_inputFields__LU3cQ",dot1:"factChecker_dot1__n9Bu5",dot2:"factChecker_dot2__HDdBs","sk-bounce":"factChecker_sk-bounce__q4XFt"}},38364:function(e,t,n){"use strict";n.d(t,{f:function(){return s}});var i=n(2265),a=n(25171),r=n(57437),o=i.forwardRef((e,t)=>(0,r.jsx)(a.WV.label,{...e,ref:t,onMouseDown:t=>{var n;t.target.closest("button, input, select, textarea")||(null===(n=e.onMouseDown)||void 0===n||n.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));o.displayName="Label";var s=o}},function(e){e.O(0,[6129,9448,929,3954,9001,3062,8840,7113,394,1603,9417,3423,2971,7023,1744],function(){return e(e.s=71884)}),_N_E=e.O()}]);