PageSourceSearch

https://boombam.app/assets/company-ai-training-C-Kq5VFg.js

js boombam.app collected 2026-10-04 13:32:54 UTC 19,875 bytes, 1 lines download raw bytes

1import{_ as ge,a5 as je,N as ye,r as c,a as fe,a6 as p,j as e,n as k,C as P,b as L,d as A,bh as be,e as E,o as z,aY as R,S as K,ab as v,aF as O,B as h,Z as g,ap as ve,F as Q,s as Ne,au as we,a7 as u,be as Ce,h as Te,f as Se}from"./index-CuSEeJFb.js";import{P as Ue}from"./progress-B2eMqtVV.js";import{T as Fe,a as Ie,b as j,c as y}from"./tabs-CcPOXtvT.js";import{U as G}from"./upload-rep3KVPL.js";import{V as J}from"./video-AMZtj4XD.js";import{C as X}from"./cloud-D2eg2POy.js";function Re(){const{toast:a}=ge(),x=je(),{activeCompanyId:d}=ye(),[m,W]=c.useState(""),[f,V]=c.useState(""),[i,q]=c.useState(""),[l,M]=c.useState(""),[N,w]=c.useState(!1),[C,T]=c.useState(!1),[S,U]=c.useState(!1),[F,I]=c.useState(!1),[b,D]=c.useState(!1),{data:n,isLoading:H}=fe({queryKey:["/api/company-ai/training-data",{companyId:d}],enabled:!!d,staleTime:0,refetchOnMount:"always",refetchInterval:s=>{var r;return((r=s==null?void 0:s.documents)==null?void 0:r.some(o=>o.status==="processing"))?5e3:!1}}),Z=p({mutationFn:async s=>await u("/api/company-ai/upload-website",{method:"POST",body:JSON.stringify({url:s})}),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/company-ai/training-data",{companyId:d}]}),W(""),w(!1),a({title:"Website Added Successfully",description:"Your website content is being processed for AI training."})},onError:s=>{w(!1),a({title:"Upload Failed",description:s.message||"Failed to upload website content.",variant:"destructive"})}}),_=p({mutationFn:async s=>await u("/api/company-ai/upload-text",{method:"POST",body:JSON.stringify({content:s})}),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/company-ai/training-data",{companyId:d}]}),V(""),T(!1),a({title:"Text Added Successfully",description:"Your custom text is being processed for AI training."})},onError:s=>{T(!1),a({title:"Upload Failed",description:s.message||"Failed to upload text content.",variant:"destructive"})}}),ee=p({mutationFn:async s=>await u("/api/company-ai/extract-video-captions",{method:"POST",body:JSON.stringify({url:s})}),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/company-ai/training-data",{companyId:d}]}),q(""),U(!1),a({title:"Video Captions Extracted",description:"Video captions have been processed for AI training."})},onError:s=>{U(!1),a({title:"Extraction Failed",description:s.message||"Failed to extract video captions.",variant:"destructive"})}}),$=p({mutationFn:async s=>await u(`/api/company-ai/documents/${s}`,{method:"DELETE"}),onSuccess:async()=>{await x.refetchQueries({queryKey:["/api/company-ai/training-data",{companyId:d}]}),a({title:"Document Removed",description:"The document has been removed from your AI training."})},onError:s=>{a({title:"Delete Failed",description:s.message||"Failed to remove document.",variant:"destructive"})}}),se=async()=>{if(!m.trim()){a({title:"URL Required",description:"Please enter a website URL.",variant:"destructive"});return}try{new URL(m.startsWith("http")?m:`https://${m}`)}catch{a({title:"Invalid URL",description:"Please enter a valid website URL.",variant:"destructive"});return}w(!0),Z.mutate(m)},te=async()=>{if(!f.trim()){a({title:"Text Required",description:"Please enter some text content.",variant:"destructive"});return}T(!0),_.mutate(f)},ae=async()=>{if(!i.trim()){a({title:"Video URL Required",description:"Please enter a video URL.",variant:"destructive"});return}try{new URL(i.startsWith("http")?i:`https://${i}`)}catch{a({title:"Invalid URL",description:"Please enter a valid video URL.",variant:"destructive"});return}const s=["youtube.com","youtu.be","vimeo.com"],t=new URL(i.startsWith("http")?i:`https://${i}`);if(!s.some(o=>t.hostname.includes(o))){a({title:"Unsupported Platform",description:"Currently supports YouTube and Vimeo videos with captions.",variant:"destructive"});return}U(!0),ee.mutate(i)},ne=p({mutationFn:async s=>await u("/api/company-ai/extract-cloud-content",{method:"POST",body:JSON.stringify({url:s})}),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/company-ai/training-data",{companyId:d}]}),M(""),I(!1),a({title:"Cloud Content Extracted",description:"Cloud storage content has been processed for AI training."})},onError:s=>{I(!1),a({title:"Extraction Failed",description:s.message||"Failed to extract cloud storage content.",variant:"destructive"})}}),re=async()=>
1{if(!l.trim()){a({title:"Cloud URL Required",description:"Please enter a Google Drive or Dropbox share URL.",variant:"destructive"});return}try{new URL(l.startsWith("http")?l:`https://${l}`)}catch{a({title:"Invalid URL",description:"Please enter a valid cloud storage URL.",variant:"destructive"});return}const s=["drive.google.com","docs.google.com","sheets.google.com","dropbox.com"],t=new URL(l.startsWith("http")?l:`https://${l}`);if(!s.some(o=>t.hostname.includes(o))){a({title:"Unsupported Platform",description:"Currently supports Google Drive and Dropbox shareable links.",variant:"destructive"});return}I(!0),ne.mutate(l)},ie=async s=>{var r;const t=(r=s.target.files)==null?void 0:r[0];t&&(await B(t),s.target.value="")},B=async s=>{const t=new FormData;t.append("file",s);try{const r=await u("/api/company-ai/upload-file",{method:"POST",body:t});x.invalidateQueries({queryKey:["/api/company-ai/training-data",{companyId:d}]}),a({title:"File Uploaded Successfully",description:"Your file is being processed for AI training."})}catch(r){a({title:"Upload Failed",description:r.message||"Failed to upload file.",variant:"destructive"})}},le=s=>{s.preventDefault(),s.stopPropagation(),D(!0)},oe=s=>{s.preventDefault(),s.stopPropagation(),D(!1)},ce=s=>{s.preventDefault(),s.stopPropagation()},de=async s=>{var r;s.preventDefault(),s.stopPropagation(),D(!1);const t=Array.from(s.dataTransfer.files);if(t.length>0){const o=t[0],pe=[".pdf",".doc",".docx",".txt"],he="."+((r=o.name.split(".").pop())==null?void 0:r.toLowerCase());if(!pe.includes(he)){a({title:"Invalid File Type",description:"Please upload PDF, DOC, DOCX, or TXT files only.",variant:"destructive"});return}if(o.size>10*1024*1024){a({title:"File Too Large",description:"Please upload files smaller than 10MB.",variant:"destructive"});return}await B(o)}},me=s=>{switch(s){case"completed":return"bg-green-100 text-green-800";case"processing":return"bg-yellow-100 text-yellow-800";case"failed":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},xe=s=>{switch(s){case"completed":return e.jsx(Se,{className:"h-4 w-4"});case"processing":return e.jsx(g,{className:"h-4 w-4 animate-pulse"});case"failed":return e.jsx(Te,{className:"h-4 w-4"});default:return e.jsx(Ce,{className:"h-4 w-4"})}},ue=s=>{if(!s)return"Unknown size";const t=s/1024;return t<1024?`${t.toFixed(1)} KB`:`${(t/1024).toFixed(1)} MB`},Y=()=>{if(!(n!=null&&n.stats))return 0;const{trainingStatus:s}=n.stats;switch(s){case"complete":return 100;case"partial":return 60;case"untrained":return 0;default:return 0}};return H?e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center min-h-96",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-orange-500 border-t-transparent rounded-full mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Loading AI training data..."})]})})}):e.jsxs("div",{className:"p-4 sm:p-6 max-w-6xl mx-auto space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"mb-4 sm:mb-8",children:[e.jsxs("h1",{className:"text-xl sm:text-2xl lg:text-3xl font-bold text-gray-900 mb-2 flex items-center gap-2 sm:gap-3",children:[e.jsx(k,{className:"h-6 sm:h-8 w-6 sm:w-8 text-orange-500"}),"Train your AI"]}),e.jsx("p",{className:"text-gray-600 text-sm sm:text-base lg:text-lg",children:"Enhance your company's AI with your business knowledge and content."})]}),e.jsxs(P,{className:"border-orange-200 bg-gradient-to-r from-orange-50 to-amber-50",children:[e.jsx(L,{className:"pb-3 sm:pb-6",children:e.jsxs(A,{className:"flex items-center gap-2 text-base sm:text-lg",children:[e.jsx(be,{className:"h-4 sm:h-5 w-4 sm:w-5 text-orange-600"}),"AI Training Status"]})}),e.jsxs(E,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 sm:gap-4 mb-3 sm:mb-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg sm:text-xl lg:text-2xl font-bold text-orange-600",children:(n==null?void 0:n.stats.totalDocuments)||0}),e.jsx("div",{className:"text-xs sm:text-sm text-gray-600",children:"Documents"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg sm:text-xl lg:text-2xl font-bold text-orange-600",children:n!=null&&n.stats.totalWords?n.stats.totalWords>999?`${Math.floor(n.stats.totalWords/1e3)}K`:n.stats.totalWords:0}),e.jsx("div",{className:"text-xs sm:text-sm text-gray-600",children:"Words"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-lg sm:text-xl lg:text-2xl font-bold text-orange-600",children:[Y(),"%"]}),e.jsx("div",{className:"text-xs sm:text-sm text-gray-600",children:"Complete"})]})]}),e.jsx(Ue,{value:Y(),className:"h-1.5 sm:h-2"}),(n==null?void 0:n.stats.lastUpdated)&&e.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Updated: ",new Date(n.stats.lastUpdated).toLocaleDateString()]})]})]}),e.jsxs(P,{children:[e.jsxs(L,{children:[e.jsxs(A,{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5 text-orange-600"}),"Add Training Content"]}),e.jsx(z,{children:"Choose how you want to add content to train your AI assistant"})]}),e.jsx(E,{className:"px-3 sm:px-6",children:e.jsxs(Fe,{defaultValue:"website",className:"w-full",children:[e.jsx("div",{className:"overflow-x-auto -mx-3 px-3 sm:-mx-6 sm:px-6 md:mx-0 md:px-0",children:e.jsxs(Ie,{className:"inline-flex h-auto min-w-full md:grid md:grid-cols-5 bg-muted p-1 rounded-lg",children:[e.jsxs(j,{value:"website",className:"flex-1 md:flex items-center justify-center gap-1 sm:gap-2 px-2 sm:px-3 py-2 whitespace-nowrap",children:[e.jsx(R,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs sm:text-sm",children:"Website"})]}),e.jsxs(j,{value:"text",className:"flex-1 md:flex items-center justify-center gap-1 sm:gap-2 px-2 sm:px-3 py-2 whitespace-nowrap",children:[e.jsx(K,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs sm:text-sm",children:"Text"})]}),e.jsxs(j,{value:"document",className:"flex-1 md:flex items-center justify-center gap-1 sm:gap-2 px-2 sm:px-3 py-2 whitespace-nowrap",children:[e.jsx(G,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs sm:text-sm",children:"Document"})]}),e.jsxs(j,{value:"video",className:"flex-1 md:flex items-center justify-center gap-1 sm:gap-2 px-2 sm:px-3 py-2 whitespace-nowrap",children:[e.jsx(J,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs sm:text-sm",children:"Video"})]}),e.jsxs(j,{value:"cloud",className:"flex-1 md:flex items-center justify-center gap-1 sm:gap-2 px-2 sm:px-3 py-2 whitespace-nowrap",children:[e.jsx(X,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs sm:text-sm",children:"Cloud"})]})]})}
1),e.jsx(y,{value:"website",className:"space-y-4 mt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"website-url",children:"Website URL"}),e.jsx(O,{id:"website-url",placeholder:"https://yourcompany.com",value:m,onChange:s=>W(s.target.value),disabled:N})]}),e.jsx(h,{onClick:se,disabled:N||!m.trim(),className:"w-full",children:N?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"h-4 w-4 mr-2 animate-pulse"}),"Analyzing Website..."]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"h-4 w-4 mr-2"}),"Analyze Website"]})}),e.jsx("p",{className:"text-sm text-gray-500",children:"Automatically extract business content, services, and information from your website to train your AI assistant."})]})}),e.jsx(y,{value:"text",className:"space-y-4 mt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"custom-text",children:"Business Content"}),e.jsx(ve,{id:"custom-text",placeholder:"Enter your business information, services, mission statement, or any other relevant content...",value:f,onChange:s=>V(s.target.value),rows:6,disabled:C})]}),e.jsx(h,{onClick:te,disabled:C||!f.trim(),className:"w-full",children:C?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"h-4 w-4 mr-2 animate-pulse"}),"Processing Text..."]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),"Add Text Content"]})}),e.jsx("p",{className:"text-sm text-gray-500",children:"Add specific business information, policies, or content manually to customize your AI's knowledge."})]})}),e.jsx(y,{value:"document",className:"space-y-4 mt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${b?"border-orange-500 bg-orange-50 dark:bg-orange-950":"border-gray-300 hover:border-gray-400"}`,onDragEnter:le,onDragLeave:oe,onDragOver:ce,onDrop:de,children:[e.jsx("input",{type:"file",id:"file-upload",accept:".pdf,.doc,.docx,.txt",onCh
1ange:ie,className:"hidden"}),e.jsxs("label",{htmlFor:"file-upload",className:"cursor-pointer",children:[e.jsx(G,{className:`h-12 w-12 mx-auto mb-4 ${b?"text-orange-500":"text-gray-400"}`}),e.jsx("p",{className:`text-lg mb-2 ${b?"text-orange-600 dark:text-orange-400":"text-gray-600"}`,children:b?"Drop file here":"Click to upload or drag and drop"}),e.jsx("p",{className:"text-sm text-gray-500",children:"PDF, DOC, DOCX, TXT (max 10MB)"})]})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Upload business documents, manuals, or guides that contain important information about your company."})]})}),e.jsx(y,{value:"video",className:"space-y-4 mt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"video-url",children:"Video URL"}),e.jsx(O,{id:"video-url",placeholder:"https://youtube.com/watch?v=...",value:i,onChange:s=>q(s.target.value),disabled:S})]}),e.jsx(h,{onClick:ae,disabled:S||!i.trim(),className:"w-full",children:S?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"h-4 w-4 mr-2 animate-pulse"}),"Extracting Captions..."]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"h-4 w-4 mr-2"}),"Extract Captions"]})}),e.jsx("p",{className:"text-sm text-gray-500",children:"Extract captions from YouTube videos, training materials, or presentations to add their content to your AI's knowledge."}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 mt-3",children:[e.jsx("p",{className:"text-sm text-blue-800 font-medium mb-2",children:"💡 How to Add YouTube Video Content"}),e.jsxs("div",{className:"space-y-2 text-sm text-blue-700",children:[e.jsx("p",{className:"font-medium",children:"Step 1: Get the transcript from YouTube"}),e.jsxs("ol",{className:"list-decimal list-inside ml-2 space-y-1 text-xs",children:[e.jsx("li",{children:"Open your video on YouTube"}),e.jsx("li",{children:'Click the "..." menu below the video'}),e.jsx("li",{children:'Select "Show transcript"'}),e.jsx("li",{children:"Copy all the transcript text"})]}),e.jsx("p",{className:"font-medium mt-3",children:"Step 2: Add to your AI training"}),e.jsx("p",{className:"text-xs ml-2",children:'Switch to the "Text" tab above and paste the transcript there.'})]})]})]})}),e.jsx(y,{value:"cloud",className:"space-y-4 mt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"cloud-url",children:"Cloud Storage URL"}),e.jsx(O,{id:"cloud-url",placeholder:"https://drive.google.com/file/d/... or https://dropbox.com/s/...",value:l,onChange:s=>M(s.target.value),disabled:F})]}),e.jsx(h,{onClick:re,disabled:F||!l.trim(),className:"w-full",children:F?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"h-4 w-4 mr-2 animate-pulse"}),"Processing Content..."]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Extract Content"]})}),e.jsx("p",{className:"text-sm text-gray-500",children:"Extract content from Google Drive documents, sheets, presentations, or Dropbox files. Make sure the link is publicly accessible or shareable."}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 mb-2",children:"Supported Content:"}),e.jsxs("ul",{className:"text-sm text-blue-800 space-y-1",children:[e.jsx("li",{children:"• Google Docs, Sheets, Slides"}),e.jsx("li",{children:"• Google Drive PDFs and text files"}),e.jsx("li",{children:"• Dropbox shared documents"}),e.jsx("li",{children:"• Public or shareable links only"})]})]})]})})]})})]}),e.jsxs(P,{children:[e.jsxs(L,{children:[e.jsx(A,{children:"Training Documents"}),e.jsx(z,{children:"Manage the content that your AI has been trained on"})]}),e.jsx(E,{children:n!=null&&n.documents&&n.documents.length>0?e.jsx("div",{className:"space-y-3",children:n.documents.map(s=>{var t;return e.jsx("div",{className:"p-3 sm:p-4 border rounded-lg",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:s.type==="website"?e.jsx(R,{className:"h-4 sm:h-5 w-4 sm:w-5 text-blue-500"}):s.type==="document"?e.jsx(Q,{className:"h-4 sm:h-5 w-4 sm:w-5 text-green-500"}):e.jsx(Q,{className:"h-4 sm:h-5 w-4 sm:w-5 text-purple-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base text-gray-900 mb-1 truncate",children:s.filename}),e.jsxs("div",{className:"text-xs sm:text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Source:"})," ",s.source||"Unknown",((t=s.metadata)==null?void 0:t.originalUrl)&&e.jsxs("a",{href:s.metadata.originalUrl,target:"_blank",rel:"noopener noreferrer",className:"ml-2 text-blue-500 hover:text-blue-700 hover:underline break-all",children:["(",s.metadata.originalUrl.length>50?s.metadata.originalUrl.substring(0,50)+"...":s.metadata.originalUrl,")"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 text-xs text-gray-500",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Size:"})," ",ue(s.size||0)]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Chunks:"})," ",s.chunkCount||0]}),e.jsxs("div",{className:"col-span-2 sm:col-span-1",children:[e.jsx("span",{className:"font-medium",children:"Tokens:"}
1)," ",(s.totalTokens||0).toLocaleString()]}),e.jsxs("div",{className:"col-span-2 sm:col-span-1",children:[e.jsx("span",{className:"font-medium",children:"Created:"})," ",new Date(s.createdAt||s.uploadedAt||Date.now()).toLocaleDateString()]})]}),s.keyInsights&&s.keyInsights.length>0&&e.jsxs("div",{className:"mt-2 text-xs text-gray-400 hidden sm:block",children:[e.jsx("span",{className:"font-medium",children:"Insights:"})," ",s.keyInsights.filter(Boolean).slice(0,2).join(", "),s.keyInsights.length>2?"...":""]})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx(Ne,{className:`${me(s.status)} border-0 text-xs`,children:e.jsxs("span",{className:"flex items-center gap-1",children:[xe(s.status),e.jsx("span",{className:"hidden sm:inline",children:s.status}),e.jsx("span",{className:"sm:hidden",children:s.status==="completed"?"✓":s.status==="processing"?"...":"!"})]})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>$.mutate(s.id),disabled:$.isPending,className:"h-8 w-8 p-0",children:e.jsx(we,{className:"h-4 w-4 text-red-500"})})]})]})},s.id)})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(k,{className:"h-12 w-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No Training Data Yet"}),e.jsx("p",{className:"text-gray-500",children:"Start by adding website content, uploading documents, or entering custom text above."})]})})]})]})}export{Re as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.