PageSourceSearch

https://graphn.ai/assets/KBCreate-DksxPeuQ.js

js graphn.ai collected 2026-10-05 12:58:01 UTC 7,601 bytes, 1 lines download raw bytes

1import{l as $,r as a,j as e}from"./vendor-react-DtC_VEUo.js";import{s as F}from"./ArrowLeft.es-Ccga8xeh.js";import{h as G,o as P,am as q,an as D,ao as A,ap as H,s as J,aq as V,ar as X}from"./Layout-BDeo5r58.js";import{s as Q}from"./CaretRight.es-CDi70gdz.js";import{m as Y}from"./SpinnerGap.es-B6em60KE.js";import{f as O,H as k}from"./index-BHcE0VsM.js";import{C as K,a as Z,b as ee,c as I}from"./card-BvU4P5j5.js";import{B as w}from"./button-BKWM_XRB.js";import"./auth-redirect-519xYbgh.js";import"./vendor-mui-DOGRGCPu.js";import"./index-BBzAfRJ_.js";import"./frontmatter--9vFRCjG.js";import"./index-BW1YI9Vb.js";import"./utils-CAJzcftR.js";import"./blog-B1140jCW.js";import"./Check.es-yHqOqKZb.js";import"./List.es-BRz05NQr.js";import"./User.es-D95GFoTy.js";import"./lightning-logo-C9q01Enb.js";import"./supportedCodingAgents-1kCjImuc.js";import"./ArrowRight.es-Cj3Au2OZ.js";import"./Play.es-DVCzMQKj.js";import"./modelRates-DUkNloPJ.js";import"./appPaletteStore-C4KZpuNY.js";import"./vendor-posthog-1e9euB4x.js";import"./singleFlight-U_Or92Sz.js";import"./cardSurface-GlPrhl0E.js";function te(r,d){let c="",l="";if(r){const s=Number(r);(isNaN(s)||s<50||s>1e4)&&(c="Must be between 50 and 10,000")}if(d){const s=Number(d);(isNaN(s)||s<0||s>5e3)&&(l="Must be between 0 and 5,000")}if(!c&&!l&&d){const s=Number(d),u=r?Number(r):1e3;s>=u&&(l=r?"Must be less than chunk size":"Must be less than default chunk size (1000)")}return{sizeError:c,overlapError:l}}function _e(){const r=$(),d=G(),{handleCreditError:c}=P(),{activeTutorialId:l,setResource:s}=q(),u=l===V,i=l===X,[h,C]=a.useState(u?D:i?A:""),[y,z]=a.useState(""),[E,S]=a.useState(!1),[g,L]=a.useState(!1),[p,R]=a.useState(""),[x,U]=a.useState(""),[N,T]=a.useState([]),[b,_]=a.useState("");a.useEffect(()=>{const t=u?D:i?A:"";t&&C(n=>n||t)},[u,i]),a.useEffect(()=>{let t=!1;return O.knowledgebases.listModels().then(n=>{if(t)return;T(n.models);const o=(i?n.models.find(m=>m.id===H)??n.models.find(m=>m.supported_inputs.includes("video")):void 0)??n.models.find(m=>m.is_default);o&&_(o.id)}).catch(()=>{t||T([])}),()=>{t=!0}},[i]);const{sizeError:f,overlapError:v}=te(p,x),M=!!(f||v),B=N.find(t=>t.id===b);async function W(t){if(t.preventDefault(),!h.trim()){k.error("Name is required");return}if(M)return;const n=p?Number(p):void 0,j=x?Number(x):void 0;try{S(!0);const o=await O.knowledgebases.create({name:h.trim(),description:y.trim(),...n!=null?{chunk_size:n}:{},...j!=null?{chunk_overlap:j}:{},...b?{embedding_model:b}:{}});k.success("Knowledge base created"),i&&s("kbId",o.id),r(d(`/knowledgebases/${o.id}`))}catch(o){if(c(o))return;k.error(o instanceof Error?o.message:"Failed to create knowledge base")}finally{S(!1)}}return e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(d("/knowledgebases")),children:e.jsx(F,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Create Knowledge Base"}),e.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:"Create a new document collection for semantic search"})]})]}),e.jsxs(K,{children:[e.jsx(Z,{children:e.jsx(ee,{children:"Details"})}),e.jsx(I,{children:e.jsxs("form",{onSubmit:W,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:t=>C(t.target.value),placeholder:"e.g., Product Documentation","data-tour":"kb-create-name",className:"mt-1 w-full rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] px-3 py-2",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx("textarea",{value:y,onChange:t=>z(t.target.value),placeholder:"What documents will this knowledge base contain?",rows:3,className:"mt-1 w-full rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] px-3 py-2"})]}),N.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Embedding Model"}),e.jsx("select",{value:b,onChange:t=>_(t.target.value),"data-tour":"kb-create-model",className:"mt-1 w-full rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] px-3 py-2",children:N.map(t=>e.jsxs("option",{value:t.id,children:[t.name," (",t.vector_size,"-dim, ",t.supported_inputs.join("+"),t.is_default?", default":"",")"]},t.id))}),e.jsxs("p",{className:"mt-1 text-xs text-[hsl(var(--muted-foreground))]",children:[B?.supported_inputs.includes("video")?"Multimodal: this KB will accept text, image, and video documents.":B?.supported_inputs.includes("image")?"Multimodal: this KB will accept both text and image documents.":"Text-only: this KB only accepts text documents."," ","The embedding model is locked once the knowledge base is created."]})]}),e.jsxs("div",{className:"border-t border-[hsl(var(--border))] pt-4",children:[e.jsxs("button",{type:"button","data-tour":"kb-create-advanced",onClick:()=>L(!g),className:"flex items-center gap-2 text-sm font-medium text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors",children:[g?e.jsx(J,{className:"h-4 w-4"}):e.jsx(Q,{className:"h-4 w-4"}),"Advanced Settings"]}),g&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Chunk Size"}),e.jsx("input",{type:"number",value:p,onChange:t=>R(t.target.value),placeholder:"1000 (default)",className:`mt-1 w-full rounded-md border bg-[hsl(var(--background))] px-3 py-2 ${f?"border-red-500 focus:ring-red-500":"border-[hsl(var(--input))]"}`}),f?e.jsx("p",{className:"mt-1 text-xs text-red-500",children:f}):e.jsx("p",{className:"mt-1 text-xs text-[hsl(var(--muted-foreground))]",children:"50 - 10,000 characters per chunk"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Chunk Overlap"}),e.jsx("input",{type:"number",value:x,onChange:t=>U(t.target.value),placeholder:"100 (default)",className:`mt-1 w-full rounded-md border bg-[hsl(var(--background))] px-3 py-2 ${v?"border-red-500 focus:ring-red-500":"border-[hsl(var(--input))]"}`}),v?e.jsx("p",{className:"mt-1 text-xs text-red-500",children:v}):e.jsx("p",{className:"mt-1 text-xs text-[hsl(var(--muted-foreground))]",children:"0 
1- 5,000. Must be less than chunk size."})]})]}),e.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"These settings control how documents are split for embedding. They cannot be changed after creation."})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>r(d("/knowledgebases")),children:"Cancel"}),e.jsxs(w,{type:"submit",disabled:E||!h.trim()||M,"data-tour":"kb-create-submit","data-testid":"kb-create-submit",children:[E&&e.jsx(Y,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Knowledge Base"]})]})]})})]}),e.jsx(K,{className:"border-dashed",children:e.jsxs(I,{className:"py-6",children:[e.jsx("h3",{className:"font-medium",children:"What happens next?"}),e.jsxs("ul",{className:"mt-2 space-y-1 text-sm text-[hsl(var(--muted-foreground))]",children:[e.jsx("li",{children:"1. Upload documents (TXT, MD, JSON, CSV files)"}),e.jsx("li",{children:"2. Documents are automatically chunked and embedded"}),e.jsx("li",{children:"3. Use the KB ID in your custom tools to search"}),e.jsx("li",{children:"4. Results are reranked for better relevance"})]})]})})]})}export{_e as KBCreate};

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.