@pickaxeproject/react 2.6.1 → 2.7.1
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.
- package/dist/cjs/components/Pickaxe/Addons/Document/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Document.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/hooks/pickaxe/useSubmit.js +1 -1
- package/dist/cjs/hooks/pickaxe/useSubmitDocument.js +1 -1
- package/dist/cjs/src/components/Pickaxe/Addons/Document/Provider.d.ts +2 -1
- package/dist/cjs/src/components/Pickaxe/Addons/Document/hooks/useDocument.d.ts +3 -3
- package/dist/cjs/src/components/Pickaxe/Addons/Document/hooks/useDocumentContext.d.ts +2 -1
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +2 -0
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +2 -0
- package/dist/cjs/src/hooks/pickaxe/useSubmit.d.ts +1 -1
- package/dist/cjs/src/hooks/pickaxe/useSubmitDocument.d.ts +2 -1
- package/dist/esm/components/Pickaxe/Addons/Document/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Document.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/hooks/pickaxe/useSubmit.js +1 -1
- package/dist/esm/hooks/pickaxe/useSubmitDocument.js +1 -1
- package/dist/esm/src/components/Pickaxe/Addons/Document/Provider.d.ts +2 -1
- package/dist/esm/src/components/Pickaxe/Addons/Document/hooks/useDocument.d.ts +3 -3
- package/dist/esm/src/components/Pickaxe/Addons/Document/hooks/useDocumentContext.d.ts +2 -1
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +2 -0
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +2 -0
- package/dist/esm/src/hooks/pickaxe/useSubmit.d.ts +1 -1
- package/dist/esm/src/hooks/pickaxe/useSubmitDocument.d.ts +2 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const s=t.createContext({});exports.DocumentContext=s,exports.default=({children:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const s=t.createContext({});exports.DocumentContext=s,exports.default=({children:o})=>{const[r,n]=t.useState([]),[i,u]=t.useState(""),[c,a]=t.useState(""),[d,l]=t.useState(!1),[m,g]=t.useState(!1);return e.jsx(s.Provider,Object.assign({value:{documents:r,documentCount:r.length,documentError:i,websiteLink:c,isUploading:d,isShowList:m,editDocument:e=>{n((t=>t.map((t=>t.id===e.id?Object.assign(Object.assign({},t),e):t))))},setDocuments:n,addDocument:e=>{n((t=>[...t,e]))},removeDocument:e=>{console.log(e),n((t=>t.filter((t=>t.id!==e))))},setDocumentError:u,setWebsiteLink:a,setIsUploading:l,setIsShowList:g}},{children:o}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js"),a=require("uuid");const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"];exports.useDocument=({onQuestionChange:d}={})=>{const{formId:l,chatId:c,sessionId:m,pickaxe:p}=s.usePickaxeContext(),f=o.useDocumentContext(),w=i.useSubmitDocument(),g=t.useMemo((()=>{var e;return u.includes(null!==(e=null==p?void 0:p.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[p]),I=e=>{const t=[...n.allowedFileMimeTypes,...g?n.allowedImageMimeTypes:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(g?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=r.default(e);return f.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},f),{isImageUploadAllowed:g,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(f.setDocumentError(""),!t.length)return null;if(I(t))return null;f.setIsUploading(!0),f.setIsShowList(!0);const s=t.map((e=>({file:e,id:a.v4()})));s.forEach((({file:e,id:t})=>{f.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,error:o}=yield w.document(Object.assign({formId:l,responseId:c,file:t,sessionId:m},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid}));if(!e)throw new Error(null!=o?o:"Document processing failed");null==d||d({input:t.name,documentId:i});const n=i.startsWith("IMAGE-");return f.editDocument({id:s,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i}),{name:t.name,documentId:i}}catch(e){const i=r.default(e);return f.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}})))),o=yield Promise.allSettled(i),n=new Set;for(const e of o)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&f.setDocumentError([...n].join(", ")),f.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){f.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");f.setIsUploading(!0),f.setIsShowList(!0),f.setWebsiteLink(""),f.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:l,responseId:c,website:e},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid})),{success:s,documentId:i}=t;if(!s)throw new Error("Website processing failed, please try again.");f.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=r.default(t);if(console.log("[onWebsiteUpload] Error",s),s.includes("Please paste a valid website URL"))return f.setDocumentError(s),null;f.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{f.setIsUploading(!1)}}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeMarkdown/Renderer.js"),c=require("../../common/PickaxeIcon.js"),r=require("./Document.js"),n=require("../../common/PickaxeCopyButton.js"),o=require("../../../../common/cn.js");exports.default=({index:d,message:x,isIntroExpand:u})=>{var m,j;const{formId:p,pickaxe:h,styles:f,colors:b,misc:g,responsiveBy:v,disableHtml:k,disableJs:w,disableCss:y,isNewChat:N,isRtl:O}=t.usePickaxeContext(),C=a.useStyleFontSize(),P=null!==(m=null==h?void 0:h.chaticon)&&void 0!==m?m:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${p}.png`;return"assistant"===x.role?e.jsx("div",Object.assign({className:o.default("flex w-full",O?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:o.default("flex flex-col",0===d&&N&&"viewport"===v&&"min-[767px]:max-w-[80%]",0===d&&N&&"container"===v&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:o.default("flex gap-x-3",O&&"flex-row-reverse")},{children:[g.isChatImage&&"NONE"!==P&&e.jsx(c.default,{src:P,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:b.text}),e.jsxs("div",Object.assign({className:o.default("flex flex-col",O?"items-end":"items-start")},{children:[e.jsx("div",Object.assign({className:o.default(C.b2,"chat-message pt-3",O?"text-right":"text-left")},{children:e.jsx(i.PickaxeMarkdown,Object.assign({theme:f.theme,accentColor:b.accent,actions:!0},O&&{rtl:!0},k&&{disableHtml:!0},w&&{disableJs:!0},y&&{disableCss:!0},{children:e.jsx(l.PickaxeMarkdownRenderer,Object.assign({value:x.content},0===d&&N&&x.content.length>470&&3===(null!==(j=null==h?void 0:h.icebreakers)&&void 0!==j?j:[]).length&&!x.content.includes("https://utils.pickaxe.co/api/fn")&&{maxLines:u?void 0:12}))}))})),e.jsx("div",Object.assign({className:"mt-4 flex gap-3"},{children:e.jsx(n.default,{color:b.accent,text:x.content})}))]}))]}))}))})):"user"===x.role?e.jsx("div",Object.assign({className:o.default("flex w-full",O?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:o.default("flex gap-x-3 max-w-[80%]",O?"pr-9":"pl-9","viewport"===v?O?"min-[767px]:pr-0":"min-[767px]:pl-0":O?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:o.default(C.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",O?"text-right":"text-left"),style:{backgroundColor:b.secondary+"80",color:b.secondaryText,borderRadius:f.cornerRadius}},{children:[x.documentIds&&x.documentIds.length>0&&e.jsx("div",Object.assign({className:o.default("flex flex-col",O?"items-start":"items-end")},{children:x.documentIds.map((t=>e.jsx(s.Fragment,{children:t.startsWith("IMAGE-")?e.jsx("div",Object.assign({className:"max-w-[300px]"},{children:e.jsx("img",{style:{borderRadius:f.cornerRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${t.split("-")[2]}/${t.split("-")[1]}.${null==t?void 0:t.split("-")[2]}`,alt:""})})):e.jsx(r.default,{documentId:t})},t)))})),e.jsx(i.PickaxeMarkdown,Object.assign({theme:f.theme,accentColor:b.accent},O&&{rtl:!0},k&&{disableHtml:!0},w&&{disableJs:!0},y&&{disableCss:!0},{children:e.jsx(l.PickaxeMarkdownRenderer,{value:x.content})}))]}))}))})):e.jsx("div",{})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeMarkdown/Renderer.js"),c=require("../../common/PickaxeIcon.js"),r=require("./Document.js"),n=require("../../common/PickaxeCopyButton.js"),o=require("../../../../common/cn.js");exports.default=({index:d,message:x,isIntroExpand:u})=>{var m,j;const{formId:p,pickaxe:h,styles:f,colors:b,misc:g,responsiveBy:v,disableHtml:k,disableJs:w,disableCss:y,isNewChat:N,isRtl:O}=t.usePickaxeContext(),C=a.useStyleFontSize(),P=null!==(m=null==h?void 0:h.chaticon)&&void 0!==m?m:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${p}.png`;return"assistant"===x.role?e.jsx("div",Object.assign({className:o.default("flex w-full",O?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:o.default("flex flex-col",0===d&&N&&"viewport"===v&&"min-[767px]:max-w-[80%]",0===d&&N&&"container"===v&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:o.default("flex gap-x-3",O&&"flex-row-reverse")},{children:[g.isChatImage&&"NONE"!==P&&e.jsx(c.default,{src:P,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:b.text}),e.jsxs("div",Object.assign({className:o.default("flex flex-col",O?"items-end":"items-start")},{children:[e.jsx("div",Object.assign({className:o.default(C.b2,"chat-message pt-3",O?"text-right":"text-left")},{children:e.jsx(i.PickaxeMarkdown,Object.assign({theme:f.theme,accentColor:b.accent,actions:!0},O&&{rtl:!0},k&&{disableHtml:!0},w&&{disableJs:!0},y&&{disableCss:!0},{children:e.jsx(l.PickaxeMarkdownRenderer,Object.assign({value:x.content},0===d&&N&&x.content.length>470&&3===(null!==(j=null==h?void 0:h.icebreakers)&&void 0!==j?j:[]).length&&!x.content.includes("https://utils.pickaxe.co/api/fn")&&{maxLines:u?void 0:12}))}))})),e.jsx("div",Object.assign({className:"mt-4 flex gap-3"},{children:e.jsx(n.default,{color:b.accent,text:x.content})}))]}))]}))}))})):"user"===x.role?e.jsx("div",Object.assign({className:o.default("flex w-full",O?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:o.default("flex gap-x-3 max-w-[80%]",O?"pr-9":"pl-9","viewport"===v?O?"min-[767px]:pr-0":"min-[767px]:pl-0":O?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:o.default(C.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",O?"text-right":"text-left"),style:{backgroundColor:b.secondary+"80",color:b.secondaryText,borderRadius:f.cornerRadius}},{children:[x.documentIds&&x.documentIds.length>0&&e.jsx("div",Object.assign({className:o.default("flex flex-col gap-y-2",O?"items-start":"items-end")},{children:x.documentIds.map((t=>e.jsx(s.Fragment,{children:t.startsWith("IMAGE-")?e.jsx("div",Object.assign({className:"max-w-[300px]"},{children:e.jsx("img",{style:{borderRadius:f.cornerRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${t.split("-")[2]}/${t.split("-")[1]}.${null==t?void 0:t.split("-")[2]}`,alt:""})})):e.jsx(r.default,{documentId:t})},t)))})),e.jsx(i.PickaxeMarkdown,Object.assign({theme:f.theme,accentColor:b.accent},O&&{rtl:!0},k&&{disableHtml:!0},w&&{disableJs:!0},y&&{disableCss:!0},{children:e.jsx(l.PickaxeMarkdownRenderer,{value:x.content})}))]}))}))})):e.jsx("div",{})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../hooks/pickaxe/useConversation.js"),n=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../Addons/Document/hooks/useDocument.js"),c=require("../Addons/Scroll/hooks/useScroll.js"),u=require("../../../hooks/core/useHover.js"),m=require("../../../common/utils.js"),f=require("../../../common/documents.js"),x=require("eventsource-parser"),p=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),g=require("../../Icons/file.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../hooks/pickaxe/useConversation.js"),n=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../Addons/Document/hooks/useDocument.js"),c=require("../Addons/Scroll/hooks/useScroll.js"),u=require("../../../hooks/core/useHover.js"),m=require("../../../common/utils.js"),f=require("../../../common/documents.js"),x=require("eventsource-parser"),p=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),g=require("../../Icons/file.svg.js"),j=require("../../Icons/x.svg.js"),b=require("../../Icons/arrow-right.svg.js"),v=require("../Addons/IceBreaker/index.js"),y=require("../../Core/Textarea.js"),w=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),N=require("../../../common/cn.js");exports.default=({isFocused:I,onFocus:O,onBlur:C})=>{var q;const{formId:S,chatId:R,userId:T,studioUserId:_,embedUserId:A,deploymentId:D,deploymentType:B,pickaxe:E,styles:F,colors:U,responsiveBy:H,isNewChat:z,isRtl:M,setIsNewChat:P,setIsShowIceBreaker:L,onGenerateComplete:$}=r.usePickaxeContext(),{messages:G,status:J,limits:K,isGenerating:W,setMessages:Q,setStatus:V,setLimitData:X,setError:Y}=o.useResponseContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,documentError:te,onFileUpload:re,setDocuments:oe,setDocumentError:le,removeDocument:ae}=d.useDocument(),{scrollStartSession:ie,scrollEndSession:ne,scrollToBottom:de}=c.useScroll({auto:!0}),ce=i.useConversation(),ue=n.useSubmit(),[me,fe]=t.useState(""),xe=t.useRef(null),pe=u.useHover(),{isHover:he}=pe,ge=e.__rest(pe,["isHover"]),je=u.useHover(),{isHover:be}=je,ve=e.__rest(je,["isHover"]),ye=a.useStyleFontSize(),we=l.useStyleInput(),ke=t.useMemo((()=>{var e,s,t;return!!z&&(!!E&&(!ce.isLoading&&(!((null!==(s=null===(e=ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=E.icebreakers)||void 0===t?void 0:t.length))))}),[E,z,ce.data,ce.isLoading]),Ne=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==J||ee)return;const e=null!=s?s:me;if(!e)return;Y(""),le(""),X(null),fe(""),P(!1),V("fetching"),ie(),de();const t=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r="enduserupload"===(null==E?void 0:E.documentuploadtype)&&t.length>0,o=[...Array.from(G),Object.assign({id:G.length+1,role:"user",content:e},r&&{documentIds:t})];Q(o),de(),r&&oe([]);const l=(yield ue.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:S,responseId:R,value:e},r&&{documentIds:t}),T&&{userId:T}),_&&{studioUserId:_}),A&&{embedUserId:A}),D&&{deploymentId:D}))).body;if(!l)throw new Error("Streaming error");const a=o.length,i=new TextDecoder,n=l.getReader();let d="",c=!0,u=!1;const m=x.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=s,Q([...o.slice(0,a),{id:G.length+1,role:"assistant",content:d}])}else if("error"===e.event){const s=JSON.parse(e.data);Y(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(c=!1)}});for(;c;){const{value:e,done:s}=yield n.read();if(s){c=!1;break}const t=i.decode(e);t&&(u||(V("streaming"),u=!0),m.feed(t))}null==$||$(R)}catch(e){let s=k.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(K).find((([e])=>s.includes(e)));t?X(t[1]):Y(s)}finally{de(),V("idle"),ne()}}));return t.useEffect((()=>{L(ke)}),[ke]),s.jsx("div",Object.assign({className:N.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===B&&z)&&"px-4 pb-4"),dir:M?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===B&&z)&&s.jsx("div",Object.assign({className:N.default("absolute bottom-full",M?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:N.default("flex flex-col gap-2 pb-4 px-2",M?"justify-start":"justify-end","viewport"===H?M?"min-[767px]:items-start":"min-[767px]:items-end":M?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:ke&&!I&&s.jsx(v.default,{data:(null==E?void 0:E.icebreakers)||[],onSend:Ne})}))})),s.jsxs("div",Object.assign({className:N.default("flex flex-col gap-y-2 px-4 py-3","block"===F.formFieldStyle&&"shadow"),style:we},{children:["idle"===J&&Z.length>0&&s.jsx("div",Object.assign({className:"flex flex-row gap-2 flex-wrap"},{children:Z.filter((e=>"failed"!==e.status)).map((e=>{var r,o,l;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:N.default("relative gap-x-[10px] flex items-center px-2 h-[56px] border",M&&"flex-row-reverse"),style:{borderRadius:we.borderRadius,borderColor:U.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:U.accent,borderRadius:we.borderRadius}},{children:ee?s.jsx(h.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(g.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:N.default("flex flex-col justify-center truncate",M?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:(N.default(ye.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:N.default(ye.b4,"opacity-80 truncate")},{children:m.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",className:N.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:we.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:we.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:we.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}/${null===(o=e.documentId)||void 0===o?void 0:o.split("-")[1]}.${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:we.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",className:N.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:we.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:N.default("flex items-end gap-x-2",M&&"flex-row-reverse")},{children:[s.jsx(y.default,Object.assign({className:N.default(ye.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",M?"text-right":"text-left"),value:me,placeholder:M?"بماذا تريد أن تتحدث؟":null!==(q=null==E?void 0:E.placeholdertext)&&void 0!==q?q:"What do you want to talk about?",onChange:e=>fe(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==J||Ne()))}},O&&{onFocus:O},C&&{onBlur:C},{dir:M?"rtl":"ltr"})),s.jsxs("div",Object.assign({className:N.default("flex items-center gap-x-2")},{children:["enduserupload"===(null==E?void 0:E.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:be?U.accent+"10":void 0},disabled:ee||"idle"!==J,onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:xe,type:"file",accept:[...f.allowedFileMimeTypes,...se?f.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){P(!1),yield re(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(p.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:be?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accent:U.accent+"10"},disabled:ee||"idle"!==J,onClick:()=>Ne()},ge,{children:s.jsx(b.default,{className:N.default("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",M&&"transform scale-x-[-1]"),style:{color:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accentText:U.accent+"80"}})}))]}))]}))]})),te&&s.jsx(w.default,{error:te,className:"mt-3"})]}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),l=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),l=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("../../Addons/Document/hooks/useDocument.js"),o=require("../../../../hooks/core/useHover.js"),n=require("../../../../common/documents.js"),c=require("../../../../common/utils.js"),d=require("../../../Icons/attach-vertical.svg.js"),u=require("../../../Icons/check.svg.js"),m=require("../../../Icons/spinner-lines.svg.js"),b=require("../../../Icons/file.svg.js"),x=require("../../../Icons/x.svg.js"),j=require("../../../Icons/link.svg.js"),f=require("../../../Core/ErrorAlert.js"),p=require("../../../../common/cn.js");exports.default=({field:h,update:g})=>{var y;const v=r.useStyleFontSize(),{colors:w,styles:N,translations:k,responsiveBy:O}=l.usePickaxeContext(),C=o.useHover(),{isHover:q}=C,I=e.__rest(C,["isHover"]),{documents:R,documentError:T,websiteLink:_,isUploading:D,isImageUploadAllowed:F,removeDocument:S,setDocumentError:A,setWebsiteLink:U,onFileUpload:z,onWebsiteUpload:E}=i.useDocument({onQuestionChange:e=>{g(Object.assign(Object.assign({},h),e))}}),[H,P]=t.useState(!1),B=t.useRef(null),L=a.useStyleInput();return s.jsxs("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:p.default(v.b3,"font-semibold opacity-70")},{children:h.main})),h.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:w.error}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsx("input",{ref:B,type:"file",accept:[...n.allowedFileMimeTypes,...F?n.allowedImageMimeTypes:[]].join(", "),id:h.id,hidden:!0,multiple:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield z(Array.from(s.target.files||[])),s.target.value=""})),disabled:D}),s.jsxs("div",Object.assign({className:p.default("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",H&&"block"===N.formFieldStyle&&"shadow","block"===N.formFieldStyle&&"shadow hover:shadow-none"),style:L},{children:[s.jsx("input",{type:"text",value:_,className:p.default(v.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(y=null==k?void 0:k["form-doc-placeholder"])&&void 0!==y?y:"Paste a website/video link or drag a file",onChange:e=>U(e.target.value),onDrop:s=>e.__awaiter(void 0,void 0,void 0,(function*(){s.preventDefault(),yield z(Array.from(s.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),E(_))},onFocus:()=>P(!0),onBlur:()=>P(!1)}),s.jsx("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:_.length>0?s.jsxs(s.Fragment,{children:[s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>E(_)},{children:s.jsx(u.default,{className:"h-5 w-5 shrink-0",style:{color:w.accent}})})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>{U(""),A("")}},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0",style:{color:w.accent}})}))]}):s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:D,onClick:()=>{var e;null===(e=B.current)||void 0===e||e.click()},style:{backgroundColor:q?w.accent+"10":void 0}},I,{children:s.jsx(d.default,{className:"h-6 w-6 shrink-0",style:{color:q?w.accent:w.accent+"80"}})}))}))]}))]}))]})),R.length>0&&s.jsx("div",Object.assign({className:p.default("flex gap-4","viewport"===O?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:s.jsx("div",Object.assign({className:"flex flex-row gap-x-2"},{children:R.filter((e=>"failed"!==e.status)).map((e=>{var l,a,r;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:w.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 animate-spin",style:{color:w.accentText}}):s.jsx(b.default,{className:"w-5 h-5",style:{color:w.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(p.default(v.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:p.default(v.b4,"opacity-80 truncate")},{children:c.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:L.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:L.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}/${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[1]}.${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:L.borderRadius,backgroundColor:w.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):"website"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:w.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 animate-spin",style:{color:w.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:w.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(p.default(v.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),s.jsx("p",Object.assign({className:p.default(v.b4,"opacity-80 truncate")},{children:(null==k?void 0:k.website)||"Website"}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):null},e.id)}))}))})),T&&s.jsx(f.default,{error:T,className:"mt-3"})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/pickaxe/useSubmit.js"),r=require("../../Addons/Document/hooks/useDocument.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/pickaxe/useSubmit.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../../../common/utils.js"),d=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),c=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),p=require("../../../../common/error.js"),f=require("../../../../common/cn.js");exports.default=({questions:g})=>{var x;const{formId:h,userId:b,studioUserId:j,embedUserId:v,deploymentId:w,pickaxe:k,misc:q,translations:y,responsiveBy:I,setChatId:O,setIsNewChat:S,onGenerateComplete:C}=n.usePickaxeContext(),{status:P,limits:D,isGenerating:U,setResponse:E,setMessages:R,setStatus:N,setLimitData:_,setError:A}=o.useResponseContext(),{documents:B,websiteLink:L,isUploading:T,onWebsiteUpload:M,setDocuments:W,setDocumentError:G}=r.useDocument(),{scrollStartSession:J,scrollEndSession:F,scrollToTarget:K}=a.useScroll({auto:!(null==k?void 0:k.enablechatresponses)}),X=i.useSubmit(),[Y,z]=t.useState(!1);return s.jsxs("div",Object.assign({className:f.default("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===I?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[s.jsx("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:s.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:T||"idle"!==P||U||Y,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==P||T||Y)return;A(""),G(""),_(null),E(null);const e=["Multiple Choice","Checkbox"];for(const s of g){if(d.encode(s.input).length>s.maxLength&&!e.includes(s.type))throw new Error("One or more of your responses is too long!");if(s.isRequired&&!s.input.trim()&&"userinput:documentupload"!==s.id)throw new Error("You must fill out all required fields.")}const s=B.filter((e=>"finished"===e.status)),t=B.map((e=>e.name)),n="enduserupload"===(null==k?void 0:k.documentuploadtype),o=g.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),i=l.extractUrlsFromText(L).filter((e=>!t.includes(e)));if(i.length){const e=i[i.length-1];z(!0);const t=yield M(e);t&&(s.push(t),yield new Promise((e=>setTimeout(e,5e3)))),z(!1)}else if(o&&n&&!s.length)return void G("Please paste a valid website/video link or drag a file to add to the knowledge base.");const r=s.map((e=>e.documentId)).filter(Boolean),a=n&&r.length>0;let c={};g.forEach((e=>c=Object.assign(Object.assign({},c),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?s.map((e=>e.name)).join(",")||"":e.input}))),N("fetching"),J(),K();const m=yield X.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:h,valueObj:c},a&&{documentIds:r}),b&&{userId:b}),j&&{studioUserId:j}),v&&{embedUserId:v}),w&&{deploymentId:w})),p=m.body;if(!p)throw new Error("Streaming error");const f=m.headers.get("X-Pickaxe-Response-Id");if(!f)throw new Error("Response ID not found");const x=new TextDecoder,q=p.getReader();let y="",I=!0,D=!1;const U=u.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");y+=s,E({formId:h,responseId:f,documentIds:r,questions:g.map((e=>({id:e.id,question:e.main,answer:e.input}))),questionResponse:y,messageCount:0,sentAt:new Date}),(null==k?void 0:k.enablechatresponses)&&R([{id:0,role:"assistant",content:y}])}else if("error"===e.event){const s=JSON.parse(e.data);A(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(I=!1)}});for(;I;){const{value:e,done:s}=yield q.read();if(s){I=!1;break}const t=x.decode(e);t&&(D||(N("streaming"),D=!0,a&&W([]),(null==k?void 0:k.enablechatresponses)&&(O(f),S(!1))),U.feed(t))}null==C||C(f)}catch(e){let s=p.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(D).find((([e])=>s.includes(e)));t?_(t[1]):A(s),K()}finally{N("idle"),z(!1),F()}}))},{children:Y?(null==y?void 0:y.processing)||"Processing...":T?(null==y?void 0:y.uploading)||"Uploading...":"fetching"===P||"streaming"===P?(null==y?void 0:y.loading)||"Loading...":null!==(x=null==k?void 0:k.submittext)&&void 0!==x?x:"Submit"}))})),!q.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3"},{children:s.jsx(c.default,{})}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),i=require("./Addons/Document/Provider.js"),o=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}const d=s.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:a,userId:l="",studioUserId:c="",deploymentId:u="",embedUserId:f="",deploymentType:p,deploymentDimensions:m,deploymentMisc:b,styles:y,colors:h,limits:v={},misc:x={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,responsiveBy:g="viewport",forceMobile:j=!1,disableHtml:I=!1,disableJs:P=!1,disableCss:w=!1,loadFont:S=!0,isRtl:O=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:D})=>{const[_,q]=s.useState(""),[E,H]=s.useState(""),[M,R]=s.useState(""),[T,U]=s.useState(null),[B,L]=s.useState(!1),[N,z]=s.useState(!0),[A,G]=s.useState(!0);return s.useEffect((()=>{L(!1)}),[null==y?void 0:y.font]),s.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!B&&(null==y?void 0:y.font)&&"Real Head Pro"!==y.font)try{(yield Promise.resolve().then((function(){return n(require("webfontloader"))}))).default.load({google:{families:[y.font]},active:()=>{L(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),L(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),L(!0)}}))}),[S,B,null==y?void 0:y.font]),t.jsx(d.Provider,Object.assign({value:Object.assign({formId:_,chatId:E,sessionId:M,userId:l,studioUserId:c,embedUserId:f,deploymentId:u,deploymentType:p,deploymentDimensions:m,deploymentMisc:b,pickaxe:T,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},y),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:x,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},F),responsiveBy:g,forceMobile:j,loadFont:S,disableHtml:I,disableJs:P,disableCss:w,isFontLoaded:B,isNewChat:N,isShowIceBreaker:A,isRtl:O,isEmbed:k,isDropShadow:C,setIsFontLoaded:L,setFormId:q,setChatId:H,setSessionId:R,setPickaxe:U,setIsNewChat:z,setIsShowIceBreaker:G},D&&{onGenerateComplete:D})},{children:t.jsx(o.default,Object.assign({limits:v},{children:t.jsx(r.default,{children:t.jsx(i.default,{children:a})})}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../hooks/pickaxe/usePickaxe.js"),t=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),r=require("../../common/utils.js"),i=require("./Addons/Scroll/Provider.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../hooks/pickaxe/usePickaxe.js"),t=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),r=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("../../common/utils.js"),i=require("./Addons/Scroll/Provider.js"),n=require("../Core/Skeleton.js"),u=require("./Chat/index.js"),x=require("./Form/index.js"),c=require("../../common/cn.js");exports.Pickaxe=({formId:d,className:f})=>{const{chatId:p,styles:m,colors:j,responsiveBy:h,deploymentType:k,isNewChat:w,setFormId:g,setChatId:q,setSessionId:v,setPickaxe:C}=a.usePickaxeContext(),{setMessages:N,setResponse:b,setError:y,setLimitData:P,setStatus:I}=l.useResponseContext(),{setDocumentError:O}=r.useDocumentContext(),[D,E]=t.useState(!1),S=s.usePickaxe();return t.useEffect((()=>{g(d)}),[d]),t.useEffect((()=>{if(!S.data)return;const e=S.data.chatflag;q(e?o.generateId(15):""),v(o.generateId(15)),e?N([]):b(null),y(""),O(""),P(null),C(S.data),E(!0)}),[S.data]),t.useEffect((()=>{y(""),O(""),P(null),N([]),b(null),I("idle")}),[p]),S.data?e.jsx("div",Object.assign({className:c.default("relative @container/pickaxe-root flex flex-col flex-grow w-full",!k&&"h-full","popup"===k&&p&&"h-full","dark"===m.theme&&"dark",f),style:Object.assign({backgroundColor:"chat-input"===k&&w?"transparent":j.primary,color:j.text},m.font&&"Real Head Pro"!==m.font&&{fontFamily:m.font})},{children:S.isLoading||!D?e.jsx("div",Object.assign({className:c.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===h?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:e.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[e.jsx(n.default,{className:"w-[72px] h-[72px]"}),e.jsx(n.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(n.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(n.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),e.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:e.jsx(n.default,{className:c.default("w-full min-h-[48px]","viewport"===h?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):e.jsx(e.Fragment,{children:p?e.jsx(i.default,{children:e.jsx(u.default,{})}):e.jsx(i.default,{children:e.jsx(x.default,{})})})})):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("@tanstack/react-query");exports.useSubmit=()=>s.useMutation({mutationFn:s=>(({formId:s,responseId:t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("@tanstack/react-query");exports.useSubmit=()=>s.useMutation({mutationFn:s=>(({formId:s,responseId:t,documentIds:n,studioUserId:o,deploymentId:i,embedUserId:r,pickaxe:d,value:a,valueObj:c,disabledDocumentIds:u,metadata:p})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e="undefined"!=typeof window?window.location.hostname:"",l="undefined"!=typeof window?window.location.href:"",b=e.includes("pickaxe.co")&&!l.includes("https://studio.pickaxe.co/_embed"),O=yield fetch(`${process.env.NEXT_PUBLIC_API_URL}/pickaxe/sse`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},t&&{responseId:t}),n&&{documentIds:n}),o&&{studioUserId:o}),i&&{deploymentId:i}),r&&{embedUserId:r}),d&&{pickaxe:d}),a&&{value:a}),c&&{valueObj:c}),u&&{disabledDocumentIds:u}),p&&{metadata:p}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),b&&{credentials:"include"}));if(200!==O.status){const e=yield O.json();throw new Error(e.error||"Unknown error, please contact support")}if("application/json"===O.headers.get("content-type")){const{success:e,error:s}=yield O.json();if(!e)throw new Error(s||"Unknown error, please contact support")}return O})))(s)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("../../common/utils.js");exports.useSubmitDocument=()=>({document:({formId:s,workspaceId:o,responseId:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("../../common/utils.js");exports.useSubmitDocument=()=>({document:({formId:s,workspaceId:o,responseId:i,file:n,isKnowledge:t,isBlocking:r,sessionId:c})=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,d;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const a=n.name.split(".").pop(),l=n.type,_={formid:s,mimetype:l,extension:a,responseid:i,workspaceid:o,sessionid:c},p=new URLSearchParams(Object.entries(_).filter((e=>void 0!==e[1]&&null!==e[1]&&""!==e[1]))),u=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${p.toString()}`,O=yield fetch(u),g=yield O.json();if(!g.success)throw new Error(null!==(e=g.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const f=new FormData;Object.entries(Object.assign(Object.assign({},g.fields),{file:n})).forEach((([e,s])=>{f.append(e,s)}));const m=yield fetch(g.url,{method:"POST",body:f});if(!m.ok)throw new Error(m.statusText);const w=`${g.url}${g.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",w),l.startsWith("image"))return{success:!0,documentId:`IMAGE-${g.documentId}-${g.folder}`};const I=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},o&&{workspaceId:o}),{documentId:g.documentId}),i&&{responseId:i}),{fileName:n.name,fileSize:n.size}),t&&{isKnowledge:t}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),b=yield I.json();if(!b.success)throw new Error(null!==(d=b.error)&&void 0!==d?d:"Failed processing document, try again or contact support.");return b})),website:({formId:o,workspaceId:i,responseId:n,website:t,isKnowledge:r,isBlocking:c})=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=s.generateId(20),a=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o},i&&{workspaceId:i}),{documentId:d}),n&&{responseId:n}),{website:t}),r&&{isKnowledge:r}),c&&{isBlocking:c})),headers:{"Content-Type":"application/json"}}),l=yield a.json();if(!l.success)throw new Error(null!==(e=l.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return l}))});
|
|
@@ -9,8 +9,9 @@ type DocumentContextType = {
|
|
|
9
9
|
isUploading: boolean;
|
|
10
10
|
isShowList: boolean;
|
|
11
11
|
editDocument: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
12
|
-
editDocumentByDocId: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
13
12
|
setDocuments: SetState<MemoryStoredDocument[]>;
|
|
13
|
+
addDocument: (newDocument: MemoryStoredDocument) => void;
|
|
14
|
+
removeDocument: (documentId: string) => void;
|
|
14
15
|
setDocumentError: SetState<string>;
|
|
15
16
|
setWebsiteLink: SetState<string>;
|
|
16
17
|
setIsUploading: SetState<boolean>;
|
|
@@ -5,9 +5,8 @@ interface UseDocumentProps {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const useDocument: ({ onQuestionChange }?: UseDocumentProps) => {
|
|
7
7
|
isImageUploadAllowed: boolean;
|
|
8
|
-
onFileUpload: (files: File[]) => Promise<
|
|
8
|
+
onFileUpload: (files: File[]) => Promise<null | undefined>;
|
|
9
9
|
onWebsiteUpload: (website: string) => Promise<MemoryStoredDocument | null>;
|
|
10
|
-
onEditDocumentByDocId: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
11
10
|
documents: MemoryStoredDocument[];
|
|
12
11
|
documentCount: number;
|
|
13
12
|
documentError: string;
|
|
@@ -15,8 +14,9 @@ export declare const useDocument: ({ onQuestionChange }?: UseDocumentProps) => {
|
|
|
15
14
|
isUploading: boolean;
|
|
16
15
|
isShowList: boolean;
|
|
17
16
|
editDocument: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
18
|
-
editDocumentByDocId: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
19
17
|
setDocuments: import("../../../../../types/common").SetState<MemoryStoredDocument[]>;
|
|
18
|
+
addDocument: (newDocument: MemoryStoredDocument) => void;
|
|
19
|
+
removeDocument: (documentId: string) => void;
|
|
20
20
|
setDocumentError: import("../../../../../types/common").SetState<string>;
|
|
21
21
|
setWebsiteLink: import("../../../../../types/common").SetState<string>;
|
|
22
22
|
setIsUploading: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -6,8 +6,9 @@ export declare const useDocumentContext: () => {
|
|
|
6
6
|
isUploading: boolean;
|
|
7
7
|
isShowList: boolean;
|
|
8
8
|
editDocument: (newDocument: Partial<import("../../../../../types/document").MemoryStoredDocument>) => void;
|
|
9
|
-
editDocumentByDocId: (newDocument: Partial<import("../../../../../types/document").MemoryStoredDocument>) => void;
|
|
10
9
|
setDocuments: import("../../../../../types/common").SetState<import("../../../../../types/document").MemoryStoredDocument[]>;
|
|
10
|
+
addDocument: (newDocument: import("../../../../../types/document").MemoryStoredDocument) => void;
|
|
11
|
+
removeDocument: (documentId: string) => void;
|
|
11
12
|
setDocumentError: import("../../../../../types/common").SetState<string>;
|
|
12
13
|
setWebsiteLink: import("../../../../../types/common").SetState<string>;
|
|
13
14
|
setIsUploading: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -54,6 +54,7 @@ export type PickaxeDeploymentMisc = {
|
|
|
54
54
|
type PickaxeContextType = {
|
|
55
55
|
formId: string;
|
|
56
56
|
chatId: string;
|
|
57
|
+
sessionId: string;
|
|
57
58
|
userId: string;
|
|
58
59
|
studioUserId: string;
|
|
59
60
|
embedUserId: string;
|
|
@@ -80,6 +81,7 @@ type PickaxeContextType = {
|
|
|
80
81
|
isDropShadow: boolean;
|
|
81
82
|
setFormId: SetState<string>;
|
|
82
83
|
setChatId: SetState<string>;
|
|
84
|
+
setSessionId: SetState<string>;
|
|
83
85
|
setPickaxe: SetState<LimitedPickaxe | null>;
|
|
84
86
|
setIsFontLoaded: SetState<boolean>;
|
|
85
87
|
setIsNewChat: SetState<boolean>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const usePickaxeContext: () => {
|
|
2
2
|
formId: string;
|
|
3
3
|
chatId: string;
|
|
4
|
+
sessionId: string;
|
|
4
5
|
userId: string;
|
|
5
6
|
studioUserId: string;
|
|
6
7
|
embedUserId: string;
|
|
@@ -27,6 +28,7 @@ export declare const usePickaxeContext: () => {
|
|
|
27
28
|
isDropShadow: boolean;
|
|
28
29
|
setFormId: import("../../types/common").SetState<string>;
|
|
29
30
|
setChatId: import("../../types/common").SetState<string>;
|
|
31
|
+
setSessionId: import("../../types/common").SetState<string>;
|
|
30
32
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
|
|
31
33
|
setIsFontLoaded: import("../../types/common").SetState<boolean>;
|
|
32
34
|
setIsNewChat: import("../../types/common").SetState<boolean>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export declare const useSubmitDocument: () => {
|
|
2
|
-
document: ({ formId, workspaceId, responseId, file, isKnowledge, isBlocking, }: {
|
|
2
|
+
document: ({ formId, workspaceId, responseId, file, isKnowledge, isBlocking, sessionId, }: {
|
|
3
3
|
formId: string;
|
|
4
4
|
workspaceId?: string | undefined;
|
|
5
5
|
responseId?: string | undefined;
|
|
6
6
|
file: File;
|
|
7
7
|
isKnowledge?: boolean | undefined;
|
|
8
8
|
isBlocking?: boolean | undefined;
|
|
9
|
+
sessionId: string;
|
|
9
10
|
}) => Promise<{
|
|
10
11
|
success: boolean;
|
|
11
12
|
documentId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useState as t,createContext as o}from"react";const s=o({}),i=({children:o})=>{const[i,n]=t([]),[r,c]=t(""),[d,m]=t(""),[u,a]=t(!1),[l,g]=t(!1);return e(s.Provider,Object.assign({value:{documents:i,documentCount:i.length,documentError:r,websiteLink:d,isUploading:u,isShowList:l,editDocument:e=>{n((t=>t.map((t=>t.id===e.id?Object.assign(Object.assign({},t),e):t))))},setDocuments:n,addDocument:e=>{n((t=>[...t,e]))},removeDocument:e=>{console.log(e),n((t=>t.filter((t=>t.id!==e))))},setDocumentError:c,setWebsiteLink:m,setIsUploading:a,setIsShowList:g}},{children:o}))};export{s as DocumentContext,i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as s}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as s}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as i}from"./useDocumentContext.js";import{allowedFileMimeTypes as n,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import d from"../../../../../common/error.js";import{v4 as a}from"uuid";const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"],l=({onQuestionChange:l}={})=>{const{formId:c,chatId:m,sessionId:p,pickaxe:f}=o(),g=i(),w=s(),I=t((()=>{var e;return u.includes(null!==(e=null==f?void 0:f.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[f]),h=e=>{const t=[...n,...I?r:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(I?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=d(e);return g.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},g),{isImageUploadAllowed:I,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(g.setDocumentError(""),!t.length)return null;if(h(t))return null;g.setIsUploading(!0),g.setIsShowList(!0);const o=t.map((e=>({file:e,id:a()})));o.forEach((({file:e,id:t})=>{g.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const s=o.map((({file:t,id:o})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:s,error:i}=yield w.document(Object.assign({formId:c,responseId:m,file:t,sessionId:p},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}));if(!e)throw new Error(null!=i?i:"Document processing failed");null==l||l({input:t.name,documentId:s});const n=s.startsWith("IMAGE-");return g.editDocument({id:o,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:s}),{name:t.name,documentId:s}}catch(e){const s=d(e);return g.editDocument({id:o,name:t.name,size:t.size,status:"failed",error:s}),{error:s}}})))),i=yield Promise.allSettled(s),n=new Set;for(const e of i)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&g.setDocumentError([...n].join(", ")),g.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){g.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");g.setIsUploading(!0),g.setIsShowList(!0),g.setWebsiteLink(""),g.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:c,responseId:m,website:e},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid})),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");g.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:s}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:s}}catch(t){const o=d(t);if(console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL"))return g.setDocumentError(o),null;g.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:o});return{type:"website",id:e,size:0,name:e,status:"failed",error:o}}finally{g.setIsUploading(!1)}}))})};export{l as useDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Fragment as t}from"react";import{usePickaxeContext as
|
|
1
|
+
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Fragment as t}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{PickaxeMarkdown as o}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as c}from"../../common/PickaxeMarkdown/Renderer.js";import l from"../../common/PickaxeIcon.js";import n from"./Document.js";import r from"../../common/PickaxeCopyButton.js";import m from"../../../../common/cn.js";const d=({index:d,message:x,isIntroExpand:p})=>{var h,u;const{formId:f,pickaxe:b,styles:g,colors:j,misc:v,responsiveBy:w,disableHtml:k,disableJs:y,disableCss:N,isNewChat:O,isRtl:C}=a(),I=i(),R=null!==(h=null==b?void 0:b.chaticon)&&void 0!==h?h:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${f}.png`;return"assistant"===x.role?e("div",Object.assign({className:m("flex w-full",C?"justify-end":"justify-start")},{children:e("div",Object.assign({className:m("flex flex-col",0===d&&O&&"viewport"===w&&"min-[767px]:max-w-[80%]",0===d&&O&&"container"===w&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:s("div",Object.assign({className:m("flex gap-x-3",C&&"flex-row-reverse")},{children:[v.isChatImage&&"NONE"!==R&&e(l,{src:R,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:j.text}),s("div",Object.assign({className:m("flex flex-col",C?"items-end":"items-start")},{children:[e("div",Object.assign({className:m(I.b2,"chat-message pt-3",C?"text-right":"text-left")},{children:e(o,Object.assign({theme:g.theme,accentColor:j.accent,actions:!0},C&&{rtl:!0},k&&{disableHtml:!0},y&&{disableJs:!0},N&&{disableCss:!0},{children:e(c,Object.assign({value:x.content},0===d&&O&&x.content.length>470&&3===(null!==(u=null==b?void 0:b.icebreakers)&&void 0!==u?u:[]).length&&!x.content.includes("https://utils.pickaxe.co/api/fn")&&{maxLines:p?void 0:12}))}))})),e("div",Object.assign({className:"mt-4 flex gap-3"},{children:e(r,{color:j.accent,text:x.content})}))]}))]}))}))})):"user"===x.role?e("div",Object.assign({className:m("flex w-full",C?"justify-start":"justify-end")},{children:e("div",Object.assign({className:m("flex gap-x-3 max-w-[80%]",C?"pr-9":"pl-9","viewport"===w?C?"min-[767px]:pr-0":"min-[767px]:pl-0":C?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:s("div",Object.assign({className:m(I.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",C?"text-right":"text-left"),style:{backgroundColor:j.secondary+"80",color:j.secondaryText,borderRadius:g.cornerRadius}},{children:[x.documentIds&&x.documentIds.length>0&&e("div",Object.assign({className:m("flex flex-col gap-y-2",C?"items-start":"items-end")},{children:x.documentIds.map((s=>e(t,{children:s.startsWith("IMAGE-")?e("div",Object.assign({className:"max-w-[300px]"},{children:e("img",{style:{borderRadius:g.cornerRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${s.split("-")[2]}/${s.split("-")[1]}.${null==s?void 0:s.split("-")[2]}`,alt:""})})):e(n,{documentId:s})},s)))})),e(o,Object.assign({theme:g.theme,accentColor:j.accent},C&&{rtl:!0},k&&{disableHtml:!0},y&&{disableJs:!0},N&&{disableCss:!0},{children:e(c,{value:x.content})}))]}))}))})):e("div",{})};export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as l,Fragment as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as u}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as f}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as b}from"../../../hooks/core/useHover.js";import{formatBytes as v}from"../../../common/utils.js";import{allowedFileMimeTypes as x,allowedImageMimeTypes as y}from"../../../common/documents.js";import{createParser as j}from"eventsource-parser";import k from"../../Icons/attach-vertical.svg.js";import w from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import I from"../../Icons/x.svg.js";import O from"../../Icons/arrow-right.svg.js";import C from"../Addons/IceBreaker/index.js";import S from"../../Core/Textarea.js";import R from"../../../common/error.js";import T from"../../../common/cn.js";const
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as l,Fragment as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as u}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as f}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as b}from"../../../hooks/core/useHover.js";import{formatBytes as v}from"../../../common/utils.js";import{allowedFileMimeTypes as x,allowedImageMimeTypes as y}from"../../../common/documents.js";import{createParser as j}from"eventsource-parser";import k from"../../Icons/attach-vertical.svg.js";import w from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import I from"../../Icons/x.svg.js";import O from"../../Icons/arrow-right.svg.js";import C from"../Addons/IceBreaker/index.js";import S from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import A from"../../../common/error.js";import T from"../../../common/cn.js";const D=({isFocused:D,onFocus:B,onBlur:E})=>{var U;const{formId:F,chatId:H,userId:z,studioUserId:L,embedUserId:$,deploymentId:G,deploymentType:J,pickaxe:K,styles:P,colors:W,responsiveBy:_,isNewChat:M,isRtl:q,setIsNewChat:Q,setIsShowIceBreaker:V,onGenerateComplete:X}=c(),{messages:Y,status:Z,limits:ee,isGenerating:te,setMessages:se,setStatus:oe,setLimitData:re,setError:ie}=d(),{documents:ne,isUploading:le,isImageUploadAllowed:ae,documentError:ce,onFileUpload:de,setDocuments:ue,setDocumentError:me,removeDocument:pe}=h(),{scrollStartSession:fe,scrollEndSession:he,scrollToBottom:ge}=g({auto:!0}),be=p(),ve=f(),[xe,ye]=r(""),je=i(null),ke=b(),{isHover:we}=ke,Ne=e(ke,["isHover"]),Ie=b(),{isHover:Oe}=Ie,Ce=e(Ie,["isHover"]),Se=m(),Re=u(),Ae=n((()=>{var e,t,s;return!!M&&(!!K&&(!be.isLoading&&(!((null!==(t=null===(e=be.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=K.icebreakers)||void 0===s?void 0:s.length))))}),[K,M,be.data,be.isLoading]),Te=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==Z||le)return;const t=null!=e?e:xe;if(!t)return;ie(""),me(""),re(null),ye(""),Q(!1),oe("fetching"),fe(),ge();const s=ne.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o="enduserupload"===(null==K?void 0:K.documentuploadtype)&&s.length>0,r=[...Array.from(Y),Object.assign({id:Y.length+1,role:"user",content:t},o&&{documentIds:s})];se(r),ge(),o&&ue([]);const i=(yield ve.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:F,responseId:H,value:t},o&&{documentIds:s}),z&&{userId:z}),L&&{studioUserId:L}),$&&{embedUserId:$}),G&&{deploymentId:G}))).body;if(!i)throw new Error("Streaming error");const n=r.length,l=new TextDecoder,a=i.getReader();let c="",d=!0,u=!1;const m=j({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=t,se([...r.slice(0,n),{id:Y.length+1,role:"assistant",content:c}])}else if("error"===e.event){const t=JSON.parse(e.data);ie(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(d=!1)}});for(;d;){const{value:e,done:t}=yield a.read();if(t){d=!1;break}const s=l.decode(e);s&&(u||(oe("streaming"),u=!0),m.feed(s))}null==X||X(H)}catch(e){let t=A(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(ee).find((([e])=>t.includes(e)));s?re(s[1]):ie(t)}finally{ge(),oe("idle"),he()}}));return l((()=>{V(Ae)}),[Ae]),s("div",Object.assign({className:T("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===J&&M)&&"px-4 pb-4"),dir:q?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===J&&M)&&s("div",Object.assign({className:T("absolute bottom-full",q?"left-0":"right-0")},{children:s("div",Object.assign({className:T("flex flex-col gap-2 pb-4 px-2",q?"justify-start":"justify-end","viewport"===_?q?"min-[767px]:items-start":"min-[767px]:items-end":q?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Ae&&!D&&s(C,{data:(null==K?void 0:K.icebreakers)||[],onSend:Te})}))})),o("div",Object.assign({className:T("flex flex-col gap-y-2 px-4 py-3","block"===P.formFieldStyle&&"shadow"),style:Re},{children:["idle"===Z&&ne.length>0&&s("div",Object.assign({className:"flex flex-row gap-2 flex-wrap"},{children:ne.filter((e=>"failed"!==e.status)).map((e=>{var t,r,i;return s(a,{children:"document"===e.type?o("div",Object.assign({className:T("relative gap-x-[10px] flex items-center px-2 h-[56px] border",q&&"flex-row-reverse"),style:{borderRadius:Re.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:Re.borderRadius}},{children:le?s(w,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:T("flex flex-col justify-center truncate",q?"text-right items-end":"text-left items-start")},{children:[s("p",Object.assign({className:(T(Se.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(Se.b4,"opacity-80 truncate")},{children:v(e.size)}))]})),s("button",Object.assign({type:"button",className:T("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:Re.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:Re.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(t=e.documentId)||void 0===t?void 0:t.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s("div",{className:"h-full w-full animate-pulse",style:{borderRadius:Re.borderRadius,backgroundColor:W.secondary}}),s("button",Object.assign({type:"button",className:T("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:T("flex items-end gap-x-2",q&&"flex-row-reverse")},{children:[s(S,Object.assign({className:T(Se.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!xe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",q?"text-right":"text-left"),value:xe,placeholder:q?"بماذا تريد أن تتحدث؟":null!==(U=null==K?void 0:K.placeholdertext)&&void 0!==U?U:"What do you want to talk about?",onChange:e=>ye(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),le||"idle"!==Z||Te()))}},B&&{onFocus:B},E&&{onBlur:E},{dir:q?"rtl":"ltr"})),o("div",Object.assign({className:T("flex items-center gap-x-2")},{children:["enduserupload"===(null==K?void 0:K.documentuploadtype)&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:Oe?W.accent+"10":void 0},disabled:le||"idle"!==Z,onClick:()=>{var e;return null===(e=je.current)||void 0===e?void 0:e.click()}},Ce,{children:[s("input",{id:"file-upload",ref:je,type:"file",accept:[...x,...ae?y:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){Q(!1),yield de(Array.from(e.target.files||[])),e.target.value=""}))}),s(k,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Oe?W.accent:W.accent+"80"}})]})),s("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accent:W.accent+"10"},disabled:le||"idle"!==Z,onClick:()=>Te()},Ne,{children:s(O,{className:T("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",q&&"transform scale-x-[-1]"),style:{color:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accentText:W.accent+"80"}})}))]}))]}))]})),ce&&s(R,{error:ce,className:"mt-3"})]}))}))};export{D as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as s}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as
|
|
1
|
+
import{__rest as e,__awaiter as s}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as i,Fragment as r}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleInput as c}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as u}from"../../Addons/Document/hooks/useDocument.js";import{useHover as m}from"../../../../hooks/core/useHover.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as p}from"../../../../common/documents.js";import{formatBytes as f}from"../../../../common/utils.js";import h from"../../../Icons/attach-vertical.svg.js";import g from"../../../Icons/check.svg.js";import y from"../../../Icons/spinner-lines.svg.js";import v from"../../../Icons/file.svg.js";import x from"../../../Icons/x.svg.js";import j from"../../../Icons/link.svg.js";import w from"../../../Core/ErrorAlert.js";import N from"../../../../common/cn.js";const k=({field:k,update:O})=>{var C;const R=d(),{colors:I,styles:D,translations:T,responsiveBy:F}=n(),A=m(),{isHover:S}=A,U=e(A,["isHover"]),{documents:E,documentError:z,websiteLink:H,isUploading:L,isImageUploadAllowed:W,removeDocument:$,setDocumentError:B,setWebsiteLink:P,onFileUpload:_,onWebsiteUpload:q}=u({onQuestionChange:e=>{O(Object.assign(Object.assign({},k),e))}}),[K,Q]=a(!1),G=i(null),J=c();return t("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:N(R.b3,"font-semibold opacity-70")},{children:k.main})),k.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:I.error}},{children:"*"}))]})),t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("input",{ref:G,type:"file",accept:[...b,...W?p:[]].join(", "),id:k.id,hidden:!0,multiple:!0,className:"hidden",onChange:e=>s(void 0,void 0,void 0,(function*(){yield _(Array.from(e.target.files||[])),e.target.value=""})),disabled:L}),t("div",Object.assign({className:N("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",K&&"block"===D.formFieldStyle&&"shadow","block"===D.formFieldStyle&&"shadow hover:shadow-none"),style:J},{children:[o("input",{type:"text",value:H,className:N(R.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(C=null==T?void 0:T["form-doc-placeholder"])&&void 0!==C?C:"Paste a website/video link or drag a file",onChange:e=>P(e.target.value),onDrop:e=>s(void 0,void 0,void 0,(function*(){e.preventDefault(),yield _(Array.from(e.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),q(H))},onFocus:()=>Q(!0),onBlur:()=>Q(!1)}),o("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:H.length>0?t(l,{children:[o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>q(H)},{children:o(g,{className:"h-5 w-5 shrink-0",style:{color:I.accent}})})),o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>{P(""),B("")}},{children:o(x,{className:"h-6 w-6 shrink-0",style:{color:I.accent}})}))]}):o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:L,onClick:()=>{var e;null===(e=G.current)||void 0===e||e.click()},style:{backgroundColor:S?I.accent+"10":void 0}},U,{children:o(h,{className:"h-6 w-6 shrink-0",style:{color:S?I.accent:I.accent+"80"}})}))}))]}))]}))]})),E.length>0&&o("div",Object.assign({className:N("flex gap-4","viewport"===F?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:o("div",Object.assign({className:"flex flex-row gap-x-2"},{children:E.filter((e=>"failed"!==e.status)).map((e=>{var s,l,a;return o(r,{children:"document"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin",style:{color:I.accentText}}):o(v,{className:"w-5 h-5",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(N(R.b3),"font-medium truncate")},{children:e.name})),o("p",Object.assign({className:N(R.b4,"opacity-80 truncate")},{children:f(e.size)}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):"image"===e.type?t("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:J.borderRadius}},{children:["finished"===e.status?o("img",{style:{borderRadius:J.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(s=e.documentId)||void 0===s?void 0:s.split("-")[2]}/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[1]}.${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[2]}`,alt:""}):o("div",{className:"h-full w-full animate-pulse",style:{borderRadius:J.borderRadius,backgroundColor:I.secondary}}),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):"website"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin",style:{color:I.accentText}}):o(j,{className:"w-5 h-5",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(N(R.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),o("p",Object.assign({className:N(R.b4,"opacity-80 truncate")},{children:(null==T?void 0:T.website)||"Website"}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):null},e.id)}))}))})),z&&o(w,{error:z,className:"mt-3"})]}))};export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as s}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useSubmit as r}from"../../../../hooks/pickaxe/useSubmit.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as a}from"../../Addons/Scroll/hooks/useScroll.js";import{extractUrlsFromText as d}from"../../../../common/utils.js";import{encode as c}from"@nem035/gpt-3-encoder";import{createParser as m}from"eventsource-parser";import u from"../../common/PickaxeBranding.js";import p from"../../common/PickaxeButton.js";import f from"../../../../common/error.js";import g from"../../../../common/cn.js";const h=({questions:h})=>{var b;const{formId:x,userId:v,studioUserId:j,embedUserId:w,deploymentId:k,pickaxe:
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as s}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useSubmit as r}from"../../../../hooks/pickaxe/useSubmit.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as a}from"../../Addons/Scroll/hooks/useScroll.js";import{extractUrlsFromText as d}from"../../../../common/utils.js";import{encode as c}from"@nem035/gpt-3-encoder";import{createParser as m}from"eventsource-parser";import u from"../../common/PickaxeBranding.js";import p from"../../common/PickaxeButton.js";import f from"../../../../common/error.js";import g from"../../../../common/cn.js";const h=({questions:h})=>{var b;const{formId:x,userId:v,studioUserId:j,embedUserId:w,deploymentId:k,pickaxe:y,misc:I,translations:O,responsiveBy:S,setChatId:C,setIsNewChat:D,onGenerateComplete:E}=n(),{status:U,limits:P,isGenerating:R,setResponse:q,setMessages:N,setStatus:A,setLimitData:B,setError:L}=i(),{documents:T,websiteLink:W,isUploading:G,onWebsiteUpload:J,setDocuments:M,setDocumentError:_}=l(),{scrollStartSession:K,scrollEndSession:X,scrollToTarget:Y}=a({auto:!(null==y?void 0:y.enablechatresponses)}),z=r(),[F,H]=s(!1);return o("div",Object.assign({className:g("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===S?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[t("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:t(p,Object.assign({className:"px-5 min-h-[42px]",isDisabled:G||"idle"!==U||R||F,onClick:()=>e(void 0,void 0,void 0,(function*(){try{if("idle"!==U||G||F)return;L(""),_(""),B(null),q(null);const e=["Multiple Choice","Checkbox"];for(const o of h){if(c(o.input).length>o.maxLength&&!e.includes(o.type))throw new Error("One or more of your responses is too long!");if(o.isRequired&&!o.input.trim()&&"userinput:documentupload"!==o.id)throw new Error("You must fill out all required fields.")}const o=T.filter((e=>"finished"===e.status)),t=T.map((e=>e.name)),s="enduserupload"===(null==y?void 0:y.documentuploadtype),n=h.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),i=d(W).filter((e=>!t.includes(e)));if(i.length){const e=i[i.length-1];H(!0);const t=yield J(e);t&&(o.push(t),yield new Promise((e=>setTimeout(e,5e3)))),H(!1)}else if(n&&s&&!o.length)return void _("Please paste a valid website/video link or drag a file to add to the knowledge base.");const r=o.map((e=>e.documentId)).filter(Boolean),l=s&&r.length>0;let a={};h.forEach((e=>a=Object.assign(Object.assign({},a),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?o.map((e=>e.name)).join(",")||"":e.input}))),A("fetching"),K(),Y();const u=yield z.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:x,valueObj:a},l&&{documentIds:r}),v&&{userId:v}),j&&{studioUserId:j}),w&&{embedUserId:w}),k&&{deploymentId:k})),p=u.body;if(!p)throw new Error("Streaming error");const f=u.headers.get("X-Pickaxe-Response-Id");if(!f)throw new Error("Response ID not found");const g=new TextDecoder,b=p.getReader();let I="",O=!0,S=!1;const P=m({onEvent:e=>{if("delta"===e.event){const o=JSON.parse(e.data).token.replace(/\u200B/g,"");I+=o,q({formId:x,responseId:f,documentIds:r,questions:h.map((e=>({id:e.id,question:e.main,answer:e.input}))),questionResponse:I,messageCount:0,sentAt:new Date}),(null==y?void 0:y.enablechatresponses)&&N([{id:0,role:"assistant",content:I}])}else if("error"===e.event){const o=JSON.parse(e.data);L(o.error||"Something went wrong, please try again.")}else"stop"===e.event&&(O=!1)}});for(;O;){const{value:e,done:o}=yield b.read();if(o){O=!1;break}const t=g.decode(e);t&&(S||(A("streaming"),S=!0,l&&M([]),(null==y?void 0:y.enablechatresponses)&&(C(f),D(!1))),P.feed(t))}null==E||E(f)}catch(e){let o=f(e)||"";o&&!o.includes("Unexpected token 'A',")||(o="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(P).find((([e])=>o.includes(e)));t?B(t[1]):L(o),Y()}finally{A("idle"),H(!1),X()}}))},{children:F?(null==O?void 0:O.processing)||"Processing...":G?(null==O?void 0:O.uploading)||"Uploading...":"fetching"===U||"streaming"===U?(null==O?void 0:O.loading)||"Loading...":null!==(b=null==y?void 0:y.submittext)&&void 0!==b?b:"Submit"}))})),!I.isWhiteLabel&&t("div",Object.assign({className:"flex justify-end pr-3"},{children:t(u,{})}))]}))};export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as i,useState as s,useEffect as t}from"react";import
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as i,useState as s,useEffect as t}from"react";import n from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import d from"./DimensionProvider.js";const l=i({}),a=({children:i,userId:a="",studioUserId:c="",deploymentId:m="",embedUserId:p="",deploymentType:f,deploymentDimensions:b,deploymentMisc:y,styles:h,colors:u,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:g,responsiveBy:v="viewport",forceMobile:w=!1,disableHtml:x=!1,disableJs:P=!1,disableCss:j=!1,loadFont:S=!0,isRtl:D=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:H})=>{const[O,R]=s(""),[T,U]=s(""),[B,L]=s(""),[M,E]=s(null),[N,A]=s(!1),[G,J]=s(!0),[W,_]=s(!0);return t((()=>{A(!1)}),[null==h?void 0:h.font]),t((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!N&&(null==h?void 0:h.font)&&"Real Head Pro"!==h.font)try{(yield import("webfontloader")).default.load({google:{families:[h.font]},active:()=>{A(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),A(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),A(!0)}}))}),[S,N,null==h?void 0:h.font]),o(l.Provider,Object.assign({value:Object.assign({formId:O,chatId:T,sessionId:B,userId:a,studioUserId:c,embedUserId:p,deploymentId:m,deploymentType:f,deploymentDimensions:b,deploymentMisc:y,pickaxe:M,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},h),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},g),responsiveBy:v,forceMobile:w,loadFont:S,disableHtml:x,disableJs:P,disableCss:j,isFontLoaded:N,isNewChat:G,isShowIceBreaker:W,isRtl:D,isEmbed:k,isDropShadow:C,setIsFontLoaded:A,setFormId:R,setChatId:U,setSessionId:L,setPickaxe:E,setIsNewChat:J,setIsShowIceBreaker:_},H&&{onGenerateComplete:H})},{children:o(r,Object.assign({limits:F},{children:o(d,{children:o(n,{children:i})})}))}))};export{l as PickaxeContext,a as PickaxeProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as o}from"react/jsx-runtime";import{usePickaxe as s}from"../../hooks/pickaxe/usePickaxe.js";import{useState as l,useEffect as a}from"react";import{usePickaxeContext as r}from"../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../hooks/pickaxe/useResponseContext.js";import{
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as o}from"react/jsx-runtime";import{usePickaxe as s}from"../../hooks/pickaxe/usePickaxe.js";import{useState as l,useEffect as a}from"react";import{usePickaxeContext as r}from"../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as m}from"./Addons/Document/hooks/useDocumentContext.js";import{generateId as n}from"../../common/utils.js";import c from"./Addons/Scroll/Provider.js";import p from"../Core/Skeleton.js";import x from"./Chat/index.js";import f from"./Form/index.js";import d from"../../common/cn.js";const u=({formId:u,className:h})=>{const{chatId:k,styles:w,colors:j,responsiveBy:g,deploymentType:N,isNewChat:b,setFormId:v,setChatId:y,setSessionId:C,setPickaxe:I}=r(),{setMessages:O,setResponse:P,setError:D,setLimitData:S,setStatus:F}=i(),{setDocumentError:R}=m(),[A,E]=l(!1),L=s();return a((()=>{v(u)}),[u]),a((()=>{if(!L.data)return;const e=L.data.chatflag;y(e?n(15):""),C(n(15)),e?O([]):P(null),D(""),R(""),S(null),I(L.data),E(!0)}),[L.data]),a((()=>{D(""),R(""),S(null),O([]),P(null),F("idle")}),[k]),L.data?e("div",Object.assign({className:d("relative @container/pickaxe-root flex flex-col flex-grow w-full",!N&&"h-full","popup"===N&&k&&"h-full","dark"===w.theme&&"dark",h),style:Object.assign({backgroundColor:"chat-input"===N&&b?"transparent":j.primary,color:j.text},w.font&&"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:L.isLoading||!A?e("div",Object.assign({className:d("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===g?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[e(p,{className:"w-[72px] h-[72px]"}),e(p,{className:"h-[20px] mt-6 w-full"}),e(p,{className:"h-[20px] mt-2 w-full"}),e(p,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),e("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:e(p,{className:d("w-full min-h-[48px]","viewport"===g?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):e(o,{children:e(c,k?{children:e(x,{})}:{children:e(f,{})})})})):null};export{u as Pickaxe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useMutation as s}from"@tanstack/react-query";const n=()=>s({mutationFn:s=>(({formId:s,responseId:n,
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useMutation as s}from"@tanstack/react-query";const n=()=>s({mutationFn:s=>(({formId:s,responseId:n,documentIds:t,studioUserId:o,deploymentId:i,embedUserId:d,pickaxe:c,value:r,valueObj:a,disabledDocumentIds:p,metadata:u})=>e(void 0,void 0,void 0,(function*(){const e="undefined"!=typeof window?window.location.hostname:"",l="undefined"!=typeof window?window.location.href:"",O=e.includes("pickaxe.co")&&!l.includes("https://studio.pickaxe.co/_embed"),b=yield fetch(`${process.env.NEXT_PUBLIC_API_URL}/pickaxe/sse`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},n&&{responseId:n}),t&&{documentIds:t}),o&&{studioUserId:o}),i&&{deploymentId:i}),d&&{embedUserId:d}),c&&{pickaxe:c}),r&&{value:r}),a&&{valueObj:a}),p&&{disabledDocumentIds:p}),u&&{metadata:u}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),O&&{credentials:"include"}));if(200!==b.status){const e=yield b.json();throw new Error(e.error||"Unknown error, please contact support")}if("application/json"===b.headers.get("content-type")){const{success:e,error:s}=yield b.json();if(!e)throw new Error(s||"Unknown error, please contact support")}return b})))(s)});export{n as useSubmit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{generateId as s}from"../../common/utils.js";const o=()=>({document:({formId:s,workspaceId:o,responseId:n,file:
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{generateId as s}from"../../common/utils.js";const o=()=>({document:({formId:s,workspaceId:o,responseId:n,file:i,isKnowledge:t,isBlocking:r,sessionId:c})=>e(void 0,void 0,void 0,(function*(){var e,d;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const a=i.name.split(".").pop(),l=i.type,p={formid:s,mimetype:l,extension:a,responseid:n,workspaceid:o,sessionid:c},_=new URLSearchParams(Object.entries(p).filter((e=>void 0!==e[1]&&null!==e[1]&&""!==e[1]))),O=`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?${_.toString()}`,g=yield fetch(O),f=yield g.json();if(!f.success)throw new Error(null!==(e=f.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const m=new FormData;Object.entries(Object.assign(Object.assign({},f.fields),{file:i})).forEach((([e,s])=>{m.append(e,s)}));const u=yield fetch(f.url,{method:"POST",body:m});if(!u.ok)throw new Error(u.statusText);const w=`${f.url}${f.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",w),l.startsWith("image"))return{success:!0,documentId:`IMAGE-${f.documentId}-${f.folder}`};const I=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:s},o&&{workspaceId:o}),{documentId:f.documentId}),n&&{responseId:n}),{fileName:i.name,fileSize:i.size}),t&&{isKnowledge:t}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),P=yield I.json();if(!P.success)throw new Error(null!==(d=P.error)&&void 0!==d?d:"Failed processing document, try again or contact support.");return P})),website:({formId:o,workspaceId:n,responseId:i,website:t,isKnowledge:r,isBlocking:c})=>e(void 0,void 0,void 0,(function*(){var e;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=s(20),a=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/process_document`,{method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:o},n&&{workspaceId:n}),{documentId:d}),i&&{responseId:i}),{website:t}),r&&{isKnowledge:r}),c&&{isBlocking:c})),headers:{"Content-Type":"application/json"}}),l=yield a.json();if(!l.success)throw new Error(null!==(e=l.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return l}))});export{o as useSubmitDocument};
|
|
@@ -9,8 +9,9 @@ type DocumentContextType = {
|
|
|
9
9
|
isUploading: boolean;
|
|
10
10
|
isShowList: boolean;
|
|
11
11
|
editDocument: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
12
|
-
editDocumentByDocId: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
13
12
|
setDocuments: SetState<MemoryStoredDocument[]>;
|
|
13
|
+
addDocument: (newDocument: MemoryStoredDocument) => void;
|
|
14
|
+
removeDocument: (documentId: string) => void;
|
|
14
15
|
setDocumentError: SetState<string>;
|
|
15
16
|
setWebsiteLink: SetState<string>;
|
|
16
17
|
setIsUploading: SetState<boolean>;
|
|
@@ -5,9 +5,8 @@ interface UseDocumentProps {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const useDocument: ({ onQuestionChange }?: UseDocumentProps) => {
|
|
7
7
|
isImageUploadAllowed: boolean;
|
|
8
|
-
onFileUpload: (files: File[]) => Promise<
|
|
8
|
+
onFileUpload: (files: File[]) => Promise<null | undefined>;
|
|
9
9
|
onWebsiteUpload: (website: string) => Promise<MemoryStoredDocument | null>;
|
|
10
|
-
onEditDocumentByDocId: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
11
10
|
documents: MemoryStoredDocument[];
|
|
12
11
|
documentCount: number;
|
|
13
12
|
documentError: string;
|
|
@@ -15,8 +14,9 @@ export declare const useDocument: ({ onQuestionChange }?: UseDocumentProps) => {
|
|
|
15
14
|
isUploading: boolean;
|
|
16
15
|
isShowList: boolean;
|
|
17
16
|
editDocument: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
18
|
-
editDocumentByDocId: (newDocument: Partial<MemoryStoredDocument>) => void;
|
|
19
17
|
setDocuments: import("../../../../../types/common").SetState<MemoryStoredDocument[]>;
|
|
18
|
+
addDocument: (newDocument: MemoryStoredDocument) => void;
|
|
19
|
+
removeDocument: (documentId: string) => void;
|
|
20
20
|
setDocumentError: import("../../../../../types/common").SetState<string>;
|
|
21
21
|
setWebsiteLink: import("../../../../../types/common").SetState<string>;
|
|
22
22
|
setIsUploading: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -6,8 +6,9 @@ export declare const useDocumentContext: () => {
|
|
|
6
6
|
isUploading: boolean;
|
|
7
7
|
isShowList: boolean;
|
|
8
8
|
editDocument: (newDocument: Partial<import("../../../../../types/document").MemoryStoredDocument>) => void;
|
|
9
|
-
editDocumentByDocId: (newDocument: Partial<import("../../../../../types/document").MemoryStoredDocument>) => void;
|
|
10
9
|
setDocuments: import("../../../../../types/common").SetState<import("../../../../../types/document").MemoryStoredDocument[]>;
|
|
10
|
+
addDocument: (newDocument: import("../../../../../types/document").MemoryStoredDocument) => void;
|
|
11
|
+
removeDocument: (documentId: string) => void;
|
|
11
12
|
setDocumentError: import("../../../../../types/common").SetState<string>;
|
|
12
13
|
setWebsiteLink: import("../../../../../types/common").SetState<string>;
|
|
13
14
|
setIsUploading: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -54,6 +54,7 @@ export type PickaxeDeploymentMisc = {
|
|
|
54
54
|
type PickaxeContextType = {
|
|
55
55
|
formId: string;
|
|
56
56
|
chatId: string;
|
|
57
|
+
sessionId: string;
|
|
57
58
|
userId: string;
|
|
58
59
|
studioUserId: string;
|
|
59
60
|
embedUserId: string;
|
|
@@ -80,6 +81,7 @@ type PickaxeContextType = {
|
|
|
80
81
|
isDropShadow: boolean;
|
|
81
82
|
setFormId: SetState<string>;
|
|
82
83
|
setChatId: SetState<string>;
|
|
84
|
+
setSessionId: SetState<string>;
|
|
83
85
|
setPickaxe: SetState<LimitedPickaxe | null>;
|
|
84
86
|
setIsFontLoaded: SetState<boolean>;
|
|
85
87
|
setIsNewChat: SetState<boolean>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const usePickaxeContext: () => {
|
|
2
2
|
formId: string;
|
|
3
3
|
chatId: string;
|
|
4
|
+
sessionId: string;
|
|
4
5
|
userId: string;
|
|
5
6
|
studioUserId: string;
|
|
6
7
|
embedUserId: string;
|
|
@@ -27,6 +28,7 @@ export declare const usePickaxeContext: () => {
|
|
|
27
28
|
isDropShadow: boolean;
|
|
28
29
|
setFormId: import("../../types/common").SetState<string>;
|
|
29
30
|
setChatId: import("../../types/common").SetState<string>;
|
|
31
|
+
setSessionId: import("../../types/common").SetState<string>;
|
|
30
32
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
|
|
31
33
|
setIsFontLoaded: import("../../types/common").SetState<boolean>;
|
|
32
34
|
setIsNewChat: import("../../types/common").SetState<boolean>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export declare const useSubmitDocument: () => {
|
|
2
|
-
document: ({ formId, workspaceId, responseId, file, isKnowledge, isBlocking, }: {
|
|
2
|
+
document: ({ formId, workspaceId, responseId, file, isKnowledge, isBlocking, sessionId, }: {
|
|
3
3
|
formId: string;
|
|
4
4
|
workspaceId?: string | undefined;
|
|
5
5
|
responseId?: string | undefined;
|
|
6
6
|
file: File;
|
|
7
7
|
isKnowledge?: boolean | undefined;
|
|
8
8
|
isBlocking?: boolean | undefined;
|
|
9
|
+
sessionId: string;
|
|
9
10
|
}) => Promise<{
|
|
10
11
|
success: boolean;
|
|
11
12
|
documentId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pickaxeproject/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Client utility library for Pickaxe",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"import": "./dist/esm/index.js",
|
|
13
|
-
"require": "./dist/cjs/index.js"
|
|
14
|
-
"types": "./dist/esm/src/index.d.ts"
|
|
13
|
+
"require": "./dist/cjs/index.js"
|
|
15
14
|
},
|
|
16
15
|
"./embed": {
|
|
17
16
|
"import": "./dist/esm/embed/index.js",
|
|
18
|
-
"require": "./dist/cjs/embed/index.js"
|
|
19
|
-
"types": "./dist/esm/src/embed.d.ts"
|
|
17
|
+
"require": "./dist/cjs/embed/index.js"
|
|
20
18
|
},
|
|
21
19
|
"./prose.css": "./dist/esm/prose.css"
|
|
22
20
|
},
|
|
@@ -72,6 +70,7 @@
|
|
|
72
70
|
"@types/react": "^18.0.26",
|
|
73
71
|
"@types/react-dom": "^18.0.10",
|
|
74
72
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
73
|
+
"@types/uuid": "^10.0.0",
|
|
75
74
|
"@types/webfontloader": "^1.6.38",
|
|
76
75
|
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
77
76
|
"@typescript-eslint/parser": "^5.48.1",
|
|
@@ -125,6 +124,7 @@
|
|
|
125
124
|
"typescript": "^4.9.4",
|
|
126
125
|
"typescript-transform-paths": "^3.4.6",
|
|
127
126
|
"unist-util-visit": "^5.0.0",
|
|
127
|
+
"uuid": "^11.1.0",
|
|
128
128
|
"vite": "^6.0.7",
|
|
129
129
|
"vite-plugin-svgr": "^4.3.0",
|
|
130
130
|
"vite-tsconfig-paths": "^5.1.4",
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
"tailwind-merge": "^2.6.0",
|
|
162
162
|
"tailwind-scrollbar": "^3.1.0",
|
|
163
163
|
"unist-util-visit": "^5.0.0",
|
|
164
|
+
"uuid": "^11.1.0",
|
|
164
165
|
"webfontloader": "^1.6.28"
|
|
165
166
|
},
|
|
166
167
|
"engines": {
|