PageSourceSearch

https://anythingllm-production-143e.up.railway.app/assets/index-6c183f93.js

js anythingllm-production-143e.up.railway.app collected 2026-10-03 12:11:59 UTC 12,339 bytes, 2 lines download raw bytes

1import{r as m,j as e,C as b,S as x,s as u,D as f,H as y,M as g,E as w,m as j,G as v,h as N}from"../index.js";import{t as h}from"./truncate-355a114a.js";import{t as k}from"./index-b542d8eb.js";import{S as C}from"./index-44bf2282.js";/* empty css                 */function V({variable:t,closeModal:l,onRefresh:s}){const[a,i]=m.useState(null),d=async c=>{if(!t.id)return;c.preventDefault(),i(null);const o=new FormData(c.target),r={};for(const[n,p]of o.entries())r[n]=p.trim();if(!r.key||!r.value){i("Key and value are required");return}try{await x.promptVariables.update(t.id,r),u("Variable updated successfully","success",{clear:!0}),s&&s(),l()}catch(n){console.error("Error updating variable:",n),i("Failed to update variable")}};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:["Edit ",t.key]})}),e.jsx("button",{onClick:l,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(b,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:d,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"key",className:"block mb-2 text-sm font-medium text-white",children:"Key"}),e.jsx("input",{name:"key",minLength:3,maxLength:255,type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., company_name",defaultValue:t.key,required:!0,autoComplete:"off",pattern:"^[a-zA-Z0-9_]+$"}),e.jsxs("p",{className:"mt-2 text-xs text-white/60",children:["Key must be unique and will be used in prompts as ","{key}",". Only letters, numbers and underscores are allowed."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"value",className:"block mb-2 text-sm font-medium text-white",children:"Value"}),e.jsx("input",{name:"value",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., Acme Corp",defaultValue:t.value,required:!0,autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block mb-2 text-sm font-medium text-white",children:"Description"}),e.jsx("input",{name:"description",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Optional description",defaultValue:t.description,autoComplete:"off"})]}),a&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",a]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:l,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Update variable"})]})]})})]})})}function E({variable:t,onRefresh:l}){const s=m.useRef(null),{isOpen:a,openModal:i,closeModal:d}=f(),c=async()=>{var n;if(t.id){if(!window.confirm(`Are you sure you want to delete the variable "${t.key}"?
2This action is irreversible.`))return!1;try{await x.promptVariables.delete(t.id),(n=s==null?void 0:s.current)==null||n.remove(),u("Variable deleted successfully","success",{clear:!0}),l&&l()}catch(p){console.error("Error deleting variable:",p),u("Failed to delete variable","error",{clear:!0})}}},r=(n=>{switch(n){case"system":return{bg:"bg-blue-600/20",text:"text-blue-400 light:text-blue-800"};case"user":return{bg:"bg-green-600/20",text:"text-green-400 light:text-green-800"};case"workspace":return{bg:"bg-cyan-600/20",text:"text-cyan-400 light:text-cyan-800"};default:return{bg:"bg-yellow-600/20",text:"text-yellow-400 light:text-yellow-800"}}})(t.type);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{ref:s,className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("th",{scope:"row",className:"px-4 py-2 whitespace-nowrap",children:t.key}),e.jsx("td",{className:"px-4 py-2",children:typeof t.value=="function"?t.value():h(t.value,50)}),e.jsx("td",{className:"px-4 py-2",children:h(t.description||"-",50)}),e.jsx("td",{className:"px-4 py-2",children:e.jsx("span",{className:`rounded-full ${r.bg} px-2 py-0.5 text-xs leading-5 font-semibold ${r.text} shadow-sm`,children:k((t==null?void 0:t.type)??"static")})}),e.jsx("td",{className:"px-4 py-2 flex items-center justify-end gap-x-4",children:t.type==="static"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"text-xs font-medium text-white/80 light:text-black/80 rounded-lg hover:text-white hover:light:text-gray-500 px-2 py-1 hover:bg-white hover:bg-opacity-10",children:"Edit"}),e.jsx("button",{onClick:c,className:"text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10",children:e.jsx(y,{className:"h-4 w-4"})})]})})]}),e.jsx(g,{isOpen:a,children:e.jsx(V,{variable:t,closeModal:d,onRefresh:l})})]})}function S({closeModal:t,onRefresh:l}){const[s,a]=m.useState(null),i=async d=>{d.preventDefault(),a(null);const c=new FormData(d.target),o={};for(const[r,n]of c.entries())o[r]=n.trim();if(!o.key||!o.value){a("Key and value are required");return}try{await x.promptVariables.create(o),u("Variable created successfully","success",{clear:!0}),l&&l(),t()}catch(r){console.error("Error creating variable:",r),a("Failed to create variable")}};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg
2-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsx("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:"Add New Variable"})}),e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(b,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:i,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"key",className:"block mb-2 text-sm font-medium text-white",children:"Key"}),e.jsx("input",{name:"key",type:"text",minLength:3,maxLength:255,className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., company_name",required:!0,autoComplete:"off",pattern:"^[a-zA-Z0-9_]+$"}),e.jsxs("p",{className:"mt-2 text-xs text-white/60",children:["Key must be unique and will be used in prompts as ","{key}",". Only letters, numbers and underscores are allowed."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"value",className:"block mb-2 text-sm font-medium text-white",children:"Value"}),e.jsx("input",{name:"value",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"e.g., Acme Corp",required:!0,autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block mb-2 text-sm font-medium text-white",children:"Description"}),e.jsx("input",{name:"description",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Optional description",autoComplete:"off"})]}),s&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",s]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:t,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Create variable"})]})]})})]})})}function q(){const[t,l]=m.useState([]),[s,a]=m.useState(!0),{isOpen:i,openModal:d,closeModal:c}=f();m.useEffect(()=>{o()},[]);const o=async()=>{a(!0);try{const{variables:r}=await x.promptVariables.getAll();l(r||[])}catch(r){console.error("Error fetching variables:",r),u("No variables found","error")}finally{a(!1)}};return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(w,{}),e.jsx("div",{style:{height:j?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("div",{className:"items-center flex gap-x-4",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"System Prompt Variables"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"System prompt variables are used to store configuration values that can be referenced in your system prompt to enable dynamic content in your prompts."})]}),e.jsx("div",{className:"w-full justify-end flex",children:e.jsxs(v,{onClick:d,className:"mt-3 mr-0 mb-4 md:-mb-6 z-10",children:[e.jsx(N,{className:"h-4 w-4",weight:"bold"})," Add Variable"]})}),e.jsx("div",{className:"overflow-x-auto",children:s?e.jsx(C,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg
2-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm mt-8",containerClassName:"flex w-full"}):t.length===0?e.jsx("div",{className:"text-center py-4 text-theme-text-secondary",children:"No variables found"}):e.jsxs("table",{className:"w-full text-sm text-left rounded-lg min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-4 py-2 rounded-tl-lg",children:"Key"}),e.jsx("th",{scope:"col",className:"px-4 py-2",children:"Value"}),e.jsx("th",{scope:"col",className:"px-4 py-2",children:"Description"}),e.jsx("th",{scope:"col",className:"px-4 py-2",children:"Type"})]})}),e.jsx("tbody",{children:t.map(r=>e.jsx(E,{variable:r,onRefresh:o},r.id))})]})})]})}),e.jsx(g,{isOpen:i,children:e.jsx(S,{closeModal:c,onRefresh:o})})]})}export{q 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.