@pickaxeproject/react 0.0.43 → 0.0.44
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/hooks/useDocument.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/Img/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/common/Action.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/common/LinkPreview.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
- package/dist/cjs/hooks/pickaxe/useSubmitDocument.js +1 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.d.ts +1 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Custom/common/LinkPreview.d.ts +6 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +11 -9
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +17 -9
- package/dist/cjs/src/hooks/pickaxe/useSubmitDocument.d.ts +21 -9
- package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/Img/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/common/Action.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/common/LinkPreview.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
- package/dist/esm/hooks/pickaxe/useSubmitDocument.js +1 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.d.ts +1 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Custom/common/LinkPreview.d.ts +6 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +11 -9
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +17 -9
- package/dist/esm/src/hooks/pickaxe/useSubmitDocument.d.ts +21 -9
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),o=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("./useDocumentContext.js"),i=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js");const a=["gpt-4o","gpt-4o-mini"];exports.useDocument=({onQuestionChange:u}={})=>{const{pickaxe:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),o=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("./useDocumentContext.js"),i=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js");const a=["gpt-4o","gpt-4o-mini"];exports.useDocument=({onQuestionChange:u}={})=>{const{formId:d,chatId:l,pickaxe:c}=o.usePickaxeContext(),m=n.useDocumentContext(),p=s.useSubmitDocument(),f=t.useMemo((()=>{var e;return a.includes(null!==(e=null==c?void 0:c.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[c]);return Object.assign(Object.assign({},m),{isImageUploadAllowed:f,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(m.setDocumentError(""),!t.length)return null;const e=t[0];try{const o=[...i.allowedFileMimeTypes,...f?i.allowedImageMimeTypes:[]],s=t.some((e=>!o.includes(e.type)));if(s){throw new Error(f?"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.")}m.setIsUploading(!0),m.setIsShowList(!0),m.upsertDocuments([{type:"document",id:e.name,name:e.name,status:"uploading"}]);const n=yield p.document({formId:d,responseId:l,file:e}),{success:r,documentId:a,error:c}=n;if(!r)throw new Error(null!=c?c:"Document processing failed, please try again.");null==u||u({input:e.name,documentId:a});const y=a.startsWith("IMAGE-")?"image":"document";return m.upsertDocuments([{type:y,id:e.name,name:e.name,status:"finished",documentId:a}]),{type:y,id:e.name,name:e.name,status:"finished",documentId:a}}catch(t){const o=r.default(t);return console.log("[onFileUpload] Error",o),o.includes("You can only upload")?(m.setDocumentError(o),null):(m.editDocument({type:"document",id:e.name,name:e.name,status:"failed",error:o}),{type:"document",id:e.name,name:e.name,status:"failed",error:o})}finally{m.setIsUploading(!1)}})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){m.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.");m.setIsUploading(!0),m.setIsShowList(!0),m.setWebsiteLink(""),m.upsertDocuments([{type:"website",id:e,name:e,status:"uploading"}]);const t=yield p.website({formId:d,responseId:l,website:e}),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");return m.upsertDocuments([{type:"website",id:e,name:e,status:"finished",documentId:s}]),{type:"website",id:e,name:e,status:"finished",documentId:s}}catch(t){const o=r.default(t);return console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL")?(m.setDocumentError(o),null):(m.editDocument({type:"website",id:e,name:e,status:"failed",error:o}),{type:"website",id:e,name:e,status:"failed",error:o})}finally{m.setIsUploading(!1)}})),onEditDocumentByDocId:m.editDocumentByDocId})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),s=require("@tanstack/react-query"),o=require("../../hooks/usePickaxeMarkdownContext.js"),i=require("../common/Action.js"),n=require("../Img/index.js"),a=require("../../../../../../common/api/utils.js"),u=require("../../../../../../common/error.js");exports.default=({node:l,href:c="",children:d})=>{const{accentColor:f,websiteMetadatas:p,linkPreviews:m,actions:h,setWebsiteMetadatas:w}=o.usePickaxeMarkdownContext(),b=c.startsWith("http://")?`https://${c.slice(7)}`:c.startsWith("www.")?`https://${c}`:c;s.useQuery({queryKey:[b],queryFn:()=>(t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("development"===process.env.NODE_ENV&&console.log("[getWebsiteMetadata]",t),!t)return null;if(!t.startsWith("https"))return null;const e=["/api/function_call_results","/api/fn/result","https://prod-pickaxe-assets.s3.amazonaws.com"];if(t.includes("pickaxe")&&e.some((e=>t.includes(e))))return null;const r=(yield a.default.get(`/metadata?url=${encodeURIComponent(t)}`)).data;if(r.error)throw new Error(r.error||"Failed to fetch metadata");return r}catch(e){const t=u.default(e);return"development"===process.env.NODE_ENV&&console.error("[getJobResult]",t),null}})))(b),enabled:"undefined"!=typeof window&&m&&!!b&&!p.some((e=>e.href===b)),retry:2,onSuccess:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t&&(p.some((e=>e.href===t.href))||w((e=>[...e,t])))}))}),r.useEffect((()=>{m&&b&&p.some((e=>e.href===b))}),[m,b,p]);const j=b.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(j&&(null==j?void 0:j[1]))return t.jsx("div",Object.assign({style:{marginTop:"2rem",marginBottom:"2rem",display:"flex",width:"100%",justifyContent:"center"}},{children:t.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${j[1]}`,style:{width:"100%",maxWidth:"560px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));return b.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif)$/)?t.jsx(n.default,{src:b,alt:"string"==typeof d?d:"Markdown Image"}):h&&b.includes("pickaxe")&&(b.includes("/api/fn/result")||b.includes("/api/function_call_results"))?t.jsx(i.default,{jobUrl:b}):t.jsx("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:f,fontWeight:600}},{children:d}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),r=require("react"),s=require("../../hooks/usePickaxeMarkdownContext.js"),t=require("../../../../../../hooks/core/useHover.js"),i=require("framer-motion"),n=require("../../../../../../common/utils.js"),a=require("../../../../../Icons/download.svg.js"),l=require("../../../PickaxeCopyButton.js"),d=require("./ImgModal.js");exports.default=({node:c,src:u,alt:x})=>{const{accentColor:p}=s.usePickaxeMarkdownContext(),[b,g]=r.useState(!1),[h,j]=r.useState(!1),m=t.useHover(),{isHover:k}=m,v=e.__rest(m,["isHover"]),w={hidden:{opacity:0,y:-10,pointerEvents:"none"},visible:{opacity:1,y:0,pointerEvents:"auto"}},y=()=>o.jsxs("div",Object.assign({style:{position:"relative"}},{children:[o.jsxs(i.motion.div,Object.assign({initial:"hidden",animate:k?"visible":"hidden",variants:w,style:{position:"absolute",display:"flex",gap:"0.4rem",top:"10px",right:"10px",color:"#FFF"}},{children:[o.jsx(i.motion.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:p+"07"},whileHover:{backgroundColor:p
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),r=require("react"),s=require("../../hooks/usePickaxeMarkdownContext.js"),t=require("../../../../../../hooks/core/useHover.js"),i=require("framer-motion"),n=require("../../../../../../common/utils.js"),a=require("../../../../../Icons/download.svg.js"),l=require("../../../PickaxeCopyButton.js"),d=require("./ImgModal.js");exports.default=({node:c,src:u,alt:x})=>{const{accentColor:p}=s.usePickaxeMarkdownContext(),[b,g]=r.useState(!1),[h,j]=r.useState(!1),m=t.useHover(),{isHover:k}=m,v=e.__rest(m,["isHover"]),w={hidden:{opacity:0,y:-10,pointerEvents:"none"},visible:{opacity:1,y:0,pointerEvents:"auto"}},y=()=>o.jsxs("div",Object.assign({style:{position:"relative"}},{children:[o.jsxs(i.motion.div,Object.assign({initial:"hidden",animate:k?"visible":"hidden",variants:w,style:{position:"absolute",display:"flex",gap:"0.4rem",top:"10px",right:"10px",color:"#FFF"}},{children:[o.jsx(i.motion.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:p+"07"},whileHover:{backgroundColor:p},whileTap:{scale:.95},onClick:e=>{e.stopPropagation(),window.open(u,"_blank")}},{children:o.jsx(a.default,{width:24,height:24,style:{color:n.getContrastColor(p),flexShrink:0}})})),o.jsx(i.motion.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:p+"07"},whileHover:{backgroundColor:p},whileTap:{scale:.95},onClick:e=>e.stopPropagation()},{children:o.jsx(l.default,{color:n.getContrastColor(p),iconClassName:"w-6 h-6",text:u||""})}))]})),o.jsx("img",{src:u,alt:x,style:{borderRadius:"8px",width:"100%",transition:"box-shadow 0.3s ease",boxShadow:k?"inset 0px 4px 10px rgba(0, 0, 0, 0.5)":"none"},onError:()=>g(!0),onClick:()=>j(!0)})]}));return o.jsxs("div",Object.assign({style:{marginTop:"2rem",marginBottom:"2rem",display:"flex",width:"100%",justifyContent:"center",overflow:"hidden",borderRadius:"8px",transition:"transform 0.3s ease, box-shadow 0.3s ease",transform:k?"translateY(-5px)":"translateY(0)"}},v,{children:[b?o.jsx("p",Object.assign({style:{userSelect:"none",opacity:.5,fontStyle:"italic"}},{children:"[Image link is broken]"})):o.jsx(y,{}),h&&o.jsx(d.default,Object.assign({isOpen:h,onChangeIsOpen:j},{children:o.jsx(y,{})}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),i=require("@tanstack/react-query"),o=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../../../../../../common/lotties/loader-black.js"),n=require("../../../../../../common/lotties/loader-white.js"),s=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),i=require("@tanstack/react-query"),o=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../../../../../../common/lotties/loader-black.js"),n=require("../../../../../../common/lotties/loader-white.js"),s=require("../../../../../../common/api/streamer.js"),d=require("../../../PickaxeLottie.js"),c=require("../../Renderer.js"),l=require("framer-motion"),u=require("../../../../../../common/api/utils.js"),m=require("../../../../../../common/error.js");exports.default=({jobUrl:v})=>{var j,p,x,y;const{theme:f}=o.usePickaxeMarkdownContext(),[h,b]=r.useState(""),[g,k]=r.useState(""),q=r.useRef(null),w=i.useQuery({queryKey:[v],queryFn:()=>(t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!t||t.includes("undefined"))throw new Error("Invalid action job URL");const e=yield fetch(t);return yield e.json()}catch(e){const t=m.default(e);return"development"===process.env.NODE_ENV&&console.error("[getJobResult]",t),{success:!1,error:t}}})))(v),enabled:"undefined"!=typeof window,retry:10,onSuccess:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(k(""),!t.success)return;if("text"in t)return void b(t.text||"");if(!("fcid"in t)){const e=(yield s.streamer({formId:t.formId,responseId:t.responseId,data:t.encodedData})).body;if(!e)return;let r=!0,i="";const o=e.getReader(),a=new TextDecoder;for(;r;){const{value:e,done:t}=yield o.read();r=!t;i+=a.decode(e),b(i)}return b(i),yield u.default.post("/fn/update",{id:t.jobId,data:Object.assign(Object.assign({},t),{text:i})}),void console.log("[Action] streaming done")}yield new Promise((e=>setTimeout(e,3e3))),w.refetch(),"development"===process.env.NODE_ENV&&console.log(`[Action] refetching <${v}>`)}catch(e){k(m.default(e))}}))});return t.jsx("div",Object.assign({ref:q,className:"pxe-action"},{children:t.jsx(l.AnimatePresence,{children:g||w.error||(null===(j=w.data)||void 0===j?void 0:j.error)?t.jsxs(l.motion.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"mt-4"},{children:[t.jsx("blockquote",Object.assign({style:{lineHeight:"20px",borderLeft:"4px solid #FF0000",color:"#FF0000",paddingLeft:"1rem",marginBottom:"1rem"}},{children:g||(null===(p=w.data)||void 0===p?void 0:p.error)||"Failed to process, please try again."})),(null===(x=w.data)||void 0===x?void 0:x.traceback)&&t.jsxs(t.Fragment,{children:[t.jsxs("p",Object.assign({style:{color:"#FF0000"}},{children:["Traceback:"," "]})),t.jsx(c.PickaxeMarkdownRenderer,{value:`\`\`\`js\n${null===(y=w.data)||void 0===y?void 0:y.traceback}\n\`\`\``,recursion:!0})]})]})):h?t.jsx(l.motion.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"mt-4"},{children:t.jsx(c.PickaxeMarkdownRenderer,{value:h,recursion:!0})})):t.jsx(l.motion.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:t.jsx(d.PickaxeLottie,{id:"dark"===f?"loader-white":"loader-black",getJson:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return"dark"===f?n.loaderWhite:a.loaderBlack})),autoplay:!0,loop:!0,style:{cursor:"default",pointerEvents:"none",width:"100%",maxWidth:"150px",height:"150px"}})}))})}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("../../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("framer-motion");exports.default=({data:r})=>{const{colors:o}=i.usePickaxeContext();return e.jsxs(t.motion.a,Object.assign({initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.3},whileHover:{scale:1.02},whileTap:{scale:.98},style:{display:"flex",flexDirection:"column",backgroundColor:o.primary,color:o.text,borderRadius:"15px 15px 15px 10px",overflow:"hidden",minHeight:r.image?"145px":"auto",maxWidth:"220px",width:"100%"},href:r.href,target:"_blank",rel:"noopener noreferrer"},{children:[!!r.image&&e.jsx("div",{style:{backgroundImage:`url("${r.image}")`,backgroundSize:"cover",backgroundPosition:"center",flex:1}}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"0.2rem",fontSize:"14px",padding:"0.25rem 1rem"}},{children:[e.jsx("p",Object.assign({style:{fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:r.title})),e.jsx("p",Object.assign({style:{fontWeight:350,opacity:.6,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:r.description||"No description found"}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),r=require("react-markdown"),s=require("remark-gfm"),n=require("remark-math"),l=require("rehype-katex"),d=require("./Custom/A/index.js"),a=require("./Custom/P/index.js"),o=require("./Custom/Img/index.js"),c=require("./Custom/Iframe/index.js"),h=require("./Custom/Code/index.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),r=require("react-markdown"),s=require("remark-gfm"),n=require("remark-math"),l=require("rehype-katex"),d=require("./Custom/A/index.js"),a=require("./Custom/P/index.js"),o=require("./Custom/Img/index.js"),c=require("./Custom/Iframe/index.js"),h=require("./Custom/Code/index.js"),u=require("./Custom/common/LinkPreview.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=m(r),x=m(s),g=m(n),f=m(l);exports.PickaxeMarkdownRenderer=({className:r,style:s,value:n,recursion:l=!1})=>{const{theme:m,websiteMetadatas:p}=t.usePickaxeMarkdownContext(),b=i.useRef(null),y={h1:({node:i,children:t})=>e.jsx("h1",Object.assign({style:{fontSize:"2.25rem",lineHeight:"2.5rem"}},{children:t})),h2:({node:i,children:t})=>e.jsx("h2",Object.assign({style:{fontSize:"1.875rem",lineHeight:"2.25rem"}},{children:t})),h3:({node:i,children:t})=>e.jsx("h3",Object.assign({style:{fontSize:"1.5rem",lineHeight:"2rem"}},{children:t})),h4:({node:i,children:t})=>e.jsx("h4",Object.assign({className:"mt-2 text-xl",style:{fontSize:"1.25rem",lineHeight:"1.75rem"}},{children:t})),h5:({node:i,children:t})=>e.jsx("h5",Object.assign({style:{fontSize:"1.125rem",lineHeight:"1.75rem"}},{children:t})),p:a.default,a:d.default,ol:({node:i,children:t})=>e.jsx("ol",Object.assign({style:{listStyleType:"decimal",listStylePosition:"inside",paddingLeft:"1.5rem"}},{children:t})),ul:({node:i,children:t})=>e.jsx("ul",Object.assign({style:{listStyleType:"disc",listStylePosition:"inside",paddingLeft:"1.5rem"}},{children:t})),li:({node:i,children:t})=>e.jsx("li",{children:t}),table:({children:i})=>e.jsx("div",Object.assign({className:"overflow-auto"},{children:e.jsx("table",Object.assign({style:{tableLayout:"fixed",fontSize:"0.875rem",lineHeight:"1.24rem"}},{children:i}))})),th:({node:i,children:t})=>e.jsx("th",Object.assign({style:{padding:"0.75em 1em",fontWeight:600,textAlign:"left"}},{children:t})),tr:({node:i,children:t})=>e.jsx("tr",Object.assign({style:{border:"dark"===m?"1px solid #30363D":"1px solid #D0D7DE"}},{children:t})),td:({node:i,children:t})=>e.jsx("td",Object.assign({style:{padding:"0.75em 1em"}},{children:t})),code:h.default,blockquote:({node:i,children:t})=>e.jsx("blockquote",Object.assign({style:{lineHeight:"15px",borderLeft:"dark"===m?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===m?"#8B8B8B":"#656D76",paddingLeft:"1rem",marginBottom:"1rem"}},{children:t})),img:o.default,iframe:c.default};return e.jsxs("div",Object.assign({className:"pxe-markdown",ref:b,style:Object.assign({position:"relative",whiteSpace:"pre-wrap"},s)},{children:[e.jsx(j.default,Object.assign({},r&&{className:r},{components:y,remarkPlugins:[x.default,g.default],rehypePlugins:[f.default]},{children:(null!=n?n:"").replace(/\u200B/g,"")})),!l&&p.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem"}},{children:p.map(((i,t)=>e.jsx(u.default,{data:i},t)))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react");const r=o.createContext({}),t=({children:t,theme:n="light",syntaxTheme:a,accentColor:c="#228DD7",linkPreviews:l=!1,actions:i=!1})=>{const[s,d]=o.useState(n),[p,u]=o.useState(c),[C,F]=o.useState([]),[g,m]=o.useState(l),[h,b]=o.useState(i);return e.jsx(r.Provider,Object.assign({value:{theme:s,syntaxTheme:a||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},accentColor:p,websiteMetadatas:C,linkPreviews:g,actions:h,setTheme:d,setAccentColor:u,setWebsiteMetadatas:F,setLinkPreviews:m,setActions:b}},{children:t}))};exports.PickaxeMarkdown=t,exports.PickaxeMarkdownContext=r,exports.default=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),
|
|
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:t,file:n,isKnowledge:i,isBlocking:r})=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,c;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=n.name.split(".").pop(),a=n.type,_=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?formid=${s}&mimetype=${a}&extension=${d}`),l=yield _.json();if(!l.success)throw new Error(null!==(e=l.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const p=new FormData;Object.entries(Object.assign(Object.assign({},l.fields),{file:n})).forEach((([e,s])=>{p.append(e,s)}));const u=yield fetch(l.url,{method:"POST",body:p});if(!u.ok)throw new Error(u.statusText);const O=`${l.url}${l.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",O),a.startsWith("image"))return{success:!0,documentId:`IMAGE-${l.documentId}-${l.folder}`};const g=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:l.documentId}),t&&{responseId:t}),{fileName:n.name,fileSize:n.size}),i&&{isKnowledge:i}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),f=yield g.json();if(!f.success)throw new Error(null!==(c=f.error)&&void 0!==c?c:"Failed processing document, try again or contact support.");return f})),website:({formId:o,workspaceId:t,responseId:n,website:i,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},t&&{workspaceId:t}),{documentId:d}),n&&{responseId:n}),{website:i}),r&&{isKnowledge:r}),c&&{isBlocking:c})),headers:{"Content-Type":"application/json"}}),_=yield a.json();if(!_.success)throw new Error(null!==(e=_.error)&&void 0!==e?e:"Failed processing website, try again or contact support.");return _}))});
|
|
@@ -3,9 +3,10 @@ interface PickaxeMarkdownRendererProps {
|
|
|
3
3
|
className?: string;
|
|
4
4
|
style?: CSSProperties;
|
|
5
5
|
value?: string | null;
|
|
6
|
+
recursion?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export type Node = {
|
|
8
9
|
node?: any;
|
|
9
10
|
};
|
|
10
|
-
export declare const PickaxeMarkdownRenderer: ({ className, style, value, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const PickaxeMarkdownRenderer: ({ className, style, value, recursion, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const usePickaxeMarkdownContext: () => {
|
|
3
|
-
theme
|
|
4
|
-
syntaxTheme
|
|
5
|
-
accentColor
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
theme: import("..").PickaxeMarkdownTheme;
|
|
4
|
+
syntaxTheme: Record<string, import("react").CSSProperties>;
|
|
5
|
+
accentColor: string;
|
|
6
|
+
websiteMetadatas: import("..").WebsiteMetadata[];
|
|
7
|
+
linkPreviews: boolean;
|
|
8
|
+
actions: boolean;
|
|
9
|
+
setTheme: import("../../../../../types/common").SetState<import("..").PickaxeMarkdownTheme>;
|
|
10
|
+
setAccentColor: import("../../../../../types/common").SetState<string>;
|
|
11
|
+
setWebsiteMetadatas: import("../../../../../types/common").SetState<import("..").WebsiteMetadata[]>;
|
|
12
|
+
setLinkPreviews: import("../../../../../types/common").SetState<boolean>;
|
|
13
|
+
setActions: import("../../../../../types/common").SetState<boolean>;
|
|
12
14
|
};
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import type { SetState } from "../../../../types/common";
|
|
2
2
|
import { type CSSProperties, type ReactNode } from "react";
|
|
3
3
|
export type PickaxeMarkdownTheme = "light" | "dark";
|
|
4
|
+
export type WebsiteMetadata = {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
image: string;
|
|
8
|
+
href: string;
|
|
9
|
+
};
|
|
4
10
|
type PickaxeMarkdownContextType = {
|
|
5
|
-
theme
|
|
6
|
-
syntaxTheme
|
|
7
|
-
accentColor
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
theme: PickaxeMarkdownTheme;
|
|
12
|
+
syntaxTheme: Record<string, CSSProperties>;
|
|
13
|
+
accentColor: string;
|
|
14
|
+
websiteMetadatas: WebsiteMetadata[];
|
|
15
|
+
linkPreviews: boolean;
|
|
16
|
+
actions: boolean;
|
|
17
|
+
setTheme: SetState<PickaxeMarkdownTheme>;
|
|
18
|
+
setAccentColor: SetState<string>;
|
|
19
|
+
setWebsiteMetadatas: SetState<WebsiteMetadata[]>;
|
|
20
|
+
setLinkPreviews: SetState<boolean>;
|
|
21
|
+
setActions: SetState<boolean>;
|
|
14
22
|
};
|
|
15
23
|
interface PickaxeMarkdownProps {
|
|
16
24
|
children: ReactNode;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
export declare const useSubmitDocument: () => {
|
|
2
|
-
document: (file
|
|
2
|
+
document: ({ formId, workspaceId, responseId, file, isKnowledge, isBlocking, }: {
|
|
3
|
+
formId: string;
|
|
4
|
+
workspaceId?: string | undefined;
|
|
5
|
+
responseId?: string | undefined;
|
|
6
|
+
file: File;
|
|
7
|
+
isKnowledge?: boolean | undefined;
|
|
8
|
+
isBlocking?: boolean | undefined;
|
|
9
|
+
}) => Promise<{
|
|
3
10
|
success: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
documentId: string;
|
|
12
|
+
chunkCount?: number;
|
|
13
|
+
error?: string;
|
|
6
14
|
}>;
|
|
7
|
-
website: (website
|
|
15
|
+
website: ({ formId, workspaceId, responseId, website, isKnowledge, isBlocking, }: {
|
|
16
|
+
formId: string;
|
|
17
|
+
workspaceId?: string | undefined;
|
|
18
|
+
responseId?: string | undefined;
|
|
19
|
+
website: string;
|
|
20
|
+
isKnowledge?: boolean | undefined;
|
|
21
|
+
isBlocking?: boolean | undefined;
|
|
22
|
+
}) => Promise<{
|
|
8
23
|
success: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
documentid: string;
|
|
12
|
-
name: string;
|
|
13
|
-
call_id: string;
|
|
24
|
+
documentId: string;
|
|
25
|
+
chunkCount?: number | undefined;
|
|
14
26
|
error?: string | undefined;
|
|
15
27
|
}>;
|
|
16
28
|
};
|
|
@@ -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 n}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as s}from"./useDocumentContext.js";import{allowedFileMimeTypes as i,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import a from"../../../../../common/error.js";const
|
|
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 n}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as s}from"./useDocumentContext.js";import{allowedFileMimeTypes as i,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import a from"../../../../../common/error.js";const d=["gpt-4o","gpt-4o-mini"],u=({onQuestionChange:u}={})=>{const{formId:l,chatId:m,pickaxe:c}=o(),p=s(),f=n(),h=t((()=>{var e;return d.includes(null!==(e=null==c?void 0:c.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[c]);return Object.assign(Object.assign({},p),{isImageUploadAllowed:h,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(p.setDocumentError(""),!t.length)return null;const e=t[0];try{const o=[...i,...h?r:[]],n=t.some((e=>!o.includes(e.type)));if(n){throw new Error(h?"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.")}p.setIsUploading(!0),p.setIsShowList(!0),p.upsertDocuments([{type:"document",id:e.name,name:e.name,status:"uploading"}]);const s=yield f.document({formId:l,responseId:m,file:e}),{success:a,documentId:d,error:c}=s;if(!a)throw new Error(null!=c?c:"Document processing failed, please try again.");null==u||u({input:e.name,documentId:d});const y=d.startsWith("IMAGE-")?"image":"document";return p.upsertDocuments([{type:y,id:e.name,name:e.name,status:"finished",documentId:d}]),{type:y,id:e.name,name:e.name,status:"finished",documentId:d}}catch(t){const o=a(t);return console.log("[onFileUpload] Error",o),o.includes("You can only upload")?(p.setDocumentError(o),null):(p.editDocument({type:"document",id:e.name,name:e.name,status:"failed",error:o}),{type:"document",id:e.name,name:e.name,status:"failed",error:o})}finally{p.setIsUploading(!1)}})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){p.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.");p.setIsUploading(!0),p.setIsShowList(!0),p.setWebsiteLink(""),p.upsertDocuments([{type:"website",id:e,name:e,status:"uploading"}]);const t=yield f.website({formId:l,responseId:m,website:e}),{success:o,documentId:n}=t;if(!o)throw new Error("Website processing failed, please try again.");return p.upsertDocuments([{type:"website",id:e,name:e,status:"finished",documentId:n}]),{type:"website",id:e,name:e,status:"finished",documentId:n}}catch(t){const o=a(t);return console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL")?(p.setDocumentError(o),null):(p.editDocument({type:"website",id:e,name:e,status:"failed",error:o}),{type:"website",id:e,name:e,status:"failed",error:o})}finally{p.setIsUploading(!1)}})),onEditDocumentByDocId:p.editDocumentByDocId})};export{u as useDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{useEffect as r}from"react";import{useQuery as o}from"@tanstack/react-query";import{usePickaxeMarkdownContext as s}from"../../hooks/usePickaxeMarkdownContext.js";import n from"../common/Action.js";import i from"../Img/index.js";import a from"../../../../../../common/api/utils.js";import c from"../../../../../../common/error.js";const l=({node:l,href:m="",children:u})=>{const{accentColor:d,websiteMetadatas:f,linkPreviews:p,actions:h,setWebsiteMetadatas:w}=s(),b=m.startsWith("http://")?`https://${m.slice(7)}`:m.startsWith("www.")?`https://${m}`:m;o({queryKey:[b],queryFn:()=>(t=>e(void 0,void 0,void 0,(function*(){try{if("development"===process.env.NODE_ENV&&console.log("[getWebsiteMetadata]",t),!t)return null;if(!t.startsWith("https"))return null;const e=["/api/function_call_results","/api/fn/result","https://prod-pickaxe-assets.s3.amazonaws.com"];if(t.includes("pickaxe")&&e.some((e=>t.includes(e))))return null;const r=(yield a.get(`/metadata?url=${encodeURIComponent(t)}`)).data;if(r.error)throw new Error(r.error||"Failed to fetch metadata");return r}catch(e){const t=c(e);return"development"===process.env.NODE_ENV&&console.error("[getJobResult]",t),null}})))(b),enabled:"undefined"!=typeof window&&p&&!!b&&!f.some((e=>e.href===b)),retry:2,onSuccess:t=>e(void 0,void 0,void 0,(function*(){t&&(f.some((e=>e.href===t.href))||w((e=>[...e,t])))}))}),r((()=>{p&&b&&f.some((e=>e.href===b))}),[p,b,f]);const g=b.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(g&&(null==g?void 0:g[1]))return t("div",Object.assign({style:{marginTop:"2rem",marginBottom:"2rem",display:"flex",width:"100%",justifyContent:"center"}},{children:t("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${g[1]}`,style:{width:"100%",maxWidth:"560px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));return b.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif)$/)?t(i,{src:b,alt:"string"==typeof u?u:"Markdown Image"}):h&&b.includes("pickaxe")&&(b.includes("/api/fn/result")||b.includes("/api/function_call_results"))?t(n,{jobUrl:b}):t("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:d,fontWeight:600}},{children:u}))};export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o}from"../../../../../../_virtual/_tslib.js";import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as i}from"react";import{usePickaxeMarkdownContext as t}from"../../hooks/usePickaxeMarkdownContext.js";import{useHover as n}from"../../../../../../hooks/core/useHover.js";import{motion as s}from"framer-motion";import{getContrastColor as a}from"../../../../../../common/utils.js";import l from"../../../../../Icons/download.svg.js";import d from"../../../PickaxeCopyButton.js";import p from"./ImgModal.js";const c=({node:c,src:m,alt:b})=>{const{accentColor:h}=t(),[g,x]=i(!1),[u,f]=i(!1),k=n(),{isHover:w}=k,y=o(k,["isHover"]),v={hidden:{opacity:0,y:-10,pointerEvents:"none"},visible:{opacity:1,y:0,pointerEvents:"auto"}},j=()=>e("div",Object.assign({style:{position:"relative"}},{children:[e(s.div,Object.assign({initial:"hidden",animate:w?"visible":"hidden",variants:v,style:{position:"absolute",display:"flex",gap:"0.4rem",top:"10px",right:"10px",color:"#FFF"}},{children:[r(s.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:h+"07"},whileHover:{backgroundColor:h
|
|
1
|
+
import{__rest as o}from"../../../../../../_virtual/_tslib.js";import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as i}from"react";import{usePickaxeMarkdownContext as t}from"../../hooks/usePickaxeMarkdownContext.js";import{useHover as n}from"../../../../../../hooks/core/useHover.js";import{motion as s}from"framer-motion";import{getContrastColor as a}from"../../../../../../common/utils.js";import l from"../../../../../Icons/download.svg.js";import d from"../../../PickaxeCopyButton.js";import p from"./ImgModal.js";const c=({node:c,src:m,alt:b})=>{const{accentColor:h}=t(),[g,x]=i(!1),[u,f]=i(!1),k=n(),{isHover:w}=k,y=o(k,["isHover"]),v={hidden:{opacity:0,y:-10,pointerEvents:"none"},visible:{opacity:1,y:0,pointerEvents:"auto"}},j=()=>e("div",Object.assign({style:{position:"relative"}},{children:[e(s.div,Object.assign({initial:"hidden",animate:w?"visible":"hidden",variants:v,style:{position:"absolute",display:"flex",gap:"0.4rem",top:"10px",right:"10px",color:"#FFF"}},{children:[r(s.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:h+"07"},whileHover:{backgroundColor:h},whileTap:{scale:.95},onClick:o=>{o.stopPropagation(),window.open(m,"_blank")}},{children:r(l,{width:24,height:24,style:{color:a(h),flexShrink:0}})})),r(s.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:h+"07"},whileHover:{backgroundColor:h},whileTap:{scale:.95},onClick:o=>o.stopPropagation()},{children:r(d,{color:a(h),iconClassName:"w-6 h-6",text:m||""})}))]})),r("img",{src:m,alt:b,style:{borderRadius:"8px",width:"100%",transition:"box-shadow 0.3s ease",boxShadow:w?"inset 0px 4px 10px rgba(0, 0, 0, 0.5)":"none"},onError:()=>x(!0),onClick:()=>f(!0)})]}));return e("div",Object.assign({style:{marginTop:"2rem",marginBottom:"2rem",display:"flex",width:"100%",justifyContent:"center",overflow:"hidden",borderRadius:"8px",transition:"transform 0.3s ease, box-shadow 0.3s ease",transform:w?"translateY(-5px)":"translateY(0)"}},y,{children:[g?r("p",Object.assign({style:{userSelect:"none",opacity:.5,fontStyle:"italic"}},{children:"[Image link is broken]"})):r(j,{}),u&&r(p,Object.assign({isOpen:u,onChangeIsOpen:f},{children:r(j,{})}))]}))};export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n}from"react";import{useQuery as a}from"@tanstack/react-query";import{usePickaxeMarkdownContext as
|
|
1
|
+
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n}from"react";import{useQuery as a}from"@tanstack/react-query";import{usePickaxeMarkdownContext as c}from"../../hooks/usePickaxeMarkdownContext.js";import{loaderBlack as d}from"../../../../../../common/lotties/loader-black.js";import{loaderWhite as s}from"../../../../../../common/lotties/loader-white.js";import{streamer as l}from"../../../../../../common/api/streamer.js";import{PickaxeLottie as m}from"../../../PickaxeLottie.js";import{PickaxeMarkdownRenderer as p}from"../../Renderer.js";import{AnimatePresence as u,motion as f}from"framer-motion";import v from"../../../../../../common/api/utils.js";import y from"../../../../../../common/error.js";const h=({jobUrl:h})=>{var j,b,g,x;const{theme:k}=c(),[w,O]=r(""),[F,N]=r(""),E=n(null),I=a({queryKey:[h],queryFn:()=>(o=>e(void 0,void 0,void 0,(function*(){try{if(!o||o.includes("undefined"))throw new Error("Invalid action job URL");const e=yield fetch(o);return yield e.json()}catch(e){const o=y(e);return"development"===process.env.NODE_ENV&&console.error("[getJobResult]",o),{success:!1,error:o}}})))(h),enabled:"undefined"!=typeof window,retry:10,onSuccess:o=>e(void 0,void 0,void 0,(function*(){try{if(N(""),!o.success)return;if("text"in o)return void O(o.text||"");if(!("fcid"in o)){const e=(yield l({formId:o.formId,responseId:o.responseId,data:o.encodedData})).body;if(!e)return;let t=!0,i="";const r=e.getReader(),n=new TextDecoder;for(;t;){const{value:e,done:o}=yield r.read();t=!o;i+=n.decode(e),O(i)}return O(i),yield v.post("/fn/update",{id:o.jobId,data:Object.assign(Object.assign({},o),{text:i})}),void console.log("[Action] streaming done")}yield new Promise((e=>setTimeout(e,3e3))),I.refetch(),"development"===process.env.NODE_ENV&&console.log(`[Action] refetching <${h}>`)}catch(e){N(y(e))}}))});return o("div",Object.assign({ref:E,className:"pxe-action"},{children:o(u,{children:F||I.error||(null===(j=I.data)||void 0===j?void 0:j.error)?t(f.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"mt-4"},{children:[o("blockquote",Object.assign({style:{lineHeight:"20px",borderLeft:"4px solid #FF0000",color:"#FF0000",paddingLeft:"1rem",marginBottom:"1rem"}},{children:F||(null===(b=I.data)||void 0===b?void 0:b.error)||"Failed to process, please try again."})),(null===(g=I.data)||void 0===g?void 0:g.traceback)&&t(i,{children:[t("p",Object.assign({style:{color:"#FF0000"}},{children:["Traceback:"," "]})),o(p,{value:`\`\`\`js\n${null===(x=I.data)||void 0===x?void 0:x.traceback}\n\`\`\``,recursion:!0})]})]})):o(f.div,w?Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"mt-4"},{children:o(p,{value:w,recursion:!0})}):Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:o(m,{id:"dark"===k?"loader-white":"loader-black",getJson:()=>e(void 0,void 0,void 0,(function*(){return"dark"===k?s:d})),autoplay:!0,loop:!0,style:{cursor:"default",pointerEvents:"none",width:"100%",maxWidth:"150px",height:"150px"}})}))})}))};export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as e,jsx as i}from"react/jsx-runtime";import{usePickaxeContext as o}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";import{motion as t}from"framer-motion";const r=({data:r})=>{const{colors:a}=o();return e(t.a,Object.assign({initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.3},whileHover:{scale:1.02},whileTap:{scale:.98},style:{display:"flex",flexDirection:"column",backgroundColor:a.primary,color:a.text,borderRadius:"15px 15px 15px 10px",overflow:"hidden",minHeight:r.image?"145px":"auto",maxWidth:"220px",width:"100%"},href:r.href,target:"_blank",rel:"noopener noreferrer"},{children:[!!r.image&&i("div",{style:{backgroundImage:`url("${r.image}")`,backgroundSize:"cover",backgroundPosition:"center",flex:1}}),e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"0.2rem",fontSize:"14px",padding:"0.25rem 1rem"}},{children:[i("p",Object.assign({style:{fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:r.title})),i("p",Object.assign({style:{fontWeight:350,opacity:.6,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:r.description||"No description found"}))]}))]}))};export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsxs as e,jsx as i}from"react/jsx-runtime";import{useRef as t}from"react";import{usePickaxeMarkdownContext as r}from"./hooks/usePickaxeMarkdownContext.js";import n from"react-markdown";import l from"remark-gfm";import s from"remark-math";import o from"rehype-katex";import d from"./Custom/A/index.js";import m from"./Custom/P/index.js";import c from"./Custom/Img/index.js";import a from"./Custom/Iframe/index.js";import h from"./Custom/Code/index.js";import g from"./Custom/common/LinkPreview.js";const p=({className:p,style:f,value:b,recursion:j=!1})=>{const{theme:y,websiteMetadatas:u}=r(),x=t(null),O={h1:({node:e,children:t})=>i("h1",Object.assign({style:{fontSize:"2.25rem",lineHeight:"2.5rem"}},{children:t})),h2:({node:e,children:t})=>i("h2",Object.assign({style:{fontSize:"1.875rem",lineHeight:"2.25rem"}},{children:t})),h3:({node:e,children:t})=>i("h3",Object.assign({style:{fontSize:"1.5rem",lineHeight:"2rem"}},{children:t})),h4:({node:e,children:t})=>i("h4",Object.assign({className:"mt-2 text-xl",style:{fontSize:"1.25rem",lineHeight:"1.75rem"}},{children:t})),h5:({node:e,children:t})=>i("h5",Object.assign({style:{fontSize:"1.125rem",lineHeight:"1.75rem"}},{children:t})),p:m,a:d,ol:({node:e,children:t})=>i("ol",Object.assign({style:{listStyleType:"decimal",listStylePosition:"inside",paddingLeft:"1.5rem"}},{children:t})),ul:({node:e,children:t})=>i("ul",Object.assign({style:{listStyleType:"disc",listStylePosition:"inside",paddingLeft:"1.5rem"}},{children:t})),li:({node:e,children:t})=>i("li",{children:t}),table:({children:e})=>i("div",Object.assign({className:"overflow-auto"},{children:i("table",Object.assign({style:{tableLayout:"fixed",fontSize:"0.875rem",lineHeight:"1.24rem"}},{children:e}))})),th:({node:e,children:t})=>i("th",Object.assign({style:{padding:"0.75em 1em",fontWeight:600,textAlign:"left"}},{children:t})),tr:({node:e,children:t})=>i("tr",Object.assign({style:{border:"dark"===y?"1px solid #30363D":"1px solid #D0D7DE"}},{children:t})),td:({node:e,children:t})=>i("td",Object.assign({style:{padding:"0.75em 1em"}},{children:t})),code:h,blockquote:({node:e,children:t})=>i("blockquote",Object.assign({style:{lineHeight:"15px",borderLeft:"dark"===y?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===y?"#8B8B8B":"#656D76",paddingLeft:"1rem",marginBottom:"1rem"}},{children:t})),img:c,iframe:a};return e("div",Object.assign({className:"pxe-markdown",ref:x,style:Object.assign({position:"relative",whiteSpace:"pre-wrap"},f)},{children:[i(n,Object.assign({},p&&{className:p},{components:O,remarkPlugins:[l,s],rehypePlugins:[o]},{children:(null!=b?b:"").replace(/\u200B/g,"")})),!j&&u.length>0&&i("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem"}},{children:u.map(((e,t)=>i(g,{data:e},t)))}))]}))};export{p as PickaxeMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o}from"react/jsx-runtime";import{createContext as e,useState as r}from"react";const n=e({}),t=({children:e,theme:t="light",syntaxTheme:
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{createContext as e,useState as r}from"react";const n=e({}),t=({children:e,theme:t="light",syntaxTheme:a,accentColor:c="#228DD7",linkPreviews:l=!1,actions:i=!1})=>{const[s,d]=r(t),[p,m]=r(c),[C,F]=r([]),[g,h]=r(l),[u,b]=r(i);return o(n.Provider,Object.assign({value:{theme:s,syntaxTheme:a||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},accentColor:p,websiteMetadatas:C,linkPreviews:g,actions:u,setTheme:d,setAccentColor:m,setWebsiteMetadatas:F,setLinkPreviews:h,setActions:b}},{children:e}))};export{t as PickaxeMarkdown,n as PickaxeMarkdownContext,t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{
|
|
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:t,isKnowledge:i,isBlocking:r})=>e(void 0,void 0,void 0,(function*(){var e,c;if(!process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL)throw new Error("NEXT_PUBLIC_MODAL_DOC_APP_URL is not defined");const d=t.name.split(".").pop(),a=t.type,l=yield fetch(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_upload_url?formid=${s}&mimetype=${a}&extension=${d}`),p=yield l.json();if(!p.success)throw new Error(null!==(e=p.error)&&void 0!==e?e:"Failed to get presigned URL, try again or contact support.");const _=new FormData;Object.entries(Object.assign(Object.assign({},p.fields),{file:t})).forEach((([e,s])=>{_.append(e,s)}));const O=yield fetch(p.url,{method:"POST",body:_});if(!O.ok)throw new Error(O.statusText);const g=`${p.url}${p.fields.key}`;if("development"===process.env.NODE_ENV&&console.log("[S3URL]",g),a.startsWith("image"))return{success:!0,documentId:`IMAGE-${p.documentId}-${p.folder}`};const f=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:p.documentId}),n&&{responseId:n}),{fileName:t.name,fileSize:t.size}),i&&{isKnowledge:i}),r&&{isBlocking:r})),headers:{"Content-Type":"application/json"}}),m=yield f.json();if(!m.success)throw new Error(null!==(c=m.error)&&void 0!==c?c:"Failed processing document, try again or contact support.");return m})),website:({formId:o,workspaceId:n,responseId:t,website:i,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}),t&&{responseId:t}),{website:i}),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};
|
|
@@ -3,9 +3,10 @@ interface PickaxeMarkdownRendererProps {
|
|
|
3
3
|
className?: string;
|
|
4
4
|
style?: CSSProperties;
|
|
5
5
|
value?: string | null;
|
|
6
|
+
recursion?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export type Node = {
|
|
8
9
|
node?: any;
|
|
9
10
|
};
|
|
10
|
-
export declare const PickaxeMarkdownRenderer: ({ className, style, value, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const PickaxeMarkdownRenderer: ({ className, style, value, recursion, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const usePickaxeMarkdownContext: () => {
|
|
3
|
-
theme
|
|
4
|
-
syntaxTheme
|
|
5
|
-
accentColor
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
theme: import("..").PickaxeMarkdownTheme;
|
|
4
|
+
syntaxTheme: Record<string, import("react").CSSProperties>;
|
|
5
|
+
accentColor: string;
|
|
6
|
+
websiteMetadatas: import("..").WebsiteMetadata[];
|
|
7
|
+
linkPreviews: boolean;
|
|
8
|
+
actions: boolean;
|
|
9
|
+
setTheme: import("../../../../../types/common").SetState<import("..").PickaxeMarkdownTheme>;
|
|
10
|
+
setAccentColor: import("../../../../../types/common").SetState<string>;
|
|
11
|
+
setWebsiteMetadatas: import("../../../../../types/common").SetState<import("..").WebsiteMetadata[]>;
|
|
12
|
+
setLinkPreviews: import("../../../../../types/common").SetState<boolean>;
|
|
13
|
+
setActions: import("../../../../../types/common").SetState<boolean>;
|
|
12
14
|
};
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import type { SetState } from "../../../../types/common";
|
|
2
2
|
import { type CSSProperties, type ReactNode } from "react";
|
|
3
3
|
export type PickaxeMarkdownTheme = "light" | "dark";
|
|
4
|
+
export type WebsiteMetadata = {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
image: string;
|
|
8
|
+
href: string;
|
|
9
|
+
};
|
|
4
10
|
type PickaxeMarkdownContextType = {
|
|
5
|
-
theme
|
|
6
|
-
syntaxTheme
|
|
7
|
-
accentColor
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
theme: PickaxeMarkdownTheme;
|
|
12
|
+
syntaxTheme: Record<string, CSSProperties>;
|
|
13
|
+
accentColor: string;
|
|
14
|
+
websiteMetadatas: WebsiteMetadata[];
|
|
15
|
+
linkPreviews: boolean;
|
|
16
|
+
actions: boolean;
|
|
17
|
+
setTheme: SetState<PickaxeMarkdownTheme>;
|
|
18
|
+
setAccentColor: SetState<string>;
|
|
19
|
+
setWebsiteMetadatas: SetState<WebsiteMetadata[]>;
|
|
20
|
+
setLinkPreviews: SetState<boolean>;
|
|
21
|
+
setActions: SetState<boolean>;
|
|
14
22
|
};
|
|
15
23
|
interface PickaxeMarkdownProps {
|
|
16
24
|
children: ReactNode;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
export declare const useSubmitDocument: () => {
|
|
2
|
-
document: (file
|
|
2
|
+
document: ({ formId, workspaceId, responseId, file, isKnowledge, isBlocking, }: {
|
|
3
|
+
formId: string;
|
|
4
|
+
workspaceId?: string | undefined;
|
|
5
|
+
responseId?: string | undefined;
|
|
6
|
+
file: File;
|
|
7
|
+
isKnowledge?: boolean | undefined;
|
|
8
|
+
isBlocking?: boolean | undefined;
|
|
9
|
+
}) => Promise<{
|
|
3
10
|
success: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
documentId: string;
|
|
12
|
+
chunkCount?: number;
|
|
13
|
+
error?: string;
|
|
6
14
|
}>;
|
|
7
|
-
website: (website
|
|
15
|
+
website: ({ formId, workspaceId, responseId, website, isKnowledge, isBlocking, }: {
|
|
16
|
+
formId: string;
|
|
17
|
+
workspaceId?: string | undefined;
|
|
18
|
+
responseId?: string | undefined;
|
|
19
|
+
website: string;
|
|
20
|
+
isKnowledge?: boolean | undefined;
|
|
21
|
+
isBlocking?: boolean | undefined;
|
|
22
|
+
}) => Promise<{
|
|
8
23
|
success: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
documentid: string;
|
|
12
|
-
name: string;
|
|
13
|
-
call_id: string;
|
|
24
|
+
documentId: string;
|
|
25
|
+
chunkCount?: number | undefined;
|
|
14
26
|
error?: string | undefined;
|
|
15
27
|
}>;
|
|
16
28
|
};
|