From 6cae24ed08093bada860ebaee33b848756917fe1 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 18 Feb 2025 21:26:06 -0800 Subject: [PATCH] ui new build --- .../out/_next/static/chunks/app/page-46aa398e93cfa70d.js | 1 - .../out/_next/static/chunks/app/page-e673cacf03d84561.js | 1 + .../_buildManifest.js | 0 .../_ssgManifest.js | 0 litellm/proxy/_experimental/out/index.html | 2 +- litellm/proxy/_experimental/out/index.txt | 4 ++-- litellm/proxy/_experimental/out/model_hub.txt | 2 +- litellm/proxy/_experimental/out/onboarding.html | 1 + litellm/proxy/_experimental/out/onboarding.txt | 2 +- ui/litellm-dashboard/out/404.html | 2 +- .../out/_next/static/chunks/app/page-46aa398e93cfa70d.js | 1 - .../out/_next/static/chunks/app/page-e673cacf03d84561.js | 1 + .../_buildManifest.js | 0 .../_ssgManifest.js | 0 ui/litellm-dashboard/out/index.html | 2 +- ui/litellm-dashboard/out/index.txt | 4 ++-- ui/litellm-dashboard/out/model_hub.html | 2 +- ui/litellm-dashboard/out/model_hub.txt | 2 +- ui/litellm-dashboard/out/onboarding.html | 2 +- ui/litellm-dashboard/out/onboarding.txt | 2 +- 20 files changed, 16 insertions(+), 15 deletions(-) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/app/page-46aa398e93cfa70d.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/app/page-e673cacf03d84561.js rename litellm/proxy/_experimental/out/_next/static/{yJuobVnL1vdr5eQA0jUcl => r-JFaQKckChAbyF6OLpws}/_buildManifest.js (100%) rename litellm/proxy/_experimental/out/_next/static/{yJuobVnL1vdr5eQA0jUcl => r-JFaQKckChAbyF6OLpws}/_ssgManifest.js (100%) create mode 100644 litellm/proxy/_experimental/out/onboarding.html delete mode 100644 ui/litellm-dashboard/out/_next/static/chunks/app/page-46aa398e93cfa70d.js create mode 100644 ui/litellm-dashboard/out/_next/static/chunks/app/page-e673cacf03d84561.js rename ui/litellm-dashboard/out/_next/static/{yJuobVnL1vdr5eQA0jUcl => r-JFaQKckChAbyF6OLpws}/_buildManifest.js (100%) rename ui/litellm-dashboard/out/_next/static/{yJuobVnL1vdr5eQA0jUcl => r-JFaQKckChAbyF6OLpws}/_ssgManifest.js (100%) diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-46aa398e93cfa70d.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-46aa398e93cfa70d.js deleted file mode 100644 index 7ddd2196aa..0000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-46aa398e93cfa70d.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,79333))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),r=s(99376),i=s(20831),n=s(94789),o=s(12514),d=s(49804),c=s(67101),m=s(84264),u=s(26637),h=s(96761),x=s(84566),p=s(19250),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,r.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,_]=(0,a.useState)(null),[y,v]=(0,a.useState)(""),[b,w]=(0,a.useState)(""),[N,S]=(0,a.useState)(null),[k,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),S(t.user_id)})},[s]),(0,t.jsx)("div",{className:"mx-auto w-full max-w-md mt-10",children:(0,t.jsxs)(o.Z,{children:[(0,t.jsx)(h.Z,{className:"text-sm mb-5 text-center",children:"\uD83D\uDE85 LiteLLM"}),(0,t.jsx)(h.Z,{className:"text-xl",children:"Sign up"}),(0,t.jsx)(m.Z,{children:"Claim your user account to login to Admin UI."}),(0,t.jsx)(n.Z,{className:"mt-4",title:"SSO",icon:x.GH$,color:"sky",children:(0,t.jsxs)(c.Z,{numItems:2,className:"flex justify-between items-center",children:[(0,t.jsx)(d.Z,{children:"SSO is under the Enterprise Tirer."}),(0,t.jsx)(d.Z,{children:(0,t.jsx)(i.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=b,N&&s&&(0,p.m_)(Z,s,N,e.password).then(e=>{var l;let s="/ui/";s+="?userID="+((null===(l=e.data)||void 0===l?void 0:l.user_id)||e.user_id),document.cookie="token="+C,console.log("redirecting to:",s),window.location.href=s}))},children:[(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:b,defaultValue:b,className:"max-w-md"})}),(0,t.jsx)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},79333:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sD}});var t,a,r=s(57437),i=s(2265),n=s(99376),o=s(14474),d=s(90946),c=s(29827),m=s(27648),u=s(80795),h=e=>{let{userID:l,userRole:s,premiumUser:t,proxySettings:a}=e,i=(null==a?void 0:a.PROXY_LOGOUT_URL)||"",n=[{key:"1",label:(0,r.jsxs)("div",{className:"px-1 py-1",children:[(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Role: ",s]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["ID: ",l]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Premium User: ",String(t)]})]})},{key:"2",label:(0,r.jsx)("p",{className:"text-sm hover:text-gray-900",onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=i},children:"Logout"})}];return(0,r.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,r.jsx)("div",{className:"w-full",children:(0,r.jsxs)("div",{className:"flex items-center h-12 px-4",children:[(0,r.jsx)("div",{className:"flex items-center flex-shrink-0",children:(0,r.jsx)(m.default,{href:"/",className:"flex items-center",children:(0,r.jsx)("img",{src:"/get_image",alt:"LiteLLM Brand",className:"h-8 w-auto"})})}),(0,r.jsxs)("div",{className:"flex items-center space-x-5 ml-auto",children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:"Docs"}),(0,r.jsx)(u.Z,{menu:{items:n,style:{padding:"4px",marginTop:"4px"}},children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:["User",(0,r.jsx)("svg",{className:"ml-1 w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})},x=s(19250);let p=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,x.It)(e,(null==t?void 0:t.organization_id)||null,l):await (0,x.It)(e,(null==t?void 0:t.organization_id)||null),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),g=s(67101),f=s(20831),Z=s(26637),_=s(87452),y=s(88829),v=s(72208),b=s(84264),w=s(96761),N=s(29233),S=s(52787),k=s(13634),I=s(41021),C=s(51369),A=s(29967),P=s(20577),E=s(56632),O=s(73002);let T=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,x.So)(s,e,l,!0)).data.map(e=>e.id),a=[],r=[];return t.forEach(e=>{e.endsWith("/*")?a.push(e):r.push(e)}),[...a,...r]}}catch(e){console.error("Error fetching user models:",e)}},M=e=>{if(e.endsWith("/*")){let l=e.replace("/*","");return"All ".concat(l," models")}return e},D=(e,l)=>{let s=[],t=[];return console.log("teamModels",e),console.log("allModels",l),e.forEach(e=>{if(e.endsWith("/*")){let a=e.replace("/*",""),r=l.filter(e=>e.startsWith(a+"/"));t.push(...r),s.push(e)}else t.push(e)}),[...s,...t].filter((e,l,s)=>s.indexOf(e)===l)};var L=e=>{let{teams:l,value:s,onChange:t}=e;return(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",value:s,onChange:t,filterOption:(e,l)=>{var s,t,a;return!!l&&((null===(a=l.children)||void 0===a?void 0:null===(t=a[0])||void 0===t?void 0:null===(s=t.props)||void 0===s?void 0:s.children)||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==l?void 0:l.map(e=>(0,r.jsxs)(S.default.Option,{value:e.team_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.team_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.team_id,")"]})]},e.team_id))})},F=s(15424),R=s(75957);let{Option:z}=S.default,U=e=>{let l=[];if(console.log("data:",JSON.stringify(e)),e)for(let s of e)s.metadata&&s.metadata.tags&&l.push(...s.metadata.tags);let s=Array.from(new Set(l)).map(e=>({value:e,label:e}));return console.log("uniqueTags:",s),s},V=(e,l)=>D(e&&e.models.length>0?e.models.includes("all-proxy-models")?l:e.models:l,l),q=async(e,l,s,t)=>{try{if(null===e||null===l)return;if(null!==s){let a=(await (0,x.So)(s,e,l)).data.map(e=>e.id);console.log("available_model_names:",a),t(a)}}catch(e){console.error("Error fetching user models:",e)}};var B=e=>{let{userID:l,team:s,teams:t,userRole:a,accessToken:n,data:o,setData:d}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[T,D]=(0,i.useState)(null),[B,K]=(0,i.useState)([]),[W,H]=(0,i.useState)([]),[G,Y]=(0,i.useState)("you"),[J,$]=(0,i.useState)(U(o)),[X,Q]=(0,i.useState)([]),[ee,el]=(0,i.useState)(s),es=()=>{u(!1),c.resetFields()},et=()=>{u(!1),p(null),c.resetFields()};(0,i.useEffect)(()=>{l&&a&&n&&q(l,a,n,K)},[n,l,a]),(0,i.useEffect)(()=>{(async()=>{try{let e=(await (0,x.t3)(n)).guardrails.map(e=>e.guardrail_name);Q(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[n]);let ea=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",i=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===i).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(i,", please provide another key alias"));if(I.ZP.info("Making API Call"),u(!0),"you"===G&&(e.user_id=l),"service_account"===G){let l={};try{l=JSON.parse(e.metadata||"{}")}catch(e){console.error("Error parsing metadata:",e)}l.service_account_id=e.key_alias,e.metadata=JSON.stringify(l)}let m=await (0,x.wX)(n,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),p(m.key),D(m.soft_budget),I.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),I.ZP.error("Error creating the key: ".concat(e))}};return(0,i.useEffect)(()=>{H(V(ee,B)),c.setFieldValue("models",[])},[ee,B]),(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(C.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:es,onCancel:et,children:(0,r.jsxs)(k.Z,{form:c,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(A.ZP.Group,{onChange:e=>Y(e.target.value),value:G,children:[(0,r.jsx)(A.ZP,{value:"you",children:"You"}),(0,r.jsx)(A.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(A.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==G,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===G,message:"Please input the user ID of the user you are assigning the key to"}],help:"Get User ID - Click on the 'Users' tab in the sidebar.",children:(0,r.jsx)(Z.Z,{placeholder:"User ID",onChange:e=>c.setFieldValue("user_id",e.target.value)})}),(0,r.jsx)(k.Z.Item,{label:"you"===G||"another_user"===G?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===G?"key name":"service account ID")}],help:"you"===G?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(L,{teams:t})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected team has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,r.jsx)(z,{value:"all-team-models",children:"All Team Models"},"all-team-models"),W.map(e=>(0,r.jsx)(z,{value:e,children:M(e)},e))]})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:X.map(e=>({value:e,label:e}))})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)(k.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:J})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(C.Z,{visible:m,onOk:es,onCancel:et,footer:null,children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Save your Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:null!=h?(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:h})}),(0,r.jsx)(N.CopyToClipboard,{text:h,onCopy:()=>{I.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(b.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,n]=(0,i.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,i.useState)(!0),[c,m]=(0,i.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!t){console.log("accessToken",t);return}d(!0);let a=await (0,x.OD)(t,(null==s?void 0:s.organization_id)||null,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),n(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,i.useEffect)(()=>{u(),console.log("selectedTeam",l,"currentOrg",s,"accessToken",t)},[l,s,t]),{keys:r.keys,isLoading:o,error:c,pagination:{currentPage:r.current_page,totalPages:r.total_pages,totalCount:r.total_count},refresh:u}},H=s(71594),G=s(24525),Y=s(21626),J=s(97214),$=s(28241),X=s(58834),Q=s(69552),ee=s(71876);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:n=!1}=e,o=(0,H.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,G.sC)(),getExpandedRowModel:(0,G.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(Y.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(X.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)(ee.Z,{children:e.headers.map(e=>(0,r.jsx)(Q.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,H.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(J.Z,{children:n?(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"\uD83D\uDE85 Loading logs..."})})})}):o.getRowModel().rows.length>0?o.getRowModel().rows.map(e=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)(ee.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)($.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,H.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"No logs found"})})})})})]})})}var es=s(27281),et=s(57365),ea=s(41649),er=s(12514),ei=s(12485),en=s(18135),eo=s(35242),ed=s(29706),ec=s(77991),em=s(10900),eu=s(23628),eh=s(74998);function ex(e){var l,s;let{keyData:t,onCancel:a,onSubmit:n,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=k.Z.useForm(),[h,p]=(0,i.useState)([]),j=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,i.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,x.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let g={...t,budget_duration:(s=t.budget_duration)&&({"24h":"daily","7d":"weekly","30d":"monthly"})[s]||null,metadata:t.metadata?JSON.stringify(t.metadata,null,2):"",guardrails:(null===(l=t.metadata)||void 0===l?void 0:l.guardrails)||[]};return(0,r.jsxs)(k.Z,{form:u,onFinish:n,initialValues:g,layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[j.length>0&&(0,r.jsx)(S.default.Option,{value:"all-team-models",children:"All Team Models"}),j.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(S.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(S.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(k.Z.Item,{name:"token",hidden:!0,children:(0,r.jsx)(E.Z,{})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(f.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,_]=(0,i.useState)(!1);(0,i.useEffect)(()=>{s&&l&&n.setFieldsValue({key_alias:l.key_alias,max_budget:l.max_budget,tpm_limit:l.tpm_limit,rpm_limit:l.rpm_limit,duration:l.duration||""})},[s,l,n]),(0,i.useEffect)(()=>{s||(d(null),_(!1),n.resetFields())},[s,n]),(0,i.useEffect)(()=>{(null==c?void 0:c.duration)?h((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString()}catch(e){return null}})(c.duration)):h(null)},[null==c?void 0:c.duration]);let y=async()=>{if(l&&a){_(!0);try{let e=await n.validateFields(),s=await (0,x.s0)(a,l.token,e);d(s.key),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key"),_(!1)}}},v=()=>{d(null),_(!1),n.resetFields(),t()};return(0,r.jsx)(C.Z,{title:"Regenerate API Key",open:s,onCancel:v,footer:o?[(0,r.jsx)(f.Z,{onClick:v,children:"Close"},"close")]:[(0,r.jsx)(f.Z,{onClick:v,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:y,disabled:p,children:p?"Regenerating...":"Regenerate"},"regenerate")],children:o?(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:(null==l?void 0:l.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:o})}),(0,r.jsx)(N.CopyToClipboard,{text:o,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(k.Z,{form:n,layout:"vertical",onValuesChange:e=>{"duration"in e&&m(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==l?void 0:l.expires)?new Date(l.expires).toLocaleString():"Never"]}),u&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",u]})]})})}function ej(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:n,userRole:o,teams:d}=e,[c,m]=(0,i.useState)(!1),[u]=k.Z.useForm(),[h,p]=(0,i.useState)(!1),[j,Z]=(0,i.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(b.Z,{children:"Key not found"})]});let _=async e=>{try{var l,s;if(!a)return;let t=e.token;if(e.key=t,e.metadata&&"string"==typeof e.metadata)try{let s=JSON.parse(e.metadata);e.metadata={...s,...(null===(l=e.guardrails)||void 0===l?void 0:l.length)>0?{guardrails:e.guardrails}:{}}}catch(e){console.error("Error parsing metadata JSON:",e),I.ZP.error("Invalid metadata JSON");return}else e.metadata={...e.metadata||{},...(null===(s=e.guardrails)||void 0===s?void 0:s.length)>0?{guardrails:e.guardrails}:{}};e.budget_duration&&(e.budget_duration=({daily:"24h",weekly:"7d",monthly:"30d"})[e.budget_duration]),await (0,x.Nc)(a,e),I.ZP.success("Key updated successfully"),m(!1)}catch(e){I.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},y=async()=>{try{if(!a)return;await (0,x.I1)(a,t.token),I.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),I.ZP.error("Failed to delete key")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(f.Z,{icon:eu.Z,variant:"secondary",onClick:()=>Z(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>p(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:j,onClose:()=>Z(!1),accessToken:a}),h&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:y,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>p(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(b.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:_,teams:d,accessToken:a,userID:n,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(b.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(b.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(b.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(b.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(b.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(b.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(b.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Metadata"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(t.metadata,null,2)})]})]})]})})]})]})]})}var eg=s(82422),ef=s(2356),eZ=s(44633),e_=s(86462),ey=s(3837),ev=e=>{var l;let{options:s,onApplyFilters:t,onResetFilters:a,initialValues:n={},buttonLabel:o="Filter"}=e,[d,c]=(0,i.useState)(!1),[m,h]=(0,i.useState)((null===(l=s[0])||void 0===l?void 0:l.name)||""),[x,p]=(0,i.useState)(n),[j,g]=(0,i.useState)(n),[f,Z]=(0,i.useState)(!1),_=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{let l=e.target;!_.current||_.current.contains(l)||l.closest(".ant-dropdown")||c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let y=e=>{g(l=>({...l,[m]:e}))},v=()=>{let e={};s.forEach(l=>{e[l.name]=""}),g(e)},b=s.map(e=>({key:e.name,label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[m===e.name&&(0,r.jsx)(eg.Z,{className:"h-4 w-4 text-blue-600"}),e.label||e.name]})}));return(0,r.jsxs)("div",{className:"relative",ref:_,children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(ef.Z,{className:"h-4 w-4"}),onClick:()=>c(!d),children:o}),d&&(0,r.jsx)(er.Z,{className:"absolute left-0 mt-2 w-96 z-50",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsx)(u.Z,{menu:{items:b,onClick:e=>{let{key:l}=e;h(l),Z(!1)}},onOpenChange:Z,open:f,trigger:["click"],children:(0,r.jsxs)(O.ZP,{className:"min-w-32 text-left flex justify-between items-center",children:[m,f?(0,r.jsx)(eZ.Z,{className:"h-4 w-4"}):(0,r.jsx)(e_.Z,{className:"h-4 w-4"})]})}),(0,r.jsx)(E.Z,{placeholder:"Enter value...",value:j[m]||"",onChange:e=>y(e.target.value),suffix:j[m]?(0,r.jsx)(ey.Z,{className:"h-4 w-4 cursor-pointer text-gray-400 hover:text-gray-500",onClick:e=>{e.stopPropagation(),y("")}}):null})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(O.ZP,{onClick:()=>{v();let e={};s.forEach(l=>{e[l.name]=""}),a(),c(!1)},children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"primary",onClick:()=>{p(j),t(j),c(!1)},children:"Apply Filters"})]})]})})]})};function eb(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:n=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h,organizations:x,setCurrentOrg:p}=e,[j,g]=(0,i.useState)(null),[Z,_]=(0,i.useState)({"Team ID":"","Organization ID":""}),y=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):null}},{header:"Key ID",accessorKey:"token",cell:e=>(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.getValue(),children:(0,r.jsx)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>g(e.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{header:"Team ID",accessorKey:"team_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Key Alias",accessorKey:"key_alias",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Organization ID",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Created",accessorKey:"created_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"-"}},{header:"Expires",accessorKey:"expires",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"Never"}},{header:"Spend (USD)",accessorKey:"spend",cell:e=>Number(e.getValue()).toFixed(4)},{header:"Budget (USD)",accessorKey:"max_budget",cell:e=>null!==e.getValue()&&void 0!==e.getValue()?e.getValue():"Unlimited"},{header:"Budget Reset",accessorKey:"budget_reset_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleString():"Never"}},{header:"Models",accessorKey:"models",cell:e=>{let l=e.getValue();return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:l&&l.length>0?l.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):"-"})}},{header:"Rate Limits",cell:e=>{let{row:l}=e,s=l.original;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{children:["TPM: ",null!==s.tpm_limit?s.tpm_limit:"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",null!==s.rpm_limit?s.rpm_limit:"Unlimited"]})]})}}];return(0,r.jsx)("div",{className:"w-full h-full overflow-hidden",children:j?(0,r.jsx)(ej,{keyId:j,onClose:()=>g(null),keyData:l.find(e=>e.token===j),accessToken:m,userID:u,userRole:h,teams:o}):(0,r.jsxs)("div",{className:"border-b py-4 flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between w-full mb-2",children:[(0,r.jsx)(ev,{options:[{name:"Team ID",label:"Team ID"},{name:"Organization ID",label:"Organization ID"}],onApplyFilters:e=>{if(_({"Team ID":e["Team ID"]||"","Organization ID":e["Organization ID"]||""}),e["Team ID"]){let l=null==o?void 0:o.find(l=>l.team_id===e["Team ID"]);l&&c(l)}if(e["Organization ID"]){let l=null==x?void 0:x.find(l=>l.organization_id===e["Organization ID"]);l&&p(l)}},initialValues:Z,onResetFilters:()=>{_({"Team ID":"","Organization ID":""}),c(null),p(null)}}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsxs)("span",{className:"inline-flex text-sm text-gray-700",children:["Showing ",s?"...":"".concat((t.currentPage-1)*n+1," - ").concat(Math.min(t.currentPage*n,t.totalCount))," of ",s?"...":t.totalCount," results"]}),(0,r.jsxs)("div",{className:"inline-flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",s?"...":t.currentPage," of ",s?"...":t.totalPages]}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage-1),disabled:s||1===t.currentPage,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage+1),disabled:s||t.currentPage===t.totalPages,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]}),(0,r.jsx)("div",{className:"h-[32rem] overflow-auto",children:(0,r.jsx)(el,{columns:y.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ew=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:n,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u,organizations:h,setCurrentOrg:p}=e,[_,y]=(0,i.useState)(!1),[v,S]=(0,i.useState)(!1),[A,E]=(0,i.useState)(null),[O,M]=(0,i.useState)(null),[D,L]=(0,i.useState)(null),[F,R]=(0,i.useState)((null==a?void 0:a.team_id)||""),[z,U]=(0,i.useState)("");(0,i.useEffect)(()=>{R((null==a?void 0:a.team_id)||"")},[a]);let{keys:V,isLoading:q,error:B,pagination:H,refresh:G}=W({selectedTeam:a,currentOrg:u,accessToken:t}),[Y,J]=(0,i.useState)(!1),[$,X]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(null),[el,es]=(0,i.useState)([]),et=new Set,[ea,er]=(0,i.useState)(!1),[ei,en]=(0,i.useState)(!1),[eo,ed]=(0,i.useState)(null),[ec,em]=(0,i.useState)(null),[eu]=k.Z.useForm(),[eh,ex]=(0,i.useState)(null),[ep,ej]=(0,i.useState)(et),[eg,ef]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",Q),(null==ec?void 0:ec.duration)?ex((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0})}catch(e){return null}})(ec.duration)):ex(null),console.log("calculateNewExpiryTime:",eh)},[Q,null==ec?void 0:ec.duration]),(0,i.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await T(l,s,t);e&&es(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,i.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ej(e)}},[c]);let eZ=async()=>{if(null!=A&&null!=o){try{await (0,x.I1)(t,A);let e=o.filter(e=>e.token!==A);d(e)}catch(e){console.error("Error deleting the key:",e)}S(!1),E(null)}},e_=(e,l)=>{em(s=>({...s,[e]:l}))},ey=async()=>{if(!m){I.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=Q)try{let e=await eu.validateFields(),l=await (0,x.s0)(t,Q.token,e);if(ed(l.key),o){let s=o.map(s=>s.token===(null==Q?void 0:Q.token)?{...s,key_name:l.key_name,...e}:s);d(s)}en(!1),eu.resetFields(),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key")}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eb,{keys:V,isLoading:q,pagination:H,onPageChange:e=>{G({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:n,accessToken:t,userID:l,userRole:s,organizations:h,setCurrentOrg:p}),v&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eZ,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{S(!1),E(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(C.Z,{title:"Regenerate API Key",visible:ei,onCancel:()=>{en(!1),eu.resetFields()},footer:[(0,r.jsx)(f.Z,{onClick:()=>{en(!1),eu.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:ey,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(k.Z,{form:eu,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&e_("duration",e.duration)},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry:"," ",(null==Q?void 0:Q.expires)!=null?new Date(Q.expires).toLocaleString():"Never"]}),eh&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eh]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),eo&&(0,r.jsx)(C.Z,{visible:!!eo,onCancel:()=>ed(null),footer:[(0,r.jsx)(f.Z,{onClick:()=>ed(null),children:"Close"},"close")],children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==Q?void 0:Q.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:eo})}),(0,r.jsx)(N.CopyToClipboard,{text:eo,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eN=s(12011),eS=s(93192);console.log=function(){},console.log("isLocal:",!1);var ek=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,premiumUser:f,organizations:Z}=e,[_,y]=(0,i.useState)(null),[v,b]=(0,i.useState)(null),w=(0,n.useSearchParams)(),N=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),S=w.get("invitation_id"),[k,I]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),[P,E]=(0,i.useState)([]),[O,T]=(0,i.useState)(null),[M,D]=(0,i.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,i.useEffect)(()=>{if(N){let e=(0,o.o)(N);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),d(l)}else console.log("User role not defined");e.user_email?m(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&k&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);e?E(JSON.parse(e)):(console.log("currentOrg: ".concat(JSON.stringify(v))),(async()=>{try{let e=await (0,x.g)(k);T(e);let t=await (0,x.Br)(k,l,s,!1,null,null);y(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(_))),(null==t?void 0:t.teams[0].keys)?h(t.keys.concat(t.teams.filter(e=>"Admin"===s||e.user_id===l).flatMap(e=>e.keys))):h(t.keys),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,x.So)(k,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),E(a),console.log("userModels:",P),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),p(k,l,s,v,u))}},[l,N,k,a,s]),(0,i.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(v),", accessToken: ").concat(k,", userID: ").concat(l,", userRole: ").concat(s)),k&&(console.log("fetching teams"),p(k,l,s,v,u))},[v]),(0,i.useEffect)(()=>{if(null!==a&&null!=M&&null!==M.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))M.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===M.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),A(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;A(e)}},[M]),null!=S)return(0,r.jsx)(eN.default,{});if(null==l||null==N){let e="/sso/key/generate";return document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",console.log("Full URL:",e),window.location.href=e,null}if(null==k)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",M),(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(j.Z,{numColSpan:1,className:"flex flex-col gap-2",children:[(0,r.jsx)(B,{userID:l,team:M,teams:t,userRole:s,accessToken:k,data:a,setData:h},M?M.team_id:null),(0,r.jsx)(ew,{userID:l,userRole:s,accessToken:k,selectedTeam:M||null,setSelectedTeam:D,data:a,setData:h,premiumUser:f,teams:t,currentOrg:v,setCurrentOrg:b,organizations:Z})]})})})},eI=s(97765);(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.Groq="Groq",t.MistralAI="Mistral AI",t.Deepseek="Deepseek",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI",t.AssemblyAI="AssemblyAI";let eC={OpenAI:"openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",Groq:"groq",MistralAI:"mistral",Cohere:"cohere_chat",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",xAI:"xai",Deepseek:"deepseek",Ollama:"ollama",AssemblyAI:"assemblyai"},eA={OpenAI:"https://artificialanalysis.ai/img/logos/openai_small.svg",Azure:"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg","Azure AI Studio":"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg",Anthropic:"https://artificialanalysis.ai/img/logos/anthropic_small.svg","Google AI Studio":"https://artificialanalysis.ai/img/logos/google_small.svg","Amazon Bedrock":"https://artificialanalysis.ai/img/logos/aws_small.png",Groq:"https://artificialanalysis.ai/img/logos/groq_small.png","Mistral AI":"https://artificialanalysis.ai/img/logos/mistral_small.png",Cohere:"https://artificialanalysis.ai/img/logos/cohere_small.png","OpenAI-Compatible Endpoints (Together AI, etc.)":"https://upload.wikimedia.org/wikipedia/commons/4/4e/OpenAI_Logo.svg","Vertex AI (Anthropic, Gemini, etc.)":"https://artificialanalysis.ai/img/logos/google_small.svg",Databricks:"https://artificialanalysis.ai/img/logos/databricks_small.png",Ollama:"https://artificialanalysis.ai/img/logos/ollama_small.svg",xAI:"https://artificialanalysis.ai/img/logos/xai_small.svg",Deepseek:"https://artificialanalysis.ai/img/logos/deepseek_small.jpg",AssemblyAI:"https://artificialanalysis.ai/img/logos/assemblyai_small.png"},eP=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(eC).find(l=>eC[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eA[s],displayName:s}},eE=e=>"Vertex AI (Anthropic, Gemini, etc.)"===e?"gemini-pro":"Anthropic"==e||"Amazon Bedrock"==e?"claude-3-opus":"Google AI Studio"==e?"gemini-pro":"Azure AI Studio"==e?"azure_ai/command-r-plus":"Azure"==e?"azure/my-deployment":"gpt-3.5-turbo",eO=(e,l)=>{console.log("Provider key: ".concat(e));let s=eC[e];console.log("Provider mapped to: ".concat(s));let t=[];return e&&"object"==typeof l&&(Object.entries(l).forEach(e=>{let[l,a]=e;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===s||a.litellm_provider.includes(s))&&t.push(l)}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(l).forEach(e=>{let[l,s]=e;null!==s&&"object"==typeof s&&"litellm_provider"in s&&"cohere"===s.litellm_provider&&t.push(l)}))),t},eT=async(e,l,s,t)=>{try{if(console.log("handling submit for formValues:",e),e.model&&e.model.includes("all-wildcard")){let l=eC[e.custom_llm_provider]+"/*";e.model_name=l,e.model=l}let a=e.model_mappings||[];for(let s of("model_mappings"in e&&delete e.model_mappings,a)){let t={},a={},r=s.public_name;for(let[l,r]of(t.model=s.litellm_model,e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),t.model=s.litellm_model,console.log("formValues add deployment:",e),Object.entries(e)))if(""!==r&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)t.model=r;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",r);let e=eC[r];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=r;else if("team_id"===l)a.team_id=r;else if("custom_model_name"===l)t.model=r;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))a[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){r&&(t[l]=Number(r));continue}else t[l]=r}let i={model_name:r,litellm_params:t,model_info:a},n=await (0,x.kK)(l,i);console.log("response for model create call: ".concat(n.data))}t&&t(),s.resetFields()}catch(e){I.ZP.error("Failed to create model: "+e,10)}},eM=e=>{var l;return(null==e?void 0:null===(l=e.model_info)||void 0===l?void 0:l.team_public_model_name)?e.model_info.team_public_model_name:(null==e?void 0:e.model_name)||"-"},eD=async(e,l,s,t)=>{if(console.log("handleEditSubmit:",e),null==l)return;let a={},r=null;for(let[l,s]of(e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),Object.entries(e)))"model_id"!==l?a[l]=""===s?null:s:r=""===s?null:s;let i={litellm_params:Object.keys(a).length>0?a:void 0,model_info:void 0!==r?{id:r}:void 0};console.log("handleEditSubmit payload:",i);try{await (0,x.um)(l,i),I.ZP.success("Model updated successfully, restart server to see updates"),s(!1),t(null)}catch(e){console.log("Error occurred")}};var eL=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[i]=k.Z.useForm(),n={},o="",d="";if(t){var c,m;n={...t.litellm_params,input_cost_per_token:(null===(c=t.litellm_params)||void 0===c?void 0:c.input_cost_per_token)?1e6*t.litellm_params.input_cost_per_token:void 0,output_cost_per_token:(null===(m=t.litellm_params)||void 0===m?void 0:m.output_cost_per_token)?1e6*t.litellm_params.output_cost_per_token:void 0},o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),n.model_id=d)}return(0,r.jsx)(C.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{a({...e,input_cost_per_token:e.input_cost_per_token?Number(e.input_cost_per_token)/1e6:void 0,output_cost_per_token:e.output_cost_per_token?Number(e.output_cost_per_token)/1e6:void 0}),i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(k.Z,{form:i,onFinish:a,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},eF=s(53003),eR=s(47323),ez=s(75105),eU=s(40278),eV=s(69410),eq=s(14301),eB=s(53410),eK=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,n]=(0,i.useState)(!1),o=async()=>{try{I.ZP.info("Making API Call"),n(!0);let e=await (0,x.Og)(s,l);console.log("model delete Response:",e),I.ZP.success("Model ".concat(l," deleted successfully")),n(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eR.Z,{onClick:()=>n(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(C.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>n(!1),children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Delete Model"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Model ID: ",(0,r.jsx)("b",{children:l})]})})]})})]})},eW=s(94789),eH=s(59664),eG=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eH.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,r.jsxs)("div",{children:[(0,r.jsx)(eW.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,r.jsx)(f.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eY=e=>{var l,s,t;let{visible:a,onCancel:n,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=k.Z.useForm();console.log("Initial Data:",d),(0,i.useEffect)(()=>{if(a){if("edit"===c&&d)u.setFieldsValue({...d,role:d.role||m.defaultRole});else{var e;u.resetFields(),u.setFieldsValue({role:m.defaultRole||(null===(e=m.roleOptions[0])||void 0===e?void 0:e.value)})}}},[a,d,c,u,m.defaultRole,m.roleOptions]);let h=async e=>{try{let l=Object.entries(e).reduce((e,l)=>{let[s,t]=l;return{...e,[s]:"string"==typeof t?t.trim():t}},{});o(l),u.resetFields(),I.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){I.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}},x=e=>{switch(e.type){case"input":return(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",onChange:e=>{e.target.value=e.target.value.trim()}});case"select":var l;return(0,r.jsx)(S.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(C.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:n,children:(0,r.jsxs)(k.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),m.showEmail&&m.showUserId&&(0,r.jsx)("div",{className:"text-center mb-4",children:(0,r.jsx)(b.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{children:"Role"}),"edit"===c&&d&&(0,r.jsxs)("span",{className:"text-gray-500 text-sm",children:["(Current: ",(s=d.role,(null===(t=m.roleOptions.find(e=>e.value===s))||void 0===t?void 0:t.label)||s),")"]})]}),name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,r.jsx)(S.default,{children:"edit"===c&&d?[...m.roleOptions.filter(e=>e.value===d.role),...m.roleOptions.filter(e=>e.value!==d.role)].map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))})}),null===(l=m.additionalFields)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.Z.Item,{label:e.label,name:e.name,className:"mb-4",rules:e.rules,children:x(e)},e.name)),(0,r.jsxs)("div",{className:"text-right mt-6",children:[(0,r.jsx)(O.ZP,{onClick:n,className:"mr-2",children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},eJ=s(7310),e$=s.n(eJ),eX=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:n="Add Team Member",roles:o=[{label:"admin",value:"admin",description:"Admin role. Can create team keys, add members, and manage settings."},{label:"user",value:"user",description:"User role. Can view team info, but not manage it."}],defaultRole:d="user"}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}p(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,x.u5)(a,s)).map(e=>({label:"user_email"===l?"".concat(e.user_email):"".concat(e.user_id),value:"user_email"===l?e.user_email:e.user_id,user:e}));u(t)}catch(e){console.error("Error fetching users:",e)}finally{p(!1)}},Z=(0,i.useCallback)(e$()((e,l)=>f(e,l),300),[]),_=(e,l)=>{g(l),Z(e,l)},y=(e,l)=>{let s=l.user;c.setFieldsValue({user_email:s.user_email,user_id:s.user_id,role:c.getFieldValue("role")})};return(0,r.jsx)(C.Z,{title:n,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(k.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>_(e,"user_email"),onSelect:(e,l)=>y(e,l),options:"user_email"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>_(e,"user_id"),onSelect:(e,l)=>y(e,l),options:"user_id"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(k.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:(0,r.jsxs)(R.Z,{title:e.description,children:[(0,r.jsx)("span",{className:"font-medium",children:e.label}),(0,r.jsxs)("span",{className:"ml-2 text-gray-500 text-sm",children:["- ",e.description]})]})},e.value))})}),(0,r.jsx)("div",{className:"text-right mt-4",children:(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},eQ=e=>{let{teamId:l,accessToken:s,currentAliases:t,availableModels:a,onUpdate:n}=e,[o,d]=(0,i.useState)(!1),[c]=k.Z.useForm(),m=async e=>{try{if(!s)return;let a={...t,[e.alias_name]:e.original_model};await (0,x.Gh)(s,{team_id:l,model_aliases:a}),I.ZP.success("Model alias created successfully"),d(!1),c.resetFields(),t[e.alias_name]=e.original_model}catch(e){I.ZP.error("Failed to create model alias"),console.error("Error creating model alias:",e)}};return(0,r.jsxs)("div",{className:"mt-8",children:[(0,r.jsx)(w.Z,{children:"Team Aliases"}),(0,r.jsx)(b.Z,{className:"text-gray-600 mb-4",children:"Allow a team to use an alias that points to a specific model deployment."}),(0,r.jsxs)("div",{className:"bg-white rounded-lg p-6 border border-gray-200",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsx)("div",{children:(0,r.jsxs)("div",{className:"flex space-x-4 text-gray-600",children:[(0,r.jsx)("div",{className:"w-64",children:"ALIAS"}),(0,r.jsx)("div",{children:"POINTS TO"})]})}),(0,r.jsx)(f.Z,{size:"md",variant:"primary",onClick:()=>d(!0),children:"Create Model Alias"})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[Object.entries(t).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)("div",{className:"flex space-x-4 border-t border-gray-200 pt-4",children:[(0,r.jsx)("div",{className:"w-64",children:(0,r.jsx)("span",{className:"bg-gray-100 px-2 py-1 rounded font-mono text-sm text-gray-700",children:s})}),(0,r.jsx)("div",{children:(0,r.jsx)("span",{className:"bg-gray-100 px-2 py-1 rounded font-mono text-sm text-gray-700",children:t})})]},l)}),0===Object.keys(t).length&&(0,r.jsx)("div",{className:"text-gray-500 text-center py-4 border-t border-gray-200",children:"No model aliases configured"})]})]}),(0,r.jsx)(C.Z,{title:"Create Model Alias",open:o,onCancel:()=>{d(!1),c.resetFields()},footer:null,width:500,children:(0,r.jsxs)(k.Z,{form:c,onFinish:m,layout:"vertical",className:"mt-4",children:[(0,r.jsx)(k.Z.Item,{label:"Alias Name",name:"alias_name",rules:[{required:!0,message:"Please enter an alias name"}],children:(0,r.jsx)(E.Z,{placeholder:"Enter the model alias (e.g., gpt-4o)",type:""})}),(0,r.jsx)(k.Z.Item,{label:"Points To",name:"original_model",rules:[{required:!0,message:"Please select a model"}],children:(0,r.jsx)(S.default,{placeholder:"Select model version",className:"w-full font-mono",showSearch:!0,optionFilterProp:"children",children:a.map(e=>(0,r.jsx)(S.default.Option,{value:e,className:"font-mono",children:e},e))})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(f.Z,{size:"md",variant:"secondary",onClick:()=>{d(!1),c.resetFields()},className:"bg-white text-gray-700 border border-gray-300 hover:bg-gray-50",children:"Cancel"}),(0,r.jsx)(f.Z,{size:"md",variant:"secondary",type:"submit",children:"Create Alias"})]})]})})]})},e0=e=>{var l,s,t;let{teamId:a,onClose:n,accessToken:o,is_team_admin:d,is_proxy_admin:c,userModels:m,editTeam:u}=e,[h,p]=(0,i.useState)(null),[j,Z]=(0,i.useState)(!0),[_,y]=(0,i.useState)(!1),[v]=k.Z.useForm(),[N,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),[D,L]=(0,i.useState)(!1);console.log("userModels in team info",m);let z=d||c,U=async()=>{try{if(Z(!0),!o)return;let e=await (0,x.Xm)(o,a);p(e)}catch(e){I.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{Z(!1)}};(0,i.useEffect)(()=>{U()},[a,o]);let V=async e=>{try{if(null==o)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.cu)(o,a,l),I.ZP.success("Team member added successfully"),y(!1),v.resetFields(),U()}catch(e){I.ZP.error("Failed to add team member"),console.error("Error adding team member:",e)}},q=async e=>{try{if(null==o)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.sN)(o,a,l),I.ZP.success("Team member updated successfully"),C(!1),U()}catch(e){I.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},B=async e=>{try{if(null==o)return;await (0,x.Lp)(o,a,e),I.ZP.success("Team member removed successfully"),U()}catch(e){I.ZP.error("Failed to remove team member"),console.error("Error removing team member:",e)}},K=async e=>{try{var l;if(!o)return;let s={team_id:a,team_alias:e.team_alias,models:e.models,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration,metadata:{...null==h?void 0:null===(l=h.team_info)||void 0===l?void 0:l.metadata,guardrails:e.guardrails||[]}};await (0,x.Gh)(o,s),I.ZP.success("Team settings updated successfully"),L(!1),U()}catch(e){I.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(j)return(0,r.jsx)("div",{className:"p-4",children:"Loading..."});if(!(null==h?void 0:h.team_info))return(0,r.jsx)("div",{className:"p-4",children:"Team not found"});let{team_info:W}=h;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:n,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:W.team_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:W.team_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:u?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",W.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===W.max_budget?"Unlimited":"$".concat(W.max_budget)]}),W.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",W.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",W.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",W.rpm_limit||"Unlimited"]}),W.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",W.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:W.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:h.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)($.Z,{children:z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{T(e),C(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>B(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(f.Z,{onClick:()=>y(!0),children:"Add Member"})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Team Settings"}),z&&!D&&(0,r.jsx)(f.Z,{onClick:()=>L(!0),children:"Edit Settings"})]}),D?(0,r.jsxs)(k.Z,{form:v,onFinish:K,initialValues:{...W,team_alias:W.team_alias,models:W.models,tpm_limit:W.tpm_limit,rpm_limit:W.rpm_limit,max_budget:W.max_budget,budget_duration:W.budget_duration,guardrails:(null===(l=W.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(E.Z,{type:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),m.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>L(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:W.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:W.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(W.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:W.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",W.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",W.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==W.max_budget?"$".concat(W.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",W.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:W.blocked?"red":"green",children:W.blocked?"Blocked":"Active"})]})]})]}),(0,r.jsx)(eQ,{teamId:a,accessToken:o,currentAliases:(null==h?void 0:null===(t=h.team_info)||void 0===t?void 0:null===(s=t.litellm_model_table)||void 0===s?void 0:s.model_aliases)||{},availableModels:m,onUpdate:U})]})]})]}),(0,r.jsx)(eY,{visible:N,onCancel:()=>C(!1),onSubmit:q,initialData:A,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Admin",value:"admin"},{label:"User",value:"user"}]}}),(0,r.jsx)(eX,{isVisible:_,onCancel:()=>y(!1),onSubmit:V,accessToken:o})]})};function e1(e){var l,s,t,a,n,o,d,c,m,u,h;let{modelId:p,onClose:j,modelData:Z,accessToken:_,userID:y,userRole:v,editModel:N,setEditModalVisible:S,setSelectedModel:C}=e,[A,P]=(0,i.useState)(!1),[E]=k.Z.useForm(),[T,M]=(0,i.useState)(!1),D="Admin"===v;if(!Z)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsx)(b.Z,{children:"Model not found"})]});let L=async()=>{try{if(!_)return;await (0,x.Og)(_,p),I.ZP.success("Model deleted successfully"),j()}catch(e){console.error("Error deleting the model:",e),I.ZP.error("Failed to delete model")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsxs)(w.Z,{children:["Public Model Name: ",eM(Z)]}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:Z.model_info.id})]}),D&&(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>M(!0),className:"flex items-center",children:"Delete Model"})})]}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-6",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Raw JSON"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6 mb-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Provider"}),(0,r.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[Z.provider&&(0,r.jsx)("img",{src:eP(Z.provider).logo,alt:"".concat(Z.provider," logo"),className:"w-4 h-4",onError:e=>{let l=e.target,s=l.parentElement;if(s){var t;let e=document.createElement("div");e.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=(null===(t=Z.provider)||void 0===t?void 0:t.charAt(0))||"-",s.replaceChild(e,l)}}}),(0,r.jsx)(w.Z,{children:Z.provider||"Not Set"})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"LiteLLM Model"}),(0,r.jsx)("pre",{children:(0,r.jsx)(w.Z,{children:Z.litellm_model_name||"Not Set"})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Pricing"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Input: $",Z.input_cost,"/1M tokens"]}),(0,r.jsxs)(b.Z,{children:["Output: $",Z.output_cost,"/1M tokens"]})]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Model Settings"}),D&&!A&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>P(!0),children:"Edit Settings"})]}),A?(0,r.jsx)(eL,{visible:A,onCancel:()=>P(!1),model:Z,onSubmit:e=>eD(e,_,S,C)}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model ID"}),(0,r.jsx)("div",{className:"font-mono",children:Z.model_info.id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Public Model Name"}),(0,r.jsx)("div",{children:eM(Z)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Model Name"}),(0,r.jsx)("div",{children:Z.litellm_model_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Input Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(l=Z.litellm_params)||void 0===l?void 0:l.input_cost_per_token)?(1e6*Z.litellm_params.input_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Output Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(s=Z.litellm_params)||void 0===s?void 0:s.output_cost_per_token)?(1e6*Z.litellm_params.output_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"API Base"}),(0,r.jsx)("div",{children:(null===(t=Z.litellm_params)||void 0===t?void 0:t.api_base)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Custom LLM Provider"}),(0,r.jsx)("div",{children:(null===(a=Z.litellm_params)||void 0===a?void 0:a.custom_llm_provider)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model"}),(0,r.jsx)("div",{children:(null===(n=Z.litellm_params)||void 0===n?void 0:n.model)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)("div",{children:(null===(o=Z.litellm_params)||void 0===o?void 0:o.organization)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"TPM (Tokens per Minute)"}),(0,r.jsx)("div",{children:(null===(d=Z.litellm_params)||void 0===d?void 0:d.tpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"RPM (Requests per Minute)"}),(0,r.jsx)("div",{children:(null===(c=Z.litellm_params)||void 0===c?void 0:c.rpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Max Retries"}),(0,r.jsx)("div",{children:(null===(m=Z.litellm_params)||void 0===m?void 0:m.max_retries)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(u=Z.litellm_params)||void 0===u?void 0:u.timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Stream Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(h=Z.litellm_params)||void 0===h?void 0:h.stream_timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{children:Z.model_info.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:Z.model_info.created_at?new Date(Z.model_info.created_at).toLocaleString():"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created By"}),(0,r.jsx)("div",{children:Z.model_info.created_by||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Parameters"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(Z.cleanedLitellmParams,null,2)})]})]})]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsx)("pre",{className:"bg-gray-100 p-4 rounded text-xs overflow-auto",children:JSON.stringify(Z,null,2)})})})]})]}),T&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Model"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this model?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(O.ZP,{onClick:L,className:"ml-2",danger:!0,children:"Delete"}),(0,r.jsx)(O.ZP,{onClick:()=>M(!1),children:"Cancel"})]})]})]})})]})}var e2=s(67960),e4=s(47451),e5=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,i=k.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,r.jsx)(k.Z.Item,{name:"model",rules:[{required:!0,message:"Please select at least one model."}],noStyle:!0,children:l===a.Azure||l===a.OpenAI_Compatible||l===a.Ollama?(0,r.jsx)(Z.Z,{placeholder:t(l)}):s.length>0?(0,r.jsx)(S.default,{mode:"multiple",allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{let l=Array.isArray(e)?e:[e];if(l.includes("all-wildcard"))i.setFieldsValue({model_name:void 0,model_mappings:[]});else{let e=l.map(e=>({public_name:e,litellm_model:e}));i.setFieldsValue({model_mappings:e})}},optionFilterProp:"children",filterOption:(e,l)=>{var s;return(null!==(s=null==l?void 0:l.label)&&void 0!==s?s:"").toLowerCase().includes(e.toLowerCase())},options:[{label:"All ".concat(l," Models (Wildcard)"),value:"all-wildcard"},...s.map(e=>({label:e,value:e})),{label:"Custom Model Name (Enter below)",value:"custom"}],style:{width:"100%"}}):(0,r.jsx)(Z.Z,{placeholder:t(l)})}),(0,r.jsx)(k.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,r.jsx)(k.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name."}],className:"mt-2",children:(0,r.jsx)(Z.Z,{placeholder:"Enter custom model name"})})}})]}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},e3=s(48379),e6=()=>{let e=k.Z.useFormInstance(),l=k.Z.useWatch("model",e)||[],s=!l.includes("all-wildcard");if((0,i.useEffect)(()=>{if(l.length>0&&!l.includes("all-wildcard")){let s=l.map(e=>({public_name:e,litellm_model:e}));e.setFieldValue("model_mappings",s)}},[l,e]),!s)return null;let t=[{title:"Public Name",dataIndex:"public_name",key:"public_name",render:(l,s,t)=>(0,r.jsx)(Z.Z,{defaultValue:l,onChange:l=>{let s=[...e.getFieldValue("model_mappings")];s[t].public_name=l.target.value,e.setFieldValue("model_mappings",s)}})},{title:"LiteLLM Model",dataIndex:"litellm_model",key:"litellm_model"}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Model Mappings",name:"model_mappings",tooltip:"Map public model names to LiteLLM model names for load balancing",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!0,children:(0,r.jsx)(e3.Z,{dataSource:e.getFieldValue("model_mappings"),columns:t,pagination:!1,size:"small"})}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})},e8=s(87024),e7=s(3632);let{Link:e9}=eS.default;var le=e=>{let{selectedProvider:l,uploadProps:s}=e;console.log("Selected provider: ".concat(l)),console.log("type of selectedProvider: ".concat(typeof l));let t=a[l];return console.log("selectedProviderEnum: ".concat(t)),console.log("type of selectedProviderEnum: ".concat(typeof t)),(0,r.jsxs)(r.Fragment,{children:[t===a.OpenAI&&(0,r.jsx)(k.Z.Item,{label:"OpenAI Organization ID",name:"organization",children:(0,r.jsx)(Z.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),t===a.Vertex_AI&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,r.jsx)(Z.Z,{placeholder:"adroit-cadet-1234.."})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(e8.Z,{...s,children:(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(e7.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]})]}),t===a.AssemblyAI&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(S.default,{placeholder:"Select API Base",children:[(0,r.jsx)(S.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(S.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsx)(Z.Z,{placeholder:"https://..."})}),t===a.Azure&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"API Version",name:"api_version",tooltip:"By default litellm will use the latest version. If you want to use a different version, you can specify it here",children:(0,r.jsx)(Z.Z,{placeholder:"2023-07-01-preview"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(k.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,r.jsx)(Z.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(e9,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]})]}),t===a.Bedrock&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})})]}),t!=a.Bedrock&&t!=a.Vertex_AI&&t!=a.Ollama&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",tooltip:"LLM API Credentials",children:(0,r.jsx)(Z.Z,{placeholder:"sk-",type:"password"})})]})},ll=s(63709),ls=s(90464);let{Link:lt}=eS.default;var la=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s,teams:t}=e,[a]=k.Z.useForm(),[n,o]=i.useState(!1),[d,c]=i.useState("per_token"),m=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),u=(e,l)=>{if(!l)return Promise.resolve();try{return JSON.parse(l),Promise.resolve()}catch(e){return Promise.reject("Please enter valid JSON")}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(_.Z,{className:"mt-2 mb-4",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Advanced Settings"})}),(0,r.jsx)(y.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",className:"mb-4",children:(0,r.jsx)(L,{teams:t})}),(0,r.jsx)(k.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(ll.Z,{onChange:e=>{o(e),e||a.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),n&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(k.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:"per_token",onChange:e=>c(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(k.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(k.Z.Item,{label:"Use in pass through routes",name:"use_in_pass_through",valuePropName:"checked",className:"mb-4 mt-4",tooltip:(0,r.jsxs)("span",{children:["Allow using these credentials in pass through routes."," ",(0,r.jsx)(lt,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(ll.Z,{onChange:e=>{let l=a.getFieldValue("litellm_extra_params");try{let s=l?JSON.parse(l):{};e?s.use_in_pass_through=!0:delete s.use_in_pass_through,Object.keys(s).length>0?a.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):a.setFieldValue("litellm_extra_params","")}catch(l){e?a.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):a.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(k.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-4 mt-4",rules:[{validator:u}],children:(0,r.jsx)(ls.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(e4.Z,{className:"mb-4",children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(lt,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(k.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",rules:[{validator:u}],children:(0,r.jsx)(ls.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})};let{Title:lr,Link:li}=eS.default;var ln=e=>{let{form:l,handleOk:s,selectedProvider:t,setSelectedProvider:i,providerModels:n,setProviderModelsFn:o,getPlaceholder:d,uploadProps:c,showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lr,{level:2,children:"Add new model"}),(0,r.jsx)(e2.Z,{children:(0,r.jsx)(k.Z,{form:l,onFinish:s,labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,r.jsx)(S.default,{showSearch:!0,value:t,onChange:e=>{i(e),o(e),l.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(S.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eA[s],alt:"".concat(l," logo"),className:"w-5 h-5",onError:e=>{let l=e.target,t=l.parentElement;if(t){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=s.charAt(0),t.replaceChild(e,l)}}}),(0,r.jsx)("span",{children:s})]})},l)})})}),(0,r.jsx)(e5,{selectedProvider:t,providerModels:n,getPlaceholder:d}),(0,r.jsx)(e6,{}),(0,r.jsx)(le,{selectedProvider:t,uploadProps:c}),(0,r.jsx)(la,{showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}),(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(R.Z,{title:"Get help on our github",children:(0,r.jsx)(eS.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]})};let{Title:lo,Link:ld}=eS.default,lc={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var lm=e=>{let{accessToken:l,token:s,userRole:t,userID:n,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m,teams:u}=e,[h,p]=(0,i.useState)([]),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(""),[N,S]=(0,i.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[C,A]=(0,i.useState)([]),[E,O]=(0,i.useState)(a.OpenAI),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(!1),[F,z]=(0,i.useState)(null),[U,V]=(0,i.useState)([]),[q,B]=(0,i.useState)([]),[K,W]=(0,i.useState)(null),[H,G]=(0,i.useState)([]),[el,em]=(0,i.useState)([]),[eh,ex]=(0,i.useState)([]),[ep,ej]=(0,i.useState)([]),[eg,eZ]=(0,i.useState)([]),[e_,ey]=(0,i.useState)([]),[ev,eb]=(0,i.useState)([]),[ew,eN]=(0,i.useState)([]),[ek,eA]=(0,i.useState)([]),[eW,eH]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eY,eJ]=(0,i.useState)(null),[e$,eX]=(0,i.useState)(0),[eQ,e2]=(0,i.useState)({}),[e4,e5]=(0,i.useState)([]),[e3,e6]=(0,i.useState)(!1),[e8,e7]=(0,i.useState)(null),[e9,le]=(0,i.useState)(null),[ll,ls]=(0,i.useState)([]),[lt,la]=(0,i.useState)(!1),[lr,li]=(0,i.useState)(null),[lo,ld]=(0,i.useState)(!1),[lm,lu]=(0,i.useState)(null),lh=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!n||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),W(e);let r=null==e8?void 0:e8.token;void 0===r&&(r=null);let i=e9;void 0===i&&(i=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,x.o6)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model metrics response:",o),em(o.data),ex(o.all_api_bases);let d=await (0,x.Rg)(l,e,s.toISOString(),a.toISOString());ej(d.data),eZ(d.all_api_bases);let c=await (0,x.N8)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model exceptions response:",c),ey(c.data),eb(c.exception_types);let m=await (0,x.fP)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);if(console.log("slowResponses:",m),eA(m),e){let t=await (0,x.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e2(t);let r=await (0,x.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e5(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,i.useEffect)(()=>{lh(K,eW.from,eW.to)},[e8,e9]);let lx=e=>{z(e),L(!0)},lp=()=>{v(new Date().toLocaleString())},lj=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eY);try{await (0,x.K_)(l,{router_settings:{model_group_retry_policy:eY}}),I.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),I.ZP.error("Failed to save retry settings")}};if((0,i.useEffect)(()=>{if(!l||!s||!t||!n)return;let e=async()=>{try{var e,s,a,r,i,o,d,m,u,h,p,j;let g=await (0,x.hy)(l);A(g);let f=await (0,x.AZ)(l,n,t);console.log("Model data response:",f.data),c(f);let Z=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",K);let v=await (0,x.o6)(l,n,t,y,null===(e=eW.from)||void 0===e?void 0:e.toISOString(),null===(s=eW.to)||void 0===s?void 0:s.toISOString(),null==e8?void 0:e8.token,e9);console.log("Model metrics response:",v),em(v.data),ex(v.all_api_bases);let b=await (0,x.Rg)(l,y,null===(a=eW.from)||void 0===a?void 0:a.toISOString(),null===(r=eW.to)||void 0===r?void 0:r.toISOString());ej(b.data),eZ(b.all_api_bases);let w=await (0,x.N8)(l,n,t,y,null===(i=eW.from)||void 0===i?void 0:i.toISOString(),null===(o=eW.to)||void 0===o?void 0:o.toISOString(),null==e8?void 0:e8.token,e9);console.log("Model exceptions response:",w),ey(w.data),eb(w.exception_types);let N=await (0,x.fP)(l,n,t,y,null===(d=eW.from)||void 0===d?void 0:d.toISOString(),null===(m=eW.to)||void 0===m?void 0:m.toISOString(),null==e8?void 0:e8.token,e9),S=await (0,x.n$)(l,null===(u=eW.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=eW.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);e2(S);let k=await (0,x.v9)(l,null===(p=eW.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=eW.to)||void 0===j?void 0:j.toISOString().split("T")[0],y);e5(k),console.log("dailyExceptions:",S),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",N),eA(N);let I=await (0,x.j2)(l);ls(null==I?void 0:I.end_users);let C=(await (0,x.BL)(l,n,t)).router_settings;console.log("routerSettingsInfo:",C);let P=C.model_group_retry_policy,E=C.num_retries;console.log("model_group_retry_policy:",P),console.log("default_retries:",E),eJ(P),eX(E)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&n&&e();let a=async()=>{let e=await (0,x.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),_(e)};null==Z&&a(),lp()},[l,s,t,n,Z,y]),!o||!l||!s||!t||!n)return(0,r.jsx)("div",{children:"Loading..."});let lg=[],lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(Z)),null!=Z&&"object"==typeof Z&&e in Z)?Z[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(r=t)||(r=1===e.length?u(s):l)}else r="-";a&&(i=null==a?void 0:a.input_cost_per_token,n=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==l?void 0:l.litellm_params)&&(m=Object.fromEntries(Object.entries(null==l?void 0:l.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),o.data[e].provider=r,o.data[e].input_cost=i,o.data[e].output_cost=n,o.data[e].litellm_model_name=s,lf.push(r),o.data[e].input_cost&&(o.data[e].input_cost=(1e6*Number(o.data[e].input_cost)).toFixed(2)),o.data[e].output_cost&&(o.data[e].output_cost=(1e6*Number(o.data[e].output_cost)).toFixed(2)),o.data[e].max_tokens=d,o.data[e].max_input_tokens=c,o.data[e].api_base=null==l?void 0:null===(ly=l.litellm_params)||void 0===ly?void 0:ly.api_base,o.data[e].cleanedLitellmParams=m,lg.push(l.model_name),console.log(o.data[e])}if(o.data&&o.data.length>0&&o.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lv=async()=>{try{I.ZP.info("Running health check..."),M("");let e=await (0,x.EY)(l);M(e)}catch(e){console.error("Error running health check:",e),M("Error running health check")}},lb=(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Select API Key Name"}),m?(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{e7(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{le(e)},children:e},l))]})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsxs)(et.Z,{value:String(l),disabled:!0,onClick:()=>{e7(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{le(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lw=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let i=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,n=t.sort((e,l)=>l.value-e.value);if(n.length>5){let e=n.length-5;(n=n.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,r.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[i&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",i]}),n.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,r.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,r.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})};console.log("selectedProvider: ".concat(E)),console.log("providerModels.length: ".concat(N.length));let lN=Object.keys(a).find(e=>a[e]===E);return(lN&&C.find(e=>e.name===eC[lN]),lm)?(0,r.jsx)("div",{className:"w-full h-full",children:(0,r.jsx)(e0,{teamId:lm,onClose:()=>lu(null),accessToken:l,is_team_admin:"Admin"===t,is_proxy_admin:"Proxy Admin"===t,userModels:lg,editTeam:!1})}):(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:lr?(0,r.jsx)(e1,{modelId:lr,editModel:!0,onClose:()=>{li(null),ld(!1)},modelData:o.data.find(e=>e.model_info.id===lr),accessToken:l,userID:n,userRole:t,setEditModalVisible:L,setSelectedModel:z}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"All Models"}),(0,r.jsx)(ei.Z,{children:"Add Model"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(ei.Z,{children:"Model Analytics"}),(0,r.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[y&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",y]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lp})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||void 0,onValueChange:e=>W("all"===e?"all":e),value:K||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Model ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created At":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created By":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Team ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:o.data.filter(e=>"all"===K||e.model_name===K||null==K||""===K).map((e,s)=>{var a;return(0,r.jsxs)(ee.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.model_info.id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>li(e.model_info.id),children:[e.model_info.id.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:eM(e)||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[e.provider&&(0,r.jsx)("img",{src:eP(e.provider).logo,alt:"".concat(e.provider," logo"),className:"w-4 h-4",onError:l=>{let s=l.target,t=s.parentElement;if(t){var a;let l=document.createElement("div");l.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",l.textContent=(null===(a=e.provider)||void 0===a?void 0:a.charAt(0))||"-",t.replaceChild(l,s)}}}),(0,r.jsx)("p",{className:"text-xs",children:e.provider||"-"})]})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.litellm_model_name,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.litellm_model_name?e.litellm_model_name:"",children:e&&e.litellm_model_name?e.litellm_model_name.slice(0,20)+(e.litellm_model_name.length>20?"...":""):"-"})})}),"Admin"===t&&(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.api_base,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:null!=e.litellm_params.input_cost_per_token&&void 0!=e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&((a=e.model_info.created_at)?new Date(a).toLocaleDateString("en-US"):null)||"-"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:e.model_info.team_id?(0,r.jsx)(R.Z,{title:e.model_info.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-purple-500 bg-purple-50 hover:bg-purple-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{lu(e.model_info.team_id)},children:[e.model_info.team_id.slice(0,7),"..."]})}):"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,r.jsx)(ea.Z,{size:"xs",className:"text-white",children:(0,r.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,r.jsx)(ea.Z,{size:"xs",className:"text-black",children:(0,r.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>lx(e)})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eK,{modelID:e.model_info.id,accessToken:l,callback:lp})})]})})]},s)})})]})})]}),(0,r.jsx)(eL,{visible:D,onCancel:()=>{L(!1),z(null)},model:F,onSubmit:e=>eD(e,l,L,z)})]}),(0,r.jsx)(ed.Z,{className:"h-full",children:(0,r.jsx)(ln,{form:j,handleOk:()=>{j.validateFields().then(e=>{eT(e,l,j,lp)}).catch(e=>{console.error("Validation failed:",e)})},selectedProvider:E,setSelectedProvider:O,providerModels:N,setProviderModelsFn:e=>{let l=eO(e,Z);S(l),console.log("providerModels: ".concat(l))},getPlaceholder:eE,uploadProps:{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;j.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?I.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&I.ZP.error("".concat(e.file.name," file upload failed."))}},showAdvancedSettings:lt,setShowAdvancedSettings:la,teams:u})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(f.Z,{onClick:lv,children:"Run `/health`"}),T&&(0,r.jsx)("pre",{children:JSON.stringify(T,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:eW,className:"mr-2",onValueChange:e=>{eH(e),lh(K,e.from,e.to)}})]}),(0,r.jsxs)(eV.Z,{className:"ml-2",children:[(0,r.jsx)(b.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:K||U[0],value:K||U[0],children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lh(e,eW.from,eW.to),children:e},l))})]}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eq.Z,{trigger:"click",content:lb,overlayStyle:{width:"20vw"},children:(0,r.jsx)(f.Z,{icon:ef.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>e6(!0)})})})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,r.jsx)(b.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),el&&eh&&(0,r.jsx)(ez.Z,{title:"Model Latency",className:"h-72",data:el,showLegend:!1,index:"date",categories:eh,connectNulls:!0,customTooltip:lw})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(eG,{modelMetrics:ep,modelMetricsCategories:eg,customTooltip:lw,premiumUser:m})})]})]})})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Deployment"}),(0,r.jsx)(Q.Z,{children:"Success Responses"}),(0,r.jsxs)(Q.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(J.Z,{children:ek.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.api_base}),(0,r.jsx)($.Z,{children:e.total_count}),(0,r.jsx)($.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Exceptions for ",K]}),(0,r.jsx)(eU.Z,{className:"h-60",data:e_,index:"model",categories:ev,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Up Rate Limit Errors (429) for ",K]}),(0,r.jsxs)(g.Z,{numItems:1,children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",eQ.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:eQ.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eV.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:e4.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,r.jsx)(r.Fragment,{children:e4&&e4.length>0&&e4.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||U[0],value:K||U[0],onValueChange:e=>W(e),children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))})]}),(0,r.jsxs)(w.Z,{children:["Retry Policy for ",K]}),(0,r.jsx)(b.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lc&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(lc).map((e,l)=>{var s;let[t,a]=e,i=null==eY?void 0:null===(s=eY[K])||void 0===s?void 0:s[a];return null==i&&(i=e$),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(P.Z,{className:"ml-5",value:i,min:0,step:1,onChange:e=>{eJ(l=>{var s;let t=null!==(s=null==l?void 0:l[K])&&void 0!==s?s:{};return{...null!=l?l:{},[K]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(f.Z,{className:"mt-6 mr-8",onClick:lj,children:"Save"})]})]})]})})};function lu(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:i,Paragraph:n}=eS.default,o=()=>(null==a?void 0:a.has_user_setup_sso)?new URL("/ui",t).toString():new URL("/ui?invitation_id=".concat(null==a?void 0:a.id),t).toString();return(0,r.jsxs)(C.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(n,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(b.Z,{children:null==a?void 0:a.user_id})]}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{children:"Invitation Link"}),(0,r.jsx)(b.Z,{children:(0,r.jsx)(b.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>I.ZP.success("Copied!"),children:(0,r.jsx)(f.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:lh}=S.default;var lx=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,i.useState)(null),[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[j,g]=(0,i.useState)([]),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(null),N=(0,n.useRouter)(),[A,P]=(0,i.useState)("http://localhost:4000");(0,i.useEffect)(()=>{(async()=>{try{let e=await (0,x.So)(s,l,"any"),t=[];for(let l=0;l{N&&P(new URL("/",window.location.href).toString())},[N]);let T=async e=>{try{var t;I.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,x.Ov)(s,null,e);console.log("user create Response:",a),p(a.key);let r=(null===(t=a.data)||void 0===t?void 0:t.user_id)||a.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:r,is_accepted:!1,accepted_at:null,expires_at:new Date(Date.now()+6048e5),created_at:new Date,created_by:l,updated_at:new Date,updated_by:l,has_user_setup_sso:!0};w(e),y(!0)}else(0,x.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,w(e),y(!0)});I.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(C.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),p(null),c.resetFields()},children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(k.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(S.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(lh,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(lh,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(lu,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:y,baseUrl:A,invitationLinkData:v})]})},lp=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:n}=e,[o,d]=(0,i.useState)(a),[c]=k.Z.useForm();(0,i.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{n(e),c.resetFields(),t()};return a?(0,r.jsx)(C.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(k.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",help:"Across all keys (including keys with team_id).",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",help:"Ignored if the key has a team_id; team budget applies there.",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var lj=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:n,teams:o,setKeys:d}=e,[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(1),[y,v]=i.useState(null),[b,w]=(0,i.useState)(null),[N,S]=(0,i.useState)(!1),[k,C]=(0,i.useState)(null),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(null),[T,M]=(0,i.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let D=e=>{O(e),P(!0)},L=async()=>{if(E&&l)try{if(await (0,x.Eb)(l,[E]),I.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==E);h(e)}}catch(e){console.error("Error deleting user:",e),I.ZP.error("Failed to delete user")}P(!1),O(null)},F=async()=>{C(null),S(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&n){try{await (0,x.pf)(l,e,null),I.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}u&&h(u.map(l=>l.user_id===e.user_id?e:l)),C(null),S(!1)}};return((0,i.useEffect)(()=>{if(!l||!s||!a||!n)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,x.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)M(JSON.parse(s));else{let e=await (0,x.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),M(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&n&&e()},[l,s,a,n,Z]),u&&l&&s&&a&&n)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(g.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(lx,{userID:n,accessToken:l,teams:o,possibleUIRoles:T}),(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,r.jsx)("div",{className:"mb-4 mt-1"}),(0,r.jsx)(en.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(Y.Z,{className:"mt-5",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(Q.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(Q.Z,{children:"API Keys"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.user_id||"-"}),(0,r.jsx)($.Z,{children:e.user_email||"-"}),(0,r.jsx)($.Z,{children:(null==T?void 0:null===(l=T[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,r.jsx)($.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)($.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)($.Z,{children:(0,r.jsx)(g.Z,{numItems:2,children:e.key_count>0?(0,r.jsxs)(ea.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,r.jsx)(ea.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,onClick:()=>{C(e),S(!0)},children:"View Keys"}),(0,r.jsx)(eR.Z,{icon:eh.Z,onClick:()=>D(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,r.jsx)(lp,{visible:N,possibleUIRoles:T,onCancel:F,user:k,onSubmit:R}),A&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,r.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),_(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},lg=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,i.useState)([]);(0,i.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,x.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let n=async e=>{if(l&&s)try{await (0,x.cu)(l,e,{user_id:s,role:"user"}),I.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),I.ZP.error("Failed to join team")}};return(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Description"}),(0,r.jsx)(Q.Z,{children:"Members"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsxs)(J.Z,{children:[t.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.team_alias})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.description||"No description available"})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"flex flex-col",children:e.models&&0!==e.models.length?e.models.map((e,l)=>(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,r.jsx)(ea.Z,{size:"xs",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{size:"xs",variant:"secondary",onClick:()=>n(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(b.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};let lf=(e,l)=>{let s=[];return e&&e.models.length>0?(console.log("organization.models: ".concat(e.models)),s=e.models):s=l,D(s,l)};var lZ=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:n,userRole:o,organizations:d}=e,[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(null),[w,N]=(0,i.useState)(null);(0,i.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&p(t,n,o,u,a),eO()},[c]);let[A]=k.Z.useForm(),[E]=k.Z.useForm(),{Title:D,Paragraph:L}=eS.default,[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(!1),[es,et]=(0,i.useState)(!1),[em,ex]=(0,i.useState)(!1),[ep,ej]=(0,i.useState)(!1),[eg,ef]=(0,i.useState)([]),[eZ,e_]=(0,i.useState)(!1),[ey,ev]=(0,i.useState)(null),[eb,ew]=(0,i.useState)([]),[eN,ek]=(0,i.useState)({}),[eI,eC]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("currentOrgForCreateTeam: ".concat(w));let e=lf(w,eg);console.log("models: ".concat(e)),ew(e),A.setFieldValue("models",[])},[w,eg]),(0,i.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,x.t3)(t)).guardrails.map(e=>e.guardrail_name);eC(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let eA=async e=>{ev(e),e_(!0)},eP=async()=>{if(null!=ey&&null!=l&&null!=t){try{await (0,x.rs)(t,ey),p(t,n,o,u,a)}catch(e){console.error("Error deleting the team:",e)}e_(!1),ev(null)}};(0,i.useEffect)(()=>{(async()=>{try{if(null===n||null===o||null===t)return;let e=await T(n,o,t);e&&ef(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,n,o,l]);let eE=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,i=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],n=(null==e?void 0:e.organization_id)||(null==u?void 0:u.organization_id);if(""===n||"string"!=typeof n?e.organization_id=null:e.organization_id=n.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,i.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));I.ZP.info("Creating Team");let o=await (0,x.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),I.ZP.success("Team created"),et(!1)}}catch(e){console.error("Error creating the team:",e),I.ZP.error("Error creating the team: "+e,20)}},eO=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:W?(0,r.jsx)(e0,{teamId:W,onClose:()=>{H(null),el(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===W)),is_proxy_admin:"Admin"==o,userModels:eg,editTeam:G}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Your Teams"}),(0,r.jsx)(ei.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:eO})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(b.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-hidden overflow-y-auto max-h-[50vh]",children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Team ID"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Organization"}),(0,r.jsx)(Q.Z,{children:"Info"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.filter(e=>!u||e.organization_id===u.organization_id).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{H(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!==e.max_budget&&void 0!==e.max_budget?e.max_budget:"No limit"}),(0,r.jsx)($.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)($.Z,{children:e.organization_id}),(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].keys&&eN[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].members_with_roles&&eN[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)($.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{H(e.team_id),el(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>eA(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),eZ&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eP,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{e_(!1),ev(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>et(!0),children:"+ Create New Team"}),(0,r.jsx)(C.Z,{title:"Create Team",visible:es,width:800,footer:null,onOk:()=>{et(!1),A.resetFields()},onCancel:()=>{et(!1),A.resetFields()},children:(0,r.jsxs)(k.Z,{form:A,onFinish:eE,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Organization",name:"organization_id",initialValue:u?u.organization_id:null,className:"mt-8",children:(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{A.setFieldValue("organization_id",e),N((null==d?void 0:d.find(l=>l.organization_id===e))||null)},filterOption:(e,l)=>{var s;return!!l&&((null===(s=l.children)||void 0===s?void 0:s.toString())||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==d?void 0:d.map(e=>(0,r.jsxs)(S.default.Option,{value:e.organization_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.organization_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.organization_id,")"]})]},e.organization_id))})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected organization has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),eb.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Additional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",help:"ID of the team you want to create. If not provided, it will be generated automatically.",children:(0,r.jsx)(Z.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eI.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lg,{accessToken:t,userID:n})})]})]})})},l_=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:n,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,i.useState)(null),[h,p]=(0,i.useState)(!0),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(!1),[y,v]=(0,i.useState)(!1),[N,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),D=n||o,L=async()=>{try{if(p(!0),!a)return;let e=await (0,x.t$)(a,s);u(e)}catch(e){I.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{p(!1)}};(0,i.useEffect)(()=>{L()},[s,a]);let F=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.vh)(a,s,l),I.ZP.success("Organization member added successfully"),v(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to add organization member"),console.error("Error adding organization member:",e)}},R=async e=>{try{if(!a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.LY)(a,s,l),I.ZP.success("Organization member updated successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,x.Sb)(a,s,e.user_id),I.ZP.success("Organization member deleted successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to delete organization member"),console.error("Error deleting organization member:",e)}},U=async e=>{try{if(!a)return;let l={organization_id:s,organization_alias:e.organization_alias,models:e.models,litellm_budget_table:{tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration}};if(!(await fetch("/organization/update",{method:"POST",headers:{Authorization:"Bearer ".concat(a),"Content-Type":"application/json"},body:JSON.stringify(l)})).ok)throw Error("Failed to update organization");I.ZP.success("Organization settings updated successfully"),_(!1),L()}catch(e){I.ZP.error("Failed to update organization settings"),console.error("Error updating organization:",e)}};return h?(0,r.jsx)("div",{className:"p-4",children:"Loading..."}):m?(0,r.jsxs)("div",{className:"w-full h-screen p-4 bg-white",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:m.organization_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===m.litellm_budget_table.max_budget?"Unlimited":"$".concat(m.litellm_budget_table.max_budget)]}),m.litellm_budget_table.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[75vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Created At"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)($.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{T({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),C(!0)}}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(f.Z,{onClick:()=>{v(!0)},children:"Add Member"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Organization Settings"}),D&&!Z&&(0,r.jsx)(f.Z,{onClick:()=>_(!0),children:"Edit Settings"})]}),Z?(0,r.jsxs)(k.Z,{form:j,onFinish:U,initialValues:{organization_alias:m.organization_alias,models:m.models,tpm_limit:m.litellm_budget_table.tpm_limit,rpm_limit:m.litellm_budget_table.rpm_limit,max_budget:m.litellm_budget_table.max_budget,budget_duration:m.litellm_budget_table.budget_duration},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>_(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization ID"}),(0,r.jsx)("div",{className:"font-mono",children:m.organization_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(m.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==m.litellm_budget_table.max_budget?"$".concat(m.litellm_budget_table.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",m.litellm_budget_table.budget_duration||"Never"]})]})]})]})})]})]}),(0,r.jsx)(eX,{isVisible:y,onCancel:()=>v(!1),onSubmit:F,accessToken:a,title:"Add Organization Member",roles:[{label:"org_admin",value:"org_admin",description:"Can add and remove members, and change their roles."},{label:"internal_user",value:"internal_user",description:"Can view/create keys for themselves within organization."},{label:"internal_user_viewer",value:"internal_user_viewer",description:"Can only view their keys within organization."}],defaultRole:"internal_user"}),(0,r.jsx)(eY,{visible:N,onCancel:()=>C(!1),onSubmit:R,initialData:A,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Org Admin",value:"org_admin"},{label:"Internal User",value:"internal_user"},{label:"Internal User Viewer",value:"internal_user_viewer"}]}})]}):(0,r.jsx)("div",{className:"p-4",children:"Organization not found"})};let ly=async(e,l)=>{l(await (0,x.r6)(e))};var lv=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:n,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,p]=(0,i.useState)(null),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(!1),[N,A]=(0,i.useState)(null),[E,O]=(0,i.useState)(!1),[T]=k.Z.useForm();(0,i.useEffect)(()=>{0===l.length&&a&&ly(a,m)},[l,a]);let D=e=>{e&&(A(e),w(!0))},L=async()=>{if(N&&a)try{await (0,x.cq)(a,N),I.ZP.success("Organization deleted successfully"),w(!1),A(null),ly(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,x.H1)(a,e),O(!1),T.resetFields(),ly(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(l_,{organizationId:h,onClose:()=>{p(null),y(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:_}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsx)("div",{className:"flex",children:(0,r.jsx)(ei.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[n&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",n]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:o})]})]}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(b.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Organization ID"}),(0,r.jsx)(Q.Z,{children:"Organization Name"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(Q.Z,{children:"Info"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>{var l,t,a,i,n,o,d,c,m;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>p(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{children:e.organization_alias}),(0,r.jsx)($.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{children:e.spend}),(0,r.jsx)($.Z,{children:(null===(t=e.litellm_budget_table)||void 0===t?void 0:t.max_budget)!==null&&(null===(a=e.litellm_budget_table)||void 0===a?void 0:a.max_budget)!==void 0?null===(i=e.litellm_budget_table)||void 0===i?void 0:i.max_budget:"No limit"}),(0,r.jsx)($.Z,{children:Array.isArray(e.models)&&(0,r.jsx)("div",{className:"flex flex-col",children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)},l))})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["TPM: ",(null===(n=e.litellm_budget_table)||void 0===n?void 0:n.tpm_limit)?null===(o=e.litellm_budget_table)||void 0===o?void 0:o.tpm_limit:"Unlimited",(0,r.jsx)("br",{}),"RPM: ",(null===(d=e.litellm_budget_table)||void 0===d?void 0:d.rpm_limit)?null===(c=e.litellm_budget_table)||void 0===c?void 0:c.rpm_limit:"Unlimited"]})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)($.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{p(e.organization_id),y(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>D(e.organization_id),icon:eh.Z,size:"sm"})]})})]},e.organization_id)}):null})]})})}),("Admin"===s||"Org Admin"===s)&&(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>O(!0),children:"+ Create New Organization"}),(0,r.jsx)(C.Z,{title:"Create Organization",visible:E,width:800,footer:null,onCancel:()=>{O(!1),T.resetFields()},children:(0,r.jsxs)(k.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(f.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),v?(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Organization"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this organization?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{w(!1),A(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(b.Z,{children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,r.jsx)("a",{href:"https://litellm.ai/pricing",target:"_blank",rel:"noopener noreferrer",children:"here"}),"."]})})};let lb=()=>{let[e,l]=(0,i.useState)("http://localhost:4000");return(0,i.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lw=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=k.Z.useForm(),[d]=k.Z.useForm(),{Title:c,Paragraph:m}=eS.default,[u,h]=(0,i.useState)(""),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(!1),[w,N]=(0,i.useState)(!1),[S,A]=(0,i.useState)(!1),[P,T]=(0,i.useState)(!1),[M,D]=(0,i.useState)(!1),[L,F]=(0,i.useState)(!1),[R,z]=(0,i.useState)(!1),[U,V]=(0,i.useState)(!1),[q,B]=(0,i.useState)(!1),[K,W]=(0,i.useState)([]),[H,G]=(0,i.useState)(null);(0,n.useRouter)();let[el,es]=(0,i.useState)(null);console.log=function(){};let et=lb(),ea="All IP Addresses Allowed",ei=et;ei+="/fallback/login";let en=async()=>{try{if(!0!==a){I.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,x.PT)(s);W(e&&e.length>0?e:[ea])}else W([ea])}catch(e){console.error("Error fetching allowed IPs:",e),I.ZP.error("Failed to fetch allowed IPs ".concat(e)),W([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,x.eH)(s,e.ip);let l=await (0,x.PT)(s);W(l),I.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),I.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{G(e),B(!0)},ec=async()=>{if(H&&s)try{await (0,x.$I)(s,H);let e=await (0,x.PT)(s);W(e.length>0?e:[ea]),I.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),I.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),G(null)}},em=()=>{F(!1)};(0,i.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,x.Xd)(s,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let t=l.users;console.log("proxy viewers response: ".concat(t)),t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(t));let a=(await (0,x.Xd)(s,"proxy_admin")).users;a.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(a)),console.log("combinedList: ".concat(e)),j(e),es(await (0,x.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=p){var l;I.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,x.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,x.XO)(s,a).then(e=>{_(e),v(!0)}),console.log("response for team create call: ".concat(t));let r=p.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===t.user_id));console.log("foundIndex: ".concat(r)),-1==r&&(console.log("updates admin with new user"),p.push(t),j(p)),o.resetFields(),A(!1)}}catch(e){console.error("Error creating the key:",e)}},eh=async e=>{if(null==s)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,x.K_)(s,l)};return console.log("admins: ".concat(null==p?void 0:p.length)),(0,r.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,r.jsx)(c,{level:4,children:"Admin Access "}),(0,r.jsx)(m,{children:"Go to 'Internal Users' page to add other admins."}),(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(c,{level:4,children:" ✨ Security Settings"}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:()=>!0===a?D(!0):I.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:en,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(C.Z,{title:"Add SSO",visible:M,width:800,footer:null,onOk:()=>{D(!1),o.resetFields()},onCancel:()=>{D(!1),o.resetFields()},children:(0,r.jsxs)(k.Z,{form:o,onFinish:e=>{eu(e),eh(e),D(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,r.jsx)(E.Z.Password,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,r.jsx)(E.Z.Password,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(C.Z,{title:"SSO Setup Instructions",visible:L,width:800,footer:null,onOk:em,onCancel:()=>{F(!1)},children:[(0,r.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(C.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(f.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"IP Address"}),(0,r.jsx)(Q.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(J.Z,{children:K.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e}),(0,r.jsx)($.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(f.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(C.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(k.Z,{onFinish:eo,children:[(0,r.jsx)(k.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,r.jsx)(E.Z,{placeholder:"Enter IP address"})}),(0,r.jsx)(k.Z.Item,{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(C.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(f.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",H,"?"]})})]}),(0,r.jsxs)(eW.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:ei,target:"_blank",children:[(0,r.jsx)("b",{children:ei})," "]})]})]})]})},lN=s(92858),lS=s(44643),lk=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:i}=e,[n]=k.Z.useForm();return(0,r.jsxs)(k.Z,{form:n,onFinish:()=>{console.log("INSIDE ONFINISH");let e=n.getFieldsValue(),l=Object.entries(e).every(e=>{let[l,s]=e;return"boolean"!=typeof s&&(""===s||null==s)});console.log("formData: ".concat(JSON.stringify(e),", isEmpty: ").concat(l)),l?console.log("Some form fields are empty."):a(e)},labelAlign:"left",children:[l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{align:"center",children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?i?(0,r.jsx)(k.Z.Item,{name:e.field_name,children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lN.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,r.jsx)(k.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lN.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),n.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lS.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lI=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(0,x.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lk,{alertingSettings:t,handleInputChange:(e,l)=>{let s=t.map(s=>s.field_name===e?{...s,field_value:l}:s);console.log("updatedSettings: ".concat(JSON.stringify(s))),a(s)},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);a(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||(console.log("formValues: ".concat(e)),null==e||void 0==e))return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let a={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(a)));let{slack_alerting:r,...i}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(i)));try{(0,x.jA)(l,"alerting_args",i),"boolean"==typeof r&&(!0==r?(0,x.jA)(l,"alerting",["slack"]):(0,x.jA)(l,"alerting",[])),I.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lC=s(86582);let{Title:lA,Paragraph:lP}=eS.default;console.log=function(){};var lE=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[n,o]=(0,i.useState)([]),[d,c]=(0,i.useState)([]),[m,u]=(0,i.useState)(!1),[h]=k.Z.useForm(),[p,j]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,w]=(0,i.useState)(""),[N,A]=(0,i.useState)({}),[P,E]=(0,i.useState)([]),[T,M]=(0,i.useState)(!1),[D,L]=(0,i.useState)([]),[F,R]=(0,i.useState)(null),[z,U]=(0,i.useState)([]),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),W=e=>{P.includes(e)?E(P.filter(l=>l!==e)):E([...P,e])},H={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,i.useEffect)(()=>{l&&s&&t&&(0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),L(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),E(e.active_alerts),w(s),A(e.alerts_to_webhook)}c(l)})},[l,s,t]);let G=e=>P&&P.includes(e),el=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));a&&a.value&&(e[s]=null==a?void 0:a.value)})}),console.log("updatedVariables",e);try{(0,x.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Email settings updated successfully")},es=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,x.K_)(l,{environment_variables:s}),I.ZP.success("Callback added successfully"),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},ea=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,x.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),I.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),j(e.litellm_callback_name),console.log("all callbacks",D),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(n)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(lA,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(g.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)(Q.Z,{children:"Callback Name"})})}),(0,r.jsx)(J.Z,{children:n.map((e,s)=>(0,r.jsxs)(ee.Z,{className:"flex justify-between",children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.name})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>M(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(b.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,r.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(H).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lN.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)}):(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,r.jsx)(lN.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:N&&N[s]?N[s]:v})})]},l)})})]}),(0,r.jsx)(f.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(H).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let r=(null==a?void 0:a.value)||"";console.log("newWebhookValue",r),e[s]=r}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:P}};console.log("payload",s);try{(0,x.K_)(l,s)}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lI,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(lA,{level:4,children:"Email Settings"}),(0,r.jsxs)(b.Z,{children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,r.jsx)("br",{})]}),(0,r.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,r.jsx)($.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(g.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,r.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,r.jsxs)("div",{children:[(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,r.jsxs)(b.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-2",children:l}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,r.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,r.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(C.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>M(!1),footer:null,children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,r.jsx)(k.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lC.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(S.default,{onChange:e=>{let l=D[e];l&&(console.log(l.ui_callback_name),em(l))},children:D&&Object.values(D).map(e=>(0,r.jsx)(et.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),z&&z.map(e=>(0,r.jsx)(lC.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,r.jsx)(Z.Z,{type:"password"})},e)),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(C.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(k.Z,{form:h,onFinish:es,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(r.Fragment,{children:B&&B.variables&&Object.entries(B.variables).map(e=>{let[l,s]=e;return(0,r.jsx)(lC.Z,{label:l,name:l,children:(0,r.jsx)(Z.Z,{type:"password",defaultValue:s})},l)})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lO=s(92414),lT=s(46030);let{Option:lM}=S.default;var lD=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(C.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),n.resetFields()},onCancel:()=>{d(!1),n.resetFields()},children:(0,r.jsxs)(k.Z,{form:n,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,i=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:i};console.log(o);try{(0,x.K_)(s,{router_settings:o}),a(o)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully"),d(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,r.jsx)(es.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,r.jsx)(k.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lO.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lT.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lL=s(33619);async function lF(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lL.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});I.ZP.success((0,r.jsxs)("span",{children:["Test model=",(0,r.jsx)("strong",{children:e}),", received model=",(0,r.jsx)("strong",{children:l.model}),". See"," ",(0,r.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lR={ttl:3600,lowest_latency_buffer:0},lz=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,r.jsxs)(_.Z,{children:[(0,r.jsx)(v.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,r.jsx)(y.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(b.Z,{children:"No specific settings"})})]})};var lU=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)({}),[d,c]=(0,i.useState)({}),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[_]=k.Z.useForm(),[y,v]=(0,i.useState)(null),[N,S]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,i.useEffect)(()=>{l&&s&&t&&((0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e);let l=e.router_settings;"model_group_retry_policy"in l&&delete l.model_group_retry_policy,o(l)}),(0,x.YU)(l).then(e=>{u(e)}))},[l,s,t]);let O=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(n.fallbacks));let s=n.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...n,fallbacks:s};try{await (0,x.K_)(l,{router_settings:t}),o(t),I.ZP.success("Router settings updated successfully")}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}},T=(e,l)=>{u(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},M=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,x.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,x.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(s)}catch(e){}},L=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,x.K_)(l,{router_settings:s})}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(w.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(n).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,r.jsx)($.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:S,children:[(0,r.jsx)(et.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,r.jsx)(et.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,r.jsx)(et.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,r.jsx)(lz,{selectedStrategy:N,strategyArgs:n&&n.routing_strategy_args&&Object.keys(n.routing_strategy_args).length>0?n.routing_strategy_args:lR,paramExplanation:E})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>L(n),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Model Name"}),(0,r.jsx)(Q.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(J.Z,{children:n.fallbacks&&n.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:t}),(0,r.jsx)($.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{onClick:()=>lF(t,l),children:"Test Fallback"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lD,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:n,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"}),(0,r.jsx)(Q.Z,{children:"Status"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,r.jsx)($.Z,{children:"Integer"==e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lS.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(f.Z,{onClick:()=>M(e.field_name,l),children:"Update"}),(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lV=s(93142),lq=s(45246),lB=s(96473),lK=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,i.useState)(Object.entries(l)),n=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let i=[...t];i[e]=[l,r],a(i),null==s||s(Object.fromEntries(i))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lV.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,r.jsx)(Z.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,r.jsx)(Z.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,r.jsx)(lq.Z,{onClick:()=>n(l)})]},l)}),(0,r.jsx)(O.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lB.Z,{}),children:"Add Header"})]})};let{Option:lW}=S.default;var lH=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=k.Z.useForm(),[n,o]=(0,i.useState)(!1),[d,c]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(C.Z,{title:"Add Pass-Through Endpoint",visible:n,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(k.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,x.Vt)(l,e),s(r)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Target",name:"target",rules:[{required:!0,message:"The URL to which requests for this path should be forwarded."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Headers",name:"headers",rules:[{required:!0,message:"Key-value pairs of headers to be forwarded with the request. You can set any key value pair here and it will be forwarded to your target endpoint"}],help:"required",children:(0,r.jsx)(lK,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lG=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&s&&t&&(0,x.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,x.EG)(l,e);let s=n.filter(l=>l.path!==e);o(s),I.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Path"}),(0,r.jsx)(Q.Z,{children:"Target"}),(0,r.jsx)(Q.Z,{children:"Headers"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:n.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.path})}),(0,r.jsx)($.Z,{children:e.target}),(0,r.jsx)($.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lH,{accessToken:l,setPassThroughItems:o,passThroughItems:n})]})})}):null},lY=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[i]=k.Z.useForm(),n=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call");let l=await (0,x.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),I.ZP.success("API Key Created"),i.resetFields()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),i.resetFields()},onCancel:()=>{t(!1),i.resetFields()},children:(0,r.jsxs)(k.Z,{form:i,onFinish:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lJ=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:n,handleUpdateCall:o}=e;console.log("existingBudget",n);let[d]=k.Z.useForm();(0,i.useEffect)(()=>{d.setFieldsValue(n)},[n,d]);let c=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call"),t(!0);let l=await (0,x.qI)(s,e);a(e=>e?[...e,l]:[l]),I.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(k.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:n,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},l$=s(17906),lX=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)(!1),[a,n]=(0,i.useState)(!1),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&(0,x.O3)(l).then(e=>{m(e)})},[l]);let u=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),n(!0))},h=async(e,s)=>{if(null==l)return;I.ZP.info("Request made"),await (0,x.NV)(l,e);let t=[...c];t.splice(s,1),m(t),I.ZP.success("Budget Deleted.")},p=async()=>{null!=l&&(0,x.O3)(l).then(e=>{m(e)})};return(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsx)(f.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lY,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lJ,{accessToken:l,isModalVisible:a,setIsModalVisible:n,setBudgetList:m,existingBudget:o,handleUpdateCall:p}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Budget ID"}),(0,r.jsx)(Q.Z,{children:"Max Budget"}),(0,r.jsx)(Q.Z,{children:"TPM"}),(0,r.jsx)(Q.Z,{children:"RPM"})]})}),(0,r.jsx)(J.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.budget_id}),(0,r.jsx)($.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)($.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)($.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,r.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="",\n api_key=""\n)\n\ncompletion = client.chat.completions.create(\n model="gpt-3.5-turbo",\n messages=[\n {"role": "system", "content": "You are a helpful assistant."},\n {"role": "user", "content": "Hello!"}\n ],\n user="my-customer-id"\n)\n\nprint(completion.choices[0].message)'})})]})]})]})]})},lQ=s(77398),l0=s.n(lQ),l1=s(20016);async function l2(e){try{let l=await fetch("http://ip-api.com/json/".concat(e)),s=await l.json();console.log("ip lookup data",s);let t=s.countryCode?s.countryCode.toUpperCase().split("").map(e=>String.fromCodePoint(e.charCodeAt(0)+127397)).join(""):"";return s.country?"".concat(t," ").concat(s.country):"Unknown"}catch(e){return console.error("Error looking up IP:",e),"Unknown"}}let l4=e=>{let{ipAddress:l}=e,[s,t]=i.useState("-");return i.useEffect(()=>{if(!l)return;let e=!0;return l2(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},l5=e=>{try{return new Date(e).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).replace(",","")}catch(e){return"Error converting time"}},l3=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:l5(l)})},l6=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):"●"}},{header:"Time",accessorKey:"startTime",cell:e=>(0,r.jsx)(l3,{utcTime:e.getValue()})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,r.jsx)(R.Z,{title:String(e.getValue()||""),children:(0,r.jsx)("span",{className:"font-mono text-xs max-w-[100px] truncate block",children:String(e.getValue()||"")})})},{header:"Cost",accessorKey:"spend",cell:e=>(0,r.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Country",accessorKey:"requester_ip_address",cell:e=>(0,r.jsx)(l4,{ipAddress:e.getValue()})},{header:"Team Name",accessorKey:"metadata.user_api_key_team_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Key Hash",accessorKey:"metadata.user_api_key",cell:e=>{let l=String(e.getValue()||"-");return(0,r.jsx)(R.Z,{title:l,children:(0,r.jsxs)("span",{className:"font-mono",children:[l.slice(0,5),"..."]})})}},{header:"Key Name",accessorKey:"metadata.user_api_key_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Model",accessorKey:"model",cell:e=>{let l=e.row.original.custom_llm_provider,s=String(e.getValue()||"");return(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[l&&(0,r.jsx)("img",{src:eP(l).logo,alt:"",className:"w-4 h-4",onError:e=>{e.target.style.display="none"}}),(0,r.jsx)(R.Z,{title:s,children:(0,r.jsx)("span",{className:"max-w-[100px] truncate",children:s})})]})}},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,r.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,r.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"Internal User",accessorKey:"user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"End User",accessorKey:"end_user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();if(!l||0===Object.keys(l).length)return"-";let s=Object.entries(l),t=s[0],a=s.slice(1);return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:(0,r.jsx)(R.Z,{title:(0,r.jsx)("div",{className:"flex flex-col gap-1",children:s.map(e=>{let[l,s]=e;return(0,r.jsxs)("span",{children:[l,": ",String(s)]},l)})}),children:(0,r.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[t[0],": ",String(t[1]),a.length>0&&" +".concat(a.length)]})})})}}],l8=async(e,l,s,t)=>{console.log("prefetchLogDetails called with",e.length,"logs");let a=e.map(e=>{if(e.request_id)return console.log("Prefetching details for request_id:",e.request_id),t.prefetchQuery({queryKey:["logDetails",e.request_id,l],queryFn:async()=>{console.log("Fetching details for",e.request_id);let t=await (0,x.qk)(s,e.request_id,l);return console.log("Received details for",e.request_id,":",t?"success":"failed"),t},staleTime:6e5,gcTime:6e5})});try{let e=await Promise.all(a);return console.log("All prefetch promises completed:",e.length),e}catch(e){throw console.error("Error in prefetchLogDetails:",e),e}};function l7(e){var l,s,t;let{accessToken:a,token:n,userRole:o,userID:d}=e,[m,u]=(0,i.useState)(""),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)(!1),[f,Z]=(0,i.useState)(1),[_]=(0,i.useState)(50),y=(0,i.useRef)(null),v=(0,i.useRef)(null),b=(0,i.useRef)(null),[w,N]=(0,i.useState)(l0()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[S,k]=(0,i.useState)(l0()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,i.useState)(!1),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(""),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(""),[F,R]=(0,i.useState)(""),[z,U]=(0,i.useState)("Team ID"),V=(0,c.NL)();(0,i.useEffect)(()=>{function e(e){y.current&&!y.current.contains(e.target)&&g(!1),v.current&&!v.current.contains(e.target)&&p(!1),b.current&&!b.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,l1.a)({queryKey:["logs","table",f,_,w,S,D,F],queryFn:async()=>{if(!a||!n||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:_,total_pages:0};let e=l0()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?l0()(S).utc().format("YYYY-MM-DD HH:mm:ss"):l0()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,x.h3)(a,F||void 0,D||void 0,void 0,e,l,f,_);return await l8(s.data,e,a,V),s.data=s.data.map(l=>{let s=V.getQueryData(["logDetails",l.request_id,e]);return(null==s?void 0:s.messages)&&(null==s?void 0:s.response)&&(l.messages=s.messages,l.response=s.response),l}),s},enabled:!!a&&!!n&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!n||!o||!d)return console.log("got None values for one of accessToken, token, userRole, userID"),null;let B=(null===(s=q.data)||void 0===s?void 0:null===(l=s.data)||void 0===l?void 0:l.filter(e=>!m||e.request_id.includes(m)||e.model.includes(m)||e.user&&e.user.includes(m)))||[],K=()=>{if(I)return"".concat(l0()(w).format("MMM D, h:mm A")," - ").concat(l0()(S).format("MMM D, h:mm A"));let e=l0()(),l=l0()(w),s=e.diff(l,"minutes");if(s<=15)return"Last 15 Minutes";if(s<=60)return"Last Hour";let t=e.diff(l,"hours");return t<=4?"Last 4 Hours":t<=24?"Last 24 Hours":t<=168?"Last 7 Days":"".concat(l.format("MMM D")," - ").concat(e.format("MMM D"))};return(0,r.jsxs)("div",{className:"w-full p-6",children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,r.jsx)("h1",{className:"text-xl font-semibold",children:"Request Logs"})}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"border-b px-6 py-4",children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between space-y-4 md:space-y-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("div",{className:"relative w-64",children:[(0,r.jsx)("input",{type:"text",placeholder:"Search by Request ID",className:"w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:m,onChange:e=>u(e.target.value)}),(0,r.jsx)("svg",{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),(0,r.jsxs)("div",{className:"relative",ref:v,children:[(0,r.jsxs)("button",{className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",onClick:()=>p(!h),children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),"Filter"]}),h&&(0,r.jsx)("div",{className:"absolute left-0 mt-2 w-[500px] bg-white rounded-lg shadow-lg border p-4 z-50",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>g(!j),className:"px-3 py-1.5 border rounded-md bg-white text-sm min-w-[160px] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-left flex justify-between items-center",children:[z,(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),j&&(0,r.jsx)("div",{className:"absolute left-0 mt-1 w-[160px] bg-white border rounded-md shadow-lg z-50",children:["Team ID","Key Hash"].map(e=>(0,r.jsxs)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 ".concat(z===e?"bg-blue-50 text-blue-600":""),onClick:()=>{U(e),g(!1),"Team ID"===e?M(""):O("")},children:[z===e&&(0,r.jsx)("svg",{className:"h-4 w-4 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e]},e))})]}),(0,r.jsx)("input",{type:"text",placeholder:"Enter value...",className:"px-3 py-1.5 border rounded-md text-sm flex-1 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:"Team ID"===z?E:T,onChange:e=>{"Team ID"===z?O(e.target.value):M(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{O(""),M("")},children:(0,r.jsx)("span",{className:"text-gray-500",children:"\xd7"})})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50",onClick:()=>{O(""),M(""),p(!1)},children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>{L(E),R(T),Z(1),p(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsxs)("button",{onClick:()=>P(!A),className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),K()]}),A&&(0,r.jsx)("div",{className:"absolute right-0 mt-2 w-64 bg-white rounded-lg shadow-lg border p-2 z-50",children:(0,r.jsxs)("div",{className:"space-y-1",children:[[{label:"Last 15 Minutes",value:15,unit:"minutes"},{label:"Last Hour",value:1,unit:"hours"},{label:"Last 4 Hours",value:4,unit:"hours"},{label:"Last 24 Hours",value:24,unit:"hours"},{label:"Last 7 Days",value:7,unit:"days"}].map(e=>(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(K()===e.label?"bg-blue-50 text-blue-600":""),onClick:()=>{k(l0()().format("YYYY-MM-DDTHH:mm")),N(l0()().subtract(e.value,e.unit).format("YYYY-MM-DDTHH:mm")),P(!1),C(!1)},children:e.label},e.label)),(0,r.jsx)("div",{className:"border-t my-2"}),(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(I?"bg-blue-50 text-blue-600":""),onClick:()=>C(!I),children:"Custom Range"})]})})]}),(0,r.jsxs)("button",{onClick:()=>{q.refetch()},className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",title:"Refresh data",children:[(0,r.jsx)("svg",{className:"w-4 h-4 ".concat(q.isFetching?"animate-spin":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,r.jsx)("span",{children:"Refresh"})]})]}),I&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:w,onChange:e=>{N(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})}),(0,r.jsx)("span",{className:"text-gray-500",children:"to"}),(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:S,onChange:e=>{k(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Showing"," ",q.isLoading?"...":q.data?(f-1)*_+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*_,q.data.total):0," ","of"," ",q.isLoading?"...":q.data?q.data.total:0," ","results"]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",q.isLoading?"...":f," of"," ",q.isLoading?"...":q.data?q.data.total_pages:1]}),(0,r.jsx)("button",{onClick:()=>Z(e=>Math.max(1,e-1)),disabled:q.isLoading||1===f,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>Z(e=>{var l;return Math.min((null===(l=q.data)||void 0===l?void 0:l.total_pages)||1,e+1)}),disabled:q.isLoading||f===((null===(t=q.data)||void 0===t?void 0:t.total_pages)||1),className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]})}),(0,r.jsx)(el,{columns:l6,data:B,renderSubComponent:l9,getRowCanExpand:()=>!0})]})]})}function l9(e){var l,s;let{row:t}=e,a=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,r.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium ",children:"Request Details"})}),(0,r.jsxs)("div",{className:"space-y-2 p-4 ",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request ID:"}),(0,r.jsx)("span",{children:t.original.request_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Key:"}),(0,r.jsx)("span",{children:t.original.api_key})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Team ID:"}),(0,r.jsx)("span",{children:t.original.team_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Model:"}),(0,r.jsx)("span",{children:t.original.model})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Base:"}),(0,r.jsx)("span",{children:t.original.api_base})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Call Type:"}),(0,r.jsx)("span",{children:t.original.call_type})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Spend:"}),(0,r.jsx)("span",{children:t.original.spend})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Total Tokens:"}),(0,r.jsx)("span",{children:t.original.total_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Prompt Tokens:"}),(0,r.jsx)("span",{children:t.original.prompt_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Completion Tokens:"}),(0,r.jsx)("span",{children:t.original.completion_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Start Time:"}),(0,r.jsx)("span",{children:t.original.startTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"End Time:"}),(0,r.jsx)("span",{children:t.original.endTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Hit:"}),(0,r.jsx)("span",{children:t.original.cache_hit})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Key:"}),(0,r.jsx)("span",{children:t.original.cache_key})]}),(null==t?void 0:null===(l=t.original)||void 0===l?void 0:l.requester_ip_address)&&(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request IP Address:"}),(0,r.jsx)("span",{children:null==t?void 0:null===(s=t.original)||void 0===s?void 0:s.requester_ip_address})]})]})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request Tags"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.request_tags),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.messages),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,r.jsx)("div",{})]}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.response),null,2)})]}),t.original.metadata&&Object.keys(t.original.metadata).length>0&&(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm ",children:JSON.stringify(t.original.metadata,null,2)})]})]})}var se=s(92699),sl=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,r.jsx)(b.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(ei.Z,{children:"LlamaIndex"}),(0,r.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="'.concat(s,'", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="').concat(s,'",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="'.concat(s,'",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})})},ss=s(243),st=s(94263);async function sa(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lL.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await r.chat.completions.create({model:s,stream:!0,messages:e})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content,t.model)}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var sr=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:n}=e,[o,d]=(0,i.useState)(n?"custom":"session"),[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[p,_]=(0,i.useState)([]),[y,v]=(0,i.useState)(void 0),[w,N]=(0,i.useState)([]),k=(0,i.useRef)(null);(0,i.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,x.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),v(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,i.useEffect)(()=>{k.current&&setTimeout(()=>{var e;null===(e=k.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[p]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===u.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){I.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},i=[...p.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];_([...p,r]);try{y&&await sa(i,(e,l)=>C("assistant",e,l),y,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,r.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(ei.Z,{children:"Chat"})}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"API Key Source"}),(0,r.jsx)(S.default,{disabled:n,defaultValue:"session",style:{width:"100%"},onChange:e=>d(e),options:[{value:"session",label:"Current UI Session"},{value:"custom",label:"Virtual Key"}]}),"custom"===o&&(0,r.jsx)(Z.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:m,value:c})]}),(0,r.jsxs)(j.Z,{className:"mx-2",children:[(0,r.jsx)(b.Z,{children:"Select Model:"}),(0,r.jsx)(S.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),v(e)},options:w,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(f.Z,{onClick:()=>{_([]),I.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(Y.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{})})}),(0,r.jsxs)(J.Z,{children:[p.map((e,l)=>(0,r.jsx)(ee.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,r.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,r.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,r.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,r.jsx)(ss.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...i}=e,n=/language-(\w+)/.exec(t||"");return!s&&n?(0,r.jsx)(l$.Z,{style:st.Z,language:n[1],PreTag:"div",...i,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...i,children:a})}},children:e.content})})]})},l)),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{ref:k,style:{height:"1px"}})})})]})]}),(0,r.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,r.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,r.jsx)(Z.Z,{type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,r.jsx)(f.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},si=s(19226),sn=s(45937),so=s(92403),sd=s(28595),sc=s(68208),sm=s(9775),su=s(41361),sh=s(37527),sx=s(15883),sp=s(12660),sj=s(88009),sg=s(48231),sf=s(41169),sZ=s(44625),s_=s(57400),sy=s(55322);let{Sider:sv}=si.default,sb=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],sw=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(so.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(sd.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(sc.Z,{}),roles:sb},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(sm.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(su.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(sh.Z,{}),roles:sb},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(sx.Z,{}),roles:sb},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(sp.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sj.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sg.Z,{}),roles:sb},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sf.Z,{}),roles:sb,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(sZ.Z,{}),roles:sb},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(sh.Z,{}),roles:sb},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(s_.Z,{}),roles:sb}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(sy.Z,{}),roles:sb,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(sy.Z,{}),roles:sb},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(sp.Z,{}),roles:sb},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(sy.Z,{}),roles:sb},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(sy.Z,{}),roles:sb}]}];var sN=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=sw.find(l=>l.page===e);if(l)return l.key;for(let l of sw)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),i=sw.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(si.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sv,{theme:"light",width:220,children:(0,r.jsx)(sn.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:i.map(e=>{var s;return{key:e.key,icon:e.icon,label:e.label,children:null===(s=e.children)||void 0===s?void 0:s.map(e=>({key:e.key,icon:e.icon,label:e.label,onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}})),onClick:e.children?void 0:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}}})})})})},sS=s(96889);console.log=function(){};var sk=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:n,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,i.useState)(null!==a?a:0),[m,u]=(0,i.useState)(o?o.max_budget:null);(0,i.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(n);else{let e=!1;if(o.team_memberships)for(let s of o.team_memberships)s.user_id===l&&"max_budget"in s.litellm_budget_table&&null!==s.litellm_budget_table.max_budget&&(u(s.litellm_budget_table.max_budget),e=!0);e||u(o.max_budget)}}},[o,n]);let[h,p]=(0,i.useState)([]);(0,i.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,x.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,i.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",h),j=h):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=h);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,r.jsx)("div",{className:"flex items-center",children:(0,r.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,r.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})},sI=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sC=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sA=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:n,premiumUser:o}=e,d=new Date,[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)([]),[v,N]=(0,i.useState)([]),[S,k]=(0,i.useState)([]),[I,C]=(0,i.useState)([]),[A,P]=(0,i.useState)([]),[E,O]=(0,i.useState)([]),[T,M]=(0,i.useState)([]),[D,L]=(0,i.useState)({}),[F,R]=(0,i.useState)([]),[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(["all-tags"]),[B,K]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(0),ea=new Date(d.getFullYear(),d.getMonth(),1),em=new Date(d.getFullYear(),d.getMonth()+1,0),eu=ef(ea),eh=ef(em);function ex(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",n),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,x.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,i.useEffect)(()=>{eg(B.from,B.to)},[B,V]);let ej=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let a=await (0,x.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),y(a)},eg=async(e,s)=>{if(!e||!s||!l)return;let t=await ep();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),k((await (0,x.J$)(l,e.toISOString(),s.toISOString(),0===V.length?void 0:V)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ef(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}console.log("Start date is ".concat(eu)),console.log("End date is ".concat(eh));let eZ=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},e_=(e,l,s,t)=>{let a=[],r=new Date(l),i=e=>{if(e.includes("-"))return e;{let[l,s]=e.split(" ");return new Date(new Date().getFullYear(),new Date("".concat(l," 01 2024")).getMonth(),parseInt(s)).toISOString().split("T")[0]}},n=new Map(e.map(e=>{let l=i(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(n.has(e))a.push(n.get(e));else{let l={date:e,api_requests:0,total_tokens:0};t.forEach(e=>{l[e]||(l[e]=0)}),a.push(l)}r.setDate(r.getDate()+1)}return a},ey=async()=>{if(l)try{let e=await (0,x.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e,t,a,[]),i=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(i),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},ev=()=>eZ(()=>l&&s?(0,x.OU)(l,s,eu,eh):Promise.reject("No access token or token"),M,"Error fetching provider spend"),eb=async()=>{l&&await eZ(async()=>(await (0,x.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:Number(e.total_spend.toFixed(2))})),h,"Error fetching top keys")},ew=async()=>{l&&await eZ(async()=>(await (0,x.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),Z,"Error fetching top models")},eN=async()=>{l&&await eZ(async()=>{let e=await (0,x.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return N(e_(e.daily_spend,t,a,e.teams)),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:Number(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eS=()=>{l&&eZ(async()=>(await (0,x.X)(l)).tag_names,C,"Error fetching tag names")},ek=()=>{l&&eZ(()=>{var e,s;return(0,x.J$)(l,null===(e=B.from)||void 0===e?void 0:e.toISOString(),null===(s=B.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>k(e.spend_per_tag),"Error fetching top tags")},eC=()=>{l&&eZ(()=>(0,x.b1)(l,null,void 0,void 0),y,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,x.wd)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e.daily_data||[],t,a,["api_requests","total_tokens"]);L({...e,daily_data:r})}catch(e){console.error("Error fetching global activity:",e)}},eP=async()=>{if(l)try{let e=await (0,x.xA)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e.map(e=>({...e,daily_data:e_(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,i.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(H(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",W),ey(),ev(),eb(),ew(),eA(),eP(),sC(t)&&(eN(),eS(),ek(),eC()))}})()},[l,s,t,a,eu,eh]),null==W?void 0:W.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(b.Z,{className:"mt-4",children:["SpendLogs in DB has ",W.NUM_SPEND_LOGS_ROWS," rows.",(0,r.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,r.jsx)(f.Z,{className:"mt-4",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(ei.Z,{children:"All Up"}),sC(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ei.Z,{children:"Team Based Usage"}),(0,r.jsx)(ei.Z,{children:"Customer Usage"}),(0,r.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{})})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(ei.Z,{children:"Cost"}),(0,r.jsx)(ei.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(b.Z,{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content mb-2 mt-2 text-lg",children:["Project Spend ",new Date().toLocaleString("default",{month:"long"})," 1 - ",new Date(new Date().getFullYear(),new Date().getMonth()+1,0).getDate()]}),(0,r.jsx)(sk,{userID:a,userRole:t,accessToken:l,userSpend:G,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Monthly Spend"}),(0,r.jsx)(eU.Z,{data:c,index:"date",categories:["spend"],colors:["cyan"],valueFormatter:e=>"$ ".concat(e.toFixed(2)),yAxisWidth:100,tickGap:5})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top API Keys"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:u,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top Models"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:p,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sI.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend",colors:["cyan"],valueFormatter:e=>"$".concat(e.toFixed(2))})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Provider"}),(0,r.jsx)(Q.Z,{children:"Spend"})]})}),(0,r.jsx)(J.Z,{children:T.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.provider}),(0,r.jsx)($.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})})]})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"All Up"}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(D.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(D.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),(0,r.jsx)(r.Fragment,{children:F.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.model}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ex,onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ex,onValueChange:e=>console.log(e)})]})]})]},l))})]})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sS.Z,{data:E})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eU.Z,{className:"h-72",data:v,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,r.jsx)(j.Z,{numColSpan:2})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{ej(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==n?void 0:n.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{ej(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(Y.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Customer"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Total Events"})]})}),(0,r.jsx)(J.Z,{children:null==_?void 0:_.map((e,l)=>{var s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.end_user}),(0,r.jsx)($.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)($.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eF.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lO.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lT.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsx)(lT.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lO.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lT.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsxs)(et.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(b.Z,{children:["Get Started Tracking cost per tag ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,r.jsx)(eU.Z,{className:"h-72",data:S,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sP=e=>{if(e)return e.toISOString().split("T")[0]};function sE(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var sO=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:n}=e,[o,d]=(0,i.useState)([]),[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)("0"),[v,w]=(0,i.useState)("0"),[N,S]=(0,i.useState)("0"),[k,C]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,i.useState)(""),[E,O]=(0,i.useState)("");(0,i.useEffect)(()=>{l&&k&&((async()=>{Z(await (0,x.zg)(l,sP(k.from),sP(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),M=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let D=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,x.zg)(l,sP(e),sP(s))))};(0,i.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",p);let e=p;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),u.length>0&&(e=e.filter(e=>u.includes(e.model))),console.log("before processed data in cache dashboard",e);let l=0,s=0,t=0,a=e.reduce((e,a)=>{console.log("Processing item:",a),a.call_type||(console.log("Item has no call_type:",a),a.call_type="Unknown"),l+=(a.total_rows||0)-(a.cache_hit_true_rows||0),s+=a.cache_hit_true_rows||0,t+=a.cached_completion_tokens||0;let r=e.find(e=>e.name===a.call_type);return r?(r["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),r["Cache hit"]+=a.cache_hit_true_rows||0,r["Cached Completion Tokens"]+=a.cached_completion_tokens||0,r["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(sE(s)),w(sE(t));let r=s+l;r>0?S((s/r*100).toFixed(2)):S("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,p]);let L=async()=>{try{I.ZP.info("Running cache health check..."),O("");let e=await (0,x.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),O(e)}catch(e){console.error("Error running health check:",e),O("Error running health check")}};return(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-full w-full mt-2 mb-8",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Cache Analytics"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"Cache Health"})})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[A&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:()=>{P(new Date().toLocaleString())}})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(g.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lO.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lT.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lO.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:M.map(e=>(0,r.jsx)(lT.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eF.Z,{enableSelect:!0,value:k,onValueChange:e=>{C(e),D(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[N,"%"]})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:v})})]})]}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eU.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sE,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eU.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sE,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{className:"mt-4",children:[(0,r.jsx)(b.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(f.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),E&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(E,null,2)})]})})]})]})},sT=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(async()=>{try{let e=await (0,x.t3)(l);console.log("guardrails: ".concat(JSON.stringify(e))),t(e.guardrails)}catch(e){console.error("Error fetching guardrails:",e)}})()},[l]),(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsxs)(b.Z,{className:"mb-4",children:["Configured guardrails and their current status. Setup guardrails in config.yaml."," ",(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-700 underline",children:"Docs"})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Guardrail Name"}),(0,r.jsx)(Q.Z,{children:"Mode"}),(0,r.jsx)(Q.Z,{children:"Status"})]})}),(0,r.jsx)(J.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.guardrail_name}),(0,r.jsx)($.Z,{children:e.litellm_params.mode}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"inline-flex rounded-full px-2 py-1 text-xs font-medium\n ".concat(e.litellm_params.default_on?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:e.litellm_params.default_on?"Always On":"Per Request"})})]},l)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};let sM=new d.S;function sD(){let[e,l]=(0,i.useState)(""),[s,t]=(0,i.useState)(!1),[a,d]=(0,i.useState)(!1),[m,u]=(0,i.useState)(null),[j,g]=(0,i.useState)(null),[f,Z]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,b]=(0,i.useState)([]),[w,N]=(0,i.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[S,k]=(0,i.useState)(!0),I=(0,n.useSearchParams)(),[C,A]=(0,i.useState)({data:[]}),[P,E]=(0,i.useState)(null),O=I.get("userID"),T=I.get("invitation_id"),[M,D]=(0,i.useState)(()=>I.get("page")||"api-keys"),[L,F]=(0,i.useState)(null);return(0,i.useEffect)(()=>{E(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,i.useEffect)(()=>{if(!P)return;let e=(0,o.o)(P);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),F(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"org_admin":return"Org Admin";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&D("usage")}else console.log("User role not defined");e.user_email?u(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?k("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&t(e.premium_user),e.auth_header_name&&(0,x.K8)(e.auth_header_name)}},[P]),(0,i.useEffect)(()=>{L&&O&&e&&q(O,e,L,b),L&&O&&e&&p(L,O,e,null,g),L&&ly(L,y)},[L,O,e]),(0,r.jsx)(i.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sM,children:T?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(h,{userID:O,userRole:e,premiumUser:s,setProxySettings:N,proxySettings:w}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sN,{setPage:e=>{let l=new URLSearchParams(I);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),D(e)},userRole:e,defaultSelectedKey:M})}),"api-keys"==M?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):"models"==M?(0,r.jsx)(lm,{userID:O,userRole:e,token:P,keys:f,accessToken:L,modelData:C,setModelData:A,premiumUser:s,teams:j}):"llm-playground"==M?(0,r.jsx)(sr,{userID:O,userRole:e,token:P,accessToken:L,disabledPersonalKeyCreation:a}):"users"==M?(0,r.jsx)(lj,{userID:O,userRole:e,token:P,keys:f,teams:j,accessToken:L,setKeys:Z}):"teams"==M?(0,r.jsx)(lZ,{teams:j,setTeams:g,searchParams:I,accessToken:L,userID:O,userRole:e,organizations:_}):"organizations"==M?(0,r.jsx)(lv,{organizations:_,setOrganizations:y,userModels:v,accessToken:L,userRole:e,premiumUser:s}):"admin-panel"==M?(0,r.jsx)(lw,{setTeams:g,searchParams:I,accessToken:L,showSSOBanner:S,premiumUser:s}):"api_ref"==M?(0,r.jsx)(sl,{proxySettings:w}):"settings"==M?(0,r.jsx)(lE,{userID:O,userRole:e,accessToken:L,premiumUser:s}):"budgets"==M?(0,r.jsx)(lX,{accessToken:L}):"guardrails"==M?(0,r.jsx)(sT,{accessToken:L}):"general-settings"==M?(0,r.jsx)(lU,{userID:O,userRole:e,accessToken:L,modelData:C}):"model-hub"==M?(0,r.jsx)(se.Z,{accessToken:L,publicPage:!1,premiumUser:s}):"caching"==M?(0,r.jsx)(sO,{userID:O,userRole:e,token:P,accessToken:L,premiumUser:s}):"pass-through-settings"==M?(0,r.jsx)(lG,{userID:O,userRole:e,accessToken:L,modelData:C}):"logs"==M?(0,r.jsx)(l7,{userID:O,userRole:e,token:P,accessToken:L}):(0,r.jsx)(sA,{userID:O,userRole:e,token:P,accessToken:L,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,812,250,699,971,117,744],function(){return e(e.s=1900)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-e673cacf03d84561.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-e673cacf03d84561.js new file mode 100644 index 0000000000..89c78ea341 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-e673cacf03d84561.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,15940))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),r=s(99376),i=s(20831),n=s(94789),o=s(12514),d=s(49804),c=s(67101),m=s(84264),u=s(26637),h=s(96761),x=s(84566),p=s(19250),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,r.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,_]=(0,a.useState)(null),[y,v]=(0,a.useState)(""),[b,w]=(0,a.useState)(""),[N,S]=(0,a.useState)(null),[k,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),S(t.user_id)})},[s]),(0,t.jsx)("div",{className:"mx-auto w-full max-w-md mt-10",children:(0,t.jsxs)(o.Z,{children:[(0,t.jsx)(h.Z,{className:"text-sm mb-5 text-center",children:"\uD83D\uDE85 LiteLLM"}),(0,t.jsx)(h.Z,{className:"text-xl",children:"Sign up"}),(0,t.jsx)(m.Z,{children:"Claim your user account to login to Admin UI."}),(0,t.jsx)(n.Z,{className:"mt-4",title:"SSO",icon:x.GH$,color:"sky",children:(0,t.jsxs)(c.Z,{numItems:2,className:"flex justify-between items-center",children:[(0,t.jsx)(d.Z,{children:"SSO is under the Enterprise Tirer."}),(0,t.jsx)(d.Z,{children:(0,t.jsx)(i.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=b,N&&s&&(0,p.m_)(Z,s,N,e.password).then(e=>{var l;let s="/ui/";s+="?userID="+((null===(l=e.data)||void 0===l?void 0:l.user_id)||e.user_id),document.cookie="token="+C,console.log("redirecting to:",s),window.location.href=s}))},children:[(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:b,defaultValue:b,className:"max-w-md"})}),(0,t.jsx)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},15940:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sM}});var t,a,r=s(57437),i=s(2265),n=s(99376),o=s(14474),d=s(90946),c=s(29827),m=s(27648),u=s(80795),h=e=>{let{userID:l,userRole:s,premiumUser:t,proxySettings:a}=e,i=(null==a?void 0:a.PROXY_LOGOUT_URL)||"",n=[{key:"1",label:(0,r.jsxs)("div",{className:"px-1 py-1",children:[(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Role: ",s]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["ID: ",l]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Premium User: ",String(t)]})]})},{key:"2",label:(0,r.jsx)("p",{className:"text-sm hover:text-gray-900",onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=i},children:"Logout"})}];return(0,r.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,r.jsx)("div",{className:"w-full",children:(0,r.jsxs)("div",{className:"flex items-center h-12 px-4",children:[(0,r.jsx)("div",{className:"flex items-center flex-shrink-0",children:(0,r.jsx)(m.default,{href:"/",className:"flex items-center",children:(0,r.jsx)("img",{src:"/get_image",alt:"LiteLLM Brand",className:"h-8 w-auto"})})}),(0,r.jsxs)("div",{className:"flex items-center space-x-5 ml-auto",children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:"Docs"}),(0,r.jsx)(u.Z,{menu:{items:n,style:{padding:"4px",marginTop:"4px"}},children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:["User",(0,r.jsx)("svg",{className:"ml-1 w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})},x=s(19250);let p=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,x.It)(e,(null==t?void 0:t.organization_id)||null,l):await (0,x.It)(e,(null==t?void 0:t.organization_id)||null),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),g=s(67101),f=s(20831),Z=s(26637),_=s(87452),y=s(88829),v=s(72208),b=s(84264),w=s(96761),N=s(29233),S=s(52787),k=s(13634),I=s(41021),C=s(51369),A=s(29967),P=s(20577),E=s(56632),O=s(73002);let T=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,x.So)(s,e,l,!0)).data.map(e=>e.id),a=[],r=[];return t.forEach(e=>{e.endsWith("/*")?a.push(e):r.push(e)}),[...a,...r]}}catch(e){console.error("Error fetching user models:",e)}},M=e=>{if(e.endsWith("/*")){let l=e.replace("/*","");return"All ".concat(l," models")}return e},D=(e,l)=>{let s=[],t=[];return console.log("teamModels",e),console.log("allModels",l),e.forEach(e=>{if(e.endsWith("/*")){let a=e.replace("/*",""),r=l.filter(e=>e.startsWith(a+"/"));t.push(...r),s.push(e)}else t.push(e)}),[...s,...t].filter((e,l,s)=>s.indexOf(e)===l)};var L=e=>{let{teams:l,value:s,onChange:t}=e;return(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",value:s,onChange:t,filterOption:(e,l)=>{var s,t,a;return!!l&&((null===(a=l.children)||void 0===a?void 0:null===(t=a[0])||void 0===t?void 0:null===(s=t.props)||void 0===s?void 0:s.children)||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==l?void 0:l.map(e=>(0,r.jsxs)(S.default.Option,{value:e.team_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.team_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.team_id,")"]})]},e.team_id))})},F=s(15424),R=s(75957);let{Option:z}=S.default,U=e=>{let l=[];if(console.log("data:",JSON.stringify(e)),e)for(let s of e)s.metadata&&s.metadata.tags&&l.push(...s.metadata.tags);let s=Array.from(new Set(l)).map(e=>({value:e,label:e}));return console.log("uniqueTags:",s),s},V=(e,l)=>D(e&&e.models.length>0?e.models.includes("all-proxy-models")?l:e.models:l,l),q=async(e,l,s,t)=>{try{if(null===e||null===l)return;if(null!==s){let a=(await (0,x.So)(s,e,l)).data.map(e=>e.id);console.log("available_model_names:",a),t(a)}}catch(e){console.error("Error fetching user models:",e)}};var B=e=>{let{userID:l,team:s,teams:t,userRole:a,accessToken:n,data:o,setData:d}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[T,D]=(0,i.useState)(null),[B,K]=(0,i.useState)([]),[W,H]=(0,i.useState)([]),[G,Y]=(0,i.useState)("you"),[J,$]=(0,i.useState)(U(o)),[X,Q]=(0,i.useState)([]),[ee,el]=(0,i.useState)(s),es=()=>{u(!1),c.resetFields()},et=()=>{u(!1),p(null),c.resetFields()};(0,i.useEffect)(()=>{l&&a&&n&&q(l,a,n,K)},[n,l,a]),(0,i.useEffect)(()=>{(async()=>{try{let e=(await (0,x.t3)(n)).guardrails.map(e=>e.guardrail_name);Q(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[n]);let ea=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",i=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===i).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(i,", please provide another key alias"));if(I.ZP.info("Making API Call"),u(!0),"you"===G&&(e.user_id=l),"service_account"===G){let l={};try{l=JSON.parse(e.metadata||"{}")}catch(e){console.error("Error parsing metadata:",e)}l.service_account_id=e.key_alias,e.metadata=JSON.stringify(l)}let m=await (0,x.wX)(n,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),p(m.key),D(m.soft_budget),I.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),I.ZP.error("Error creating the key: ".concat(e))}};return(0,i.useEffect)(()=>{H(V(ee,B)),c.setFieldValue("models",[])},[ee,B]),(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(C.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:es,onCancel:et,children:(0,r.jsxs)(k.Z,{form:c,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(A.ZP.Group,{onChange:e=>Y(e.target.value),value:G,children:[(0,r.jsx)(A.ZP,{value:"you",children:"You"}),(0,r.jsx)(A.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(A.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==G,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===G,message:"Please input the user ID of the user you are assigning the key to"}],help:"Get User ID - Click on the 'Users' tab in the sidebar.",children:(0,r.jsx)(Z.Z,{placeholder:"User ID",onChange:e=>c.setFieldValue("user_id",e.target.value)})}),(0,r.jsx)(k.Z.Item,{label:"you"===G||"another_user"===G?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===G?"key name":"service account ID")}],help:"you"===G?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(L,{teams:t,onChange:e=>{el((null==t?void 0:t.find(l=>l.team_id===e))||null)}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected team has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,r.jsx)(z,{value:"all-team-models",children:"All Team Models"},"all-team-models"),W.map(e=>(0,r.jsx)(z,{value:e,children:M(e)},e))]})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:X.map(e=>({value:e,label:e}))})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)(k.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:J})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(C.Z,{visible:m,onOk:es,onCancel:et,footer:null,children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Save your Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:null!=h?(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:h})}),(0,r.jsx)(N.CopyToClipboard,{text:h,onCopy:()=>{I.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(b.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,n]=(0,i.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,i.useState)(!0),[c,m]=(0,i.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!t){console.log("accessToken",t);return}d(!0);let a=await (0,x.OD)(t,(null==s?void 0:s.organization_id)||null,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),n(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,i.useEffect)(()=>{u(),console.log("selectedTeam",l,"currentOrg",s,"accessToken",t)},[l,s,t]),{keys:r.keys,isLoading:o,error:c,pagination:{currentPage:r.current_page,totalPages:r.total_pages,totalCount:r.total_count},refresh:u}},H=s(71594),G=s(24525),Y=s(21626),J=s(97214),$=s(28241),X=s(58834),Q=s(69552),ee=s(71876);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:n=!1}=e,o=(0,H.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,G.sC)(),getExpandedRowModel:(0,G.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(Y.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(X.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)(ee.Z,{children:e.headers.map(e=>(0,r.jsx)(Q.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,H.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(J.Z,{children:n?(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"\uD83D\uDE85 Loading logs..."})})})}):o.getRowModel().rows.length>0?o.getRowModel().rows.map(e=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)(ee.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)($.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,H.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"No logs found"})})})})})]})})}var es=s(27281),et=s(57365),ea=s(41649),er=s(12514),ei=s(12485),en=s(18135),eo=s(35242),ed=s(29706),ec=s(77991),em=s(10900),eu=s(23628),eh=s(74998);function ex(e){var l,s;let{keyData:t,onCancel:a,onSubmit:n,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=k.Z.useForm(),[h,p]=(0,i.useState)([]),j=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,i.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,x.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let g={...t,budget_duration:(s=t.budget_duration)&&({"24h":"daily","7d":"weekly","30d":"monthly"})[s]||null,metadata:t.metadata?JSON.stringify(t.metadata,null,2):"",guardrails:(null===(l=t.metadata)||void 0===l?void 0:l.guardrails)||[]};return(0,r.jsxs)(k.Z,{form:u,onFinish:n,initialValues:g,layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[j.length>0&&(0,r.jsx)(S.default.Option,{value:"all-team-models",children:"All Team Models"}),j.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(S.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(S.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(k.Z.Item,{name:"token",hidden:!0,children:(0,r.jsx)(E.Z,{})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(f.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,_]=(0,i.useState)(!1);(0,i.useEffect)(()=>{s&&l&&n.setFieldsValue({key_alias:l.key_alias,max_budget:l.max_budget,tpm_limit:l.tpm_limit,rpm_limit:l.rpm_limit,duration:l.duration||""})},[s,l,n]),(0,i.useEffect)(()=>{s||(d(null),_(!1),n.resetFields())},[s,n]),(0,i.useEffect)(()=>{(null==c?void 0:c.duration)?h((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString()}catch(e){return null}})(c.duration)):h(null)},[null==c?void 0:c.duration]);let y=async()=>{if(l&&a){_(!0);try{let e=await n.validateFields(),s=await (0,x.s0)(a,l.token,e);d(s.key),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key"),_(!1)}}},v=()=>{d(null),_(!1),n.resetFields(),t()};return(0,r.jsx)(C.Z,{title:"Regenerate API Key",open:s,onCancel:v,footer:o?[(0,r.jsx)(f.Z,{onClick:v,children:"Close"},"close")]:[(0,r.jsx)(f.Z,{onClick:v,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:y,disabled:p,children:p?"Regenerating...":"Regenerate"},"regenerate")],children:o?(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:(null==l?void 0:l.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:o})}),(0,r.jsx)(N.CopyToClipboard,{text:o,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(k.Z,{form:n,layout:"vertical",onValuesChange:e=>{"duration"in e&&m(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==l?void 0:l.expires)?new Date(l.expires).toLocaleString():"Never"]}),u&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",u]})]})})}function ej(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:n,userRole:o,teams:d}=e,[c,m]=(0,i.useState)(!1),[u]=k.Z.useForm(),[h,p]=(0,i.useState)(!1),[j,Z]=(0,i.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(b.Z,{children:"Key not found"})]});let _=async e=>{try{var l,s;if(!a)return;let t=e.token;if(e.key=t,e.metadata&&"string"==typeof e.metadata)try{let s=JSON.parse(e.metadata);e.metadata={...s,...(null===(l=e.guardrails)||void 0===l?void 0:l.length)>0?{guardrails:e.guardrails}:{}}}catch(e){console.error("Error parsing metadata JSON:",e),I.ZP.error("Invalid metadata JSON");return}else e.metadata={...e.metadata||{},...(null===(s=e.guardrails)||void 0===s?void 0:s.length)>0?{guardrails:e.guardrails}:{}};e.budget_duration&&(e.budget_duration=({daily:"24h",weekly:"7d",monthly:"30d"})[e.budget_duration]),await (0,x.Nc)(a,e),I.ZP.success("Key updated successfully"),m(!1)}catch(e){I.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},y=async()=>{try{if(!a)return;await (0,x.I1)(a,t.token),I.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),I.ZP.error("Failed to delete key")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(f.Z,{icon:eu.Z,variant:"secondary",onClick:()=>Z(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>p(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:j,onClose:()=>Z(!1),accessToken:a}),h&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:y,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>p(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(b.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:_,teams:d,accessToken:a,userID:n,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(b.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(b.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(b.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(b.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(b.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(b.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(b.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Metadata"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(t.metadata,null,2)})]})]})]})})]})]})]})}var eg=s(82422),ef=s(2356),eZ=s(44633),e_=s(86462),ey=s(3837),ev=e=>{var l;let{options:s,onApplyFilters:t,onResetFilters:a,initialValues:n={},buttonLabel:o="Filter"}=e,[d,c]=(0,i.useState)(!1),[m,h]=(0,i.useState)((null===(l=s[0])||void 0===l?void 0:l.name)||""),[x,p]=(0,i.useState)(n),[j,g]=(0,i.useState)(n),[Z,_]=(0,i.useState)(!1),y=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{let l=e.target;!y.current||y.current.contains(l)||l.closest(".ant-dropdown")||c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let v=e=>{g(l=>({...l,[m]:e}))},b=()=>{let e={};s.forEach(l=>{e[l.name]=""}),g(e)},w=s.map(e=>({key:e.name,label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[m===e.name&&(0,r.jsx)(eg.Z,{className:"h-4 w-4 text-blue-600"}),e.label||e.name]})}));return(0,r.jsxs)("div",{className:"relative",ref:y,children:[(0,r.jsx)(f.Z,{icon:ef.Z,onClick:()=>c(!d),variant:"secondary",size:"xs",className:"flex items-center pr-2",children:o}),d&&(0,r.jsx)(er.Z,{className:"absolute left-0 mt-2 w-96 z-50 border border-gray-200 shadow-lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsx)(u.Z,{menu:{items:w,onClick:e=>{let{key:l}=e;h(l),_(!1)}},onOpenChange:_,open:Z,trigger:["click"],children:(0,r.jsxs)(O.ZP,{className:"min-w-32 text-left flex justify-between items-center",children:[m,Z?(0,r.jsx)(eZ.Z,{className:"h-4 w-4"}):(0,r.jsx)(e_.Z,{className:"h-4 w-4"})]})}),(0,r.jsx)(E.Z,{placeholder:"Enter value...",value:j[m]||"",onChange:e=>v(e.target.value),className:"px-3 py-1.5 border rounded-md text-sm flex-1 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",suffix:j[m]?(0,r.jsx)(ey.Z,{className:"h-4 w-4 cursor-pointer text-gray-400 hover:text-gray-500",onClick:e=>{e.stopPropagation(),v("")}}):null})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(O.ZP,{onClick:()=>{b();let e={};s.forEach(l=>{e[l.name]=""}),a(),c(!1)},children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"primary",onClick:()=>{p(j),t(j),c(!1)},children:"Apply Filters"})]})]})})]})};function eb(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:n=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h,organizations:x,setCurrentOrg:p}=e,[j,g]=(0,i.useState)(null),[Z,_]=(0,i.useState)({"Team ID":"","Organization ID":""}),y=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):null}},{header:"Key ID",accessorKey:"token",cell:e=>(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.getValue(),children:(0,r.jsx)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>g(e.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{header:"Team ID",accessorKey:"team_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Key Alias",accessorKey:"key_alias",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Organization ID",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Created",accessorKey:"created_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"-"}},{header:"Expires",accessorKey:"expires",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"Never"}},{header:"Spend (USD)",accessorKey:"spend",cell:e=>Number(e.getValue()).toFixed(4)},{header:"Budget (USD)",accessorKey:"max_budget",cell:e=>null!==e.getValue()&&void 0!==e.getValue()?e.getValue():"Unlimited"},{header:"Budget Reset",accessorKey:"budget_reset_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleString():"Never"}},{header:"Models",accessorKey:"models",cell:e=>{let l=e.getValue();return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:l&&l.length>0?l.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):"-"})}},{header:"Rate Limits",cell:e=>{let{row:l}=e,s=l.original;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{children:["TPM: ",null!==s.tpm_limit?s.tpm_limit:"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",null!==s.rpm_limit?s.rpm_limit:"Unlimited"]})]})}}];return(0,r.jsx)("div",{className:"w-full h-full overflow-hidden",children:j?(0,r.jsx)(ej,{keyId:j,onClose:()=>g(null),keyData:l.find(e=>e.token===j),accessToken:m,userID:u,userRole:h,teams:o}):(0,r.jsxs)("div",{className:"border-b py-4 flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between w-full mb-2",children:[(0,r.jsx)(ev,{options:[{name:"Team ID",label:"Team ID"},{name:"Organization ID",label:"Organization ID"}],onApplyFilters:e=>{if(_({"Team ID":e["Team ID"]||"","Organization ID":e["Organization ID"]||""}),e["Team ID"]){let l=null==o?void 0:o.find(l=>l.team_id===e["Team ID"]);l&&c(l)}if(e["Organization ID"]){let l=null==x?void 0:x.find(l=>l.organization_id===e["Organization ID"]);l&&p(l)}},initialValues:Z,onResetFilters:()=>{_({"Team ID":"","Organization ID":""}),c(null),p(null)}}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsxs)("span",{className:"inline-flex text-sm text-gray-700",children:["Showing ",s?"...":"".concat((t.currentPage-1)*n+1," - ").concat(Math.min(t.currentPage*n,t.totalCount))," of ",s?"...":t.totalCount," results"]}),(0,r.jsxs)("div",{className:"inline-flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",s?"...":t.currentPage," of ",s?"...":t.totalPages]}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage-1),disabled:s||1===t.currentPage,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage+1),disabled:s||t.currentPage===t.totalPages,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]}),(0,r.jsx)("div",{className:"h-[32rem] overflow-auto",children:(0,r.jsx)(el,{columns:y.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ew=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:n,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u,organizations:h,setCurrentOrg:p}=e,[_,y]=(0,i.useState)(!1),[v,S]=(0,i.useState)(!1),[A,E]=(0,i.useState)(null),[O,M]=(0,i.useState)(null),[D,L]=(0,i.useState)(null),[F,R]=(0,i.useState)((null==a?void 0:a.team_id)||""),[z,U]=(0,i.useState)("");(0,i.useEffect)(()=>{R((null==a?void 0:a.team_id)||"")},[a]);let{keys:V,isLoading:q,error:B,pagination:H,refresh:G}=W({selectedTeam:a,currentOrg:u,accessToken:t}),[Y,J]=(0,i.useState)(!1),[$,X]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(null),[el,es]=(0,i.useState)([]),et=new Set,[ea,er]=(0,i.useState)(!1),[ei,en]=(0,i.useState)(!1),[eo,ed]=(0,i.useState)(null),[ec,em]=(0,i.useState)(null),[eu]=k.Z.useForm(),[eh,ex]=(0,i.useState)(null),[ep,ej]=(0,i.useState)(et),[eg,ef]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",Q),(null==ec?void 0:ec.duration)?ex((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0})}catch(e){return null}})(ec.duration)):ex(null),console.log("calculateNewExpiryTime:",eh)},[Q,null==ec?void 0:ec.duration]),(0,i.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await T(l,s,t);e&&es(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,i.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ej(e)}},[c]);let eZ=async()=>{if(null!=A&&null!=o){try{await (0,x.I1)(t,A);let e=o.filter(e=>e.token!==A);d(e)}catch(e){console.error("Error deleting the key:",e)}S(!1),E(null)}},e_=(e,l)=>{em(s=>({...s,[e]:l}))},ey=async()=>{if(!m){I.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=Q)try{let e=await eu.validateFields(),l=await (0,x.s0)(t,Q.token,e);if(ed(l.key),o){let s=o.map(s=>s.token===(null==Q?void 0:Q.token)?{...s,key_name:l.key_name,...e}:s);d(s)}en(!1),eu.resetFields(),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key")}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eb,{keys:V,isLoading:q,pagination:H,onPageChange:e=>{G({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:n,accessToken:t,userID:l,userRole:s,organizations:h,setCurrentOrg:p}),v&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eZ,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{S(!1),E(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(C.Z,{title:"Regenerate API Key",visible:ei,onCancel:()=>{en(!1),eu.resetFields()},footer:[(0,r.jsx)(f.Z,{onClick:()=>{en(!1),eu.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:ey,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(k.Z,{form:eu,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&e_("duration",e.duration)},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry:"," ",(null==Q?void 0:Q.expires)!=null?new Date(Q.expires).toLocaleString():"Never"]}),eh&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eh]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),eo&&(0,r.jsx)(C.Z,{visible:!!eo,onCancel:()=>ed(null),footer:[(0,r.jsx)(f.Z,{onClick:()=>ed(null),children:"Close"},"close")],children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==Q?void 0:Q.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:eo})}),(0,r.jsx)(N.CopyToClipboard,{text:eo,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eN=s(12011),eS=s(93192);console.log=function(){},console.log("isLocal:",!1);var ek=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,premiumUser:f,organizations:Z}=e,[_,y]=(0,i.useState)(null),[v,b]=(0,i.useState)(null),w=(0,n.useSearchParams)(),N=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),S=w.get("invitation_id"),[k,I]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),[P,E]=(0,i.useState)([]),[O,T]=(0,i.useState)(null),[M,D]=(0,i.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,i.useEffect)(()=>{if(N){let e=(0,o.o)(N);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),d(l)}else console.log("User role not defined");e.user_email?m(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&k&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);e?E(JSON.parse(e)):(console.log("currentOrg: ".concat(JSON.stringify(v))),(async()=>{try{let e=await (0,x.g)(k);T(e);let t=await (0,x.Br)(k,l,s,!1,null,null);y(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(_))),(null==t?void 0:t.teams[0].keys)?h(t.keys.concat(t.teams.filter(e=>"Admin"===s||e.user_id===l).flatMap(e=>e.keys))):h(t.keys),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,x.So)(k,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),E(a),console.log("userModels:",P),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),p(k,l,s,v,u))}},[l,N,k,a,s]),(0,i.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(v),", accessToken: ").concat(k,", userID: ").concat(l,", userRole: ").concat(s)),k&&(console.log("fetching teams"),p(k,l,s,v,u))},[v]),(0,i.useEffect)(()=>{if(null!==a&&null!=M&&null!==M.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))M.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===M.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),A(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;A(e)}},[M]),null!=S)return(0,r.jsx)(eN.default,{});if(null==l||null==N){let e="/sso/key/generate";return document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",console.log("Full URL:",e),window.location.href=e,null}if(null==k)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",M),(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(j.Z,{numColSpan:1,className:"flex flex-col gap-2",children:[(0,r.jsx)(B,{userID:l,team:M,teams:t,userRole:s,accessToken:k,data:a,setData:h},M?M.team_id:null),(0,r.jsx)(ew,{userID:l,userRole:s,accessToken:k,selectedTeam:M||null,setSelectedTeam:D,data:a,setData:h,premiumUser:f,teams:t,currentOrg:v,setCurrentOrg:b,organizations:Z})]})})})},eI=s(97765);(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.Groq="Groq",t.MistralAI="Mistral AI",t.Deepseek="Deepseek",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI",t.AssemblyAI="AssemblyAI";let eC={OpenAI:"openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",Groq:"groq",MistralAI:"mistral",Cohere:"cohere_chat",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",xAI:"xai",Deepseek:"deepseek",Ollama:"ollama",AssemblyAI:"assemblyai"},eA={OpenAI:"https://artificialanalysis.ai/img/logos/openai_small.svg",Azure:"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg","Azure AI Studio":"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg",Anthropic:"https://artificialanalysis.ai/img/logos/anthropic_small.svg","Google AI Studio":"https://artificialanalysis.ai/img/logos/google_small.svg","Amazon Bedrock":"https://artificialanalysis.ai/img/logos/aws_small.png",Groq:"https://artificialanalysis.ai/img/logos/groq_small.png","Mistral AI":"https://artificialanalysis.ai/img/logos/mistral_small.png",Cohere:"https://artificialanalysis.ai/img/logos/cohere_small.png","OpenAI-Compatible Endpoints (Together AI, etc.)":"https://upload.wikimedia.org/wikipedia/commons/4/4e/OpenAI_Logo.svg","Vertex AI (Anthropic, Gemini, etc.)":"https://artificialanalysis.ai/img/logos/google_small.svg",Databricks:"https://artificialanalysis.ai/img/logos/databricks_small.png",Ollama:"https://artificialanalysis.ai/img/logos/ollama_small.svg",xAI:"https://artificialanalysis.ai/img/logos/xai_small.svg",Deepseek:"https://artificialanalysis.ai/img/logos/deepseek_small.jpg",AssemblyAI:"https://artificialanalysis.ai/img/logos/assemblyai_small.png"},eP=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(eC).find(l=>eC[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eA[s],displayName:s}},eE=e=>"Vertex AI (Anthropic, Gemini, etc.)"===e?"gemini-pro":"Anthropic"==e||"Amazon Bedrock"==e?"claude-3-opus":"Google AI Studio"==e?"gemini-pro":"Azure AI Studio"==e?"azure_ai/command-r-plus":"Azure"==e?"azure/my-deployment":"gpt-3.5-turbo",eO=(e,l)=>{console.log("Provider key: ".concat(e));let s=eC[e];console.log("Provider mapped to: ".concat(s));let t=[];return e&&"object"==typeof l&&(Object.entries(l).forEach(e=>{let[l,a]=e;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===s||a.litellm_provider.includes(s))&&t.push(l)}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(l).forEach(e=>{let[l,s]=e;null!==s&&"object"==typeof s&&"litellm_provider"in s&&"cohere"===s.litellm_provider&&t.push(l)}))),t},eT=async(e,l,s,t)=>{try{console.log("handling submit for formValues:",e);let a=e.model_mappings||[];if("model_mappings"in e&&delete e.model_mappings,e.model&&e.model.includes("all-wildcard")){let l=eC[e.custom_llm_provider]+"/*";e.model_name=l,a.push({public_name:l,litellm_model:l}),e.model=l}for(let s of a){let t={},a={},r=s.public_name;for(let[l,r]of(t.model=s.litellm_model,e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),t.model=s.litellm_model,console.log("formValues add deployment:",e),Object.entries(e)))if(""!==r&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)t.model=r;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",r);let e=eC[r];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=r;else if("team_id"===l)a.team_id=r;else if("custom_model_name"===l)t.model=r;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))a[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){r&&(t[l]=Number(r));continue}else t[l]=r}let i={model_name:r,litellm_params:t,model_info:a},n=await (0,x.kK)(l,i);console.log("response for model create call: ".concat(n.data))}t&&t(),s.resetFields()}catch(e){I.ZP.error("Failed to create model: "+e,10)}},eM=e=>{var l;return(null==e?void 0:null===(l=e.model_info)||void 0===l?void 0:l.team_public_model_name)?e.model_info.team_public_model_name:(null==e?void 0:e.model_name)||"-"},eD=async(e,l,s,t)=>{if(console.log("handleEditSubmit:",e),null==l)return;let a={},r=null;for(let[l,s]of(e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),Object.entries(e)))"model_id"!==l?a[l]=""===s?null:s:r=""===s?null:s;let i={litellm_params:Object.keys(a).length>0?a:void 0,model_info:void 0!==r?{id:r}:void 0};console.log("handleEditSubmit payload:",i);try{await (0,x.um)(l,i),I.ZP.success("Model updated successfully, restart server to see updates"),s(!1),t(null)}catch(e){console.log("Error occurred")}};var eL=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[i]=k.Z.useForm(),n={},o="",d="";if(t){var c,m;n={...t.litellm_params,input_cost_per_token:(null===(c=t.litellm_params)||void 0===c?void 0:c.input_cost_per_token)?1e6*t.litellm_params.input_cost_per_token:void 0,output_cost_per_token:(null===(m=t.litellm_params)||void 0===m?void 0:m.output_cost_per_token)?1e6*t.litellm_params.output_cost_per_token:void 0},o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),n.model_id=d)}return(0,r.jsx)(C.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{a({...e,input_cost_per_token:e.input_cost_per_token?Number(e.input_cost_per_token)/1e6:void 0,output_cost_per_token:e.output_cost_per_token?Number(e.output_cost_per_token)/1e6:void 0}),i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(k.Z,{form:i,onFinish:a,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},eF=s(53003),eR=s(47323),ez=s(75105),eU=s(40278),eV=s(69410),eq=s(14301),eB=s(53410),eK=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,n]=(0,i.useState)(!1),o=async()=>{try{I.ZP.info("Making API Call"),n(!0);let e=await (0,x.Og)(s,l);console.log("model delete Response:",e),I.ZP.success("Model ".concat(l," deleted successfully")),n(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eR.Z,{onClick:()=>n(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(C.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>n(!1),children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Delete Model"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Model ID: ",(0,r.jsx)("b",{children:l})]})})]})})]})},eW=s(94789),eH=s(59664),eG=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eH.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,r.jsxs)("div",{children:[(0,r.jsx)(eW.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,r.jsx)(f.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eY=e=>{var l,s,t;let{visible:a,onCancel:n,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=k.Z.useForm();console.log("Initial Data:",d),(0,i.useEffect)(()=>{if(a){if("edit"===c&&d)u.setFieldsValue({...d,role:d.role||m.defaultRole});else{var e;u.resetFields(),u.setFieldsValue({role:m.defaultRole||(null===(e=m.roleOptions[0])||void 0===e?void 0:e.value)})}}},[a,d,c,u,m.defaultRole,m.roleOptions]);let h=async e=>{try{let l=Object.entries(e).reduce((e,l)=>{let[s,t]=l;return{...e,[s]:"string"==typeof t?t.trim():t}},{});o(l),u.resetFields(),I.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){I.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}},x=e=>{switch(e.type){case"input":return(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",onChange:e=>{e.target.value=e.target.value.trim()}});case"select":var l;return(0,r.jsx)(S.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(C.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:n,children:(0,r.jsxs)(k.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),m.showEmail&&m.showUserId&&(0,r.jsx)("div",{className:"text-center mb-4",children:(0,r.jsx)(b.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{children:"Role"}),"edit"===c&&d&&(0,r.jsxs)("span",{className:"text-gray-500 text-sm",children:["(Current: ",(s=d.role,(null===(t=m.roleOptions.find(e=>e.value===s))||void 0===t?void 0:t.label)||s),")"]})]}),name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,r.jsx)(S.default,{children:"edit"===c&&d?[...m.roleOptions.filter(e=>e.value===d.role),...m.roleOptions.filter(e=>e.value!==d.role)].map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))})}),null===(l=m.additionalFields)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.Z.Item,{label:e.label,name:e.name,className:"mb-4",rules:e.rules,children:x(e)},e.name)),(0,r.jsxs)("div",{className:"text-right mt-6",children:[(0,r.jsx)(O.ZP,{onClick:n,className:"mr-2",children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},eJ=s(7310),e$=s.n(eJ),eX=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:n="Add Team Member",roles:o=[{label:"admin",value:"admin",description:"Admin role. Can create team keys, add members, and manage settings."},{label:"user",value:"user",description:"User role. Can view team info, but not manage it."}],defaultRole:d="user"}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}p(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,x.u5)(a,s)).map(e=>({label:"user_email"===l?"".concat(e.user_email):"".concat(e.user_id),value:"user_email"===l?e.user_email:e.user_id,user:e}));u(t)}catch(e){console.error("Error fetching users:",e)}finally{p(!1)}},Z=(0,i.useCallback)(e$()((e,l)=>f(e,l),300),[]),_=(e,l)=>{g(l),Z(e,l)},y=(e,l)=>{let s=l.user;c.setFieldsValue({user_email:s.user_email,user_id:s.user_id,role:c.getFieldValue("role")})};return(0,r.jsx)(C.Z,{title:n,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(k.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>_(e,"user_email"),onSelect:(e,l)=>y(e,l),options:"user_email"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>_(e,"user_id"),onSelect:(e,l)=>y(e,l),options:"user_id"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(k.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:(0,r.jsxs)(R.Z,{title:e.description,children:[(0,r.jsx)("span",{className:"font-medium",children:e.label}),(0,r.jsxs)("span",{className:"ml-2 text-gray-500 text-sm",children:["- ",e.description]})]})},e.value))})}),(0,r.jsx)("div",{className:"text-right mt-4",children:(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},eQ=e=>{var l;let{teamId:s,onClose:t,accessToken:a,is_team_admin:n,is_proxy_admin:o,userModels:d,editTeam:c}=e,[m,u]=(0,i.useState)(null),[h,p]=(0,i.useState)(!0),[j,Z]=(0,i.useState)(!1),[_]=k.Z.useForm(),[y,v]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null),[A,T]=(0,i.useState)(!1);console.log("userModels in team info",d);let D=n||o,L=async()=>{try{if(p(!0),!a)return;let e=await (0,x.Xm)(a,s);u(e)}catch(e){I.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{p(!1)}};(0,i.useEffect)(()=>{L()},[s,a]);let z=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.cu)(a,s,l),I.ZP.success("Team member added successfully"),Z(!1),_.resetFields(),L()}catch(e){I.ZP.error("Failed to add team member"),console.error("Error adding team member:",e)}},U=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.sN)(a,s,l),I.ZP.success("Team member updated successfully"),v(!1),L()}catch(e){I.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},V=async e=>{try{if(null==a)return;await (0,x.Lp)(a,s,e),I.ZP.success("Team member removed successfully"),L()}catch(e){I.ZP.error("Failed to remove team member"),console.error("Error removing team member:",e)}},q=async e=>{try{var l;if(!a)return;let t={team_id:s,team_alias:e.team_alias,models:e.models,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration,metadata:{...null==m?void 0:null===(l=m.team_info)||void 0===l?void 0:l.metadata,guardrails:e.guardrails||[]}};await (0,x.Gh)(a,t),I.ZP.success("Team settings updated successfully"),T(!1),L()}catch(e){I.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(h)return(0,r.jsx)("div",{className:"p-4",children:"Loading..."});if(!(null==m?void 0:m.team_info))return(0,r.jsx)("div",{className:"p-4",children:"Team not found"});let{team_info:B}=m;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:B.team_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:B.team_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",B.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===B.max_budget?"Unlimited":"$".concat(B.max_budget)]}),B.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",B.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",B.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",B.rpm_limit||"Unlimited"]}),B.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",B.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:B.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:m.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)($.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{C(e),v(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>V(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(f.Z,{onClick:()=>Z(!0),children:"Add Member"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Team Settings"}),D&&!A&&(0,r.jsx)(f.Z,{onClick:()=>T(!0),children:"Edit Settings"})]}),A?(0,r.jsxs)(k.Z,{form:_,onFinish:q,initialValues:{...B,team_alias:B.team_alias,models:B.models,tpm_limit:B.tpm_limit,rpm_limit:B.rpm_limit,max_budget:B.max_budget,budget_duration:B.budget_duration,guardrails:(null===(l=B.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(E.Z,{type:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>T(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:B.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:B.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(B.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:B.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",B.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",B.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==B.max_budget?"$".concat(B.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",B.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:B.blocked?"red":"green",children:B.blocked?"Blocked":"Active"})]})]})]})})]})]}),(0,r.jsx)(eY,{visible:y,onCancel:()=>v(!1),onSubmit:U,initialData:N,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Admin",value:"admin"},{label:"User",value:"user"}]}}),(0,r.jsx)(eX,{isVisible:j,onCancel:()=>Z(!1),onSubmit:z,accessToken:a})]})};function e0(e){var l,s,t,a,n,o,d,c,m,u,h;let{modelId:p,onClose:j,modelData:Z,accessToken:_,userID:y,userRole:v,editModel:N,setEditModalVisible:S,setSelectedModel:C}=e,[A,P]=(0,i.useState)(!1),[E]=k.Z.useForm(),[T,M]=(0,i.useState)(!1),D="Admin"===v;if(!Z)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsx)(b.Z,{children:"Model not found"})]});let L=async()=>{try{if(!_)return;await (0,x.Og)(_,p),I.ZP.success("Model deleted successfully"),j()}catch(e){console.error("Error deleting the model:",e),I.ZP.error("Failed to delete model")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsxs)(w.Z,{children:["Public Model Name: ",eM(Z)]}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:Z.model_info.id})]}),D&&(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>M(!0),className:"flex items-center",children:"Delete Model"})})]}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-6",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Raw JSON"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6 mb-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Provider"}),(0,r.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[Z.provider&&(0,r.jsx)("img",{src:eP(Z.provider).logo,alt:"".concat(Z.provider," logo"),className:"w-4 h-4",onError:e=>{let l=e.target,s=l.parentElement;if(s){var t;let e=document.createElement("div");e.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=(null===(t=Z.provider)||void 0===t?void 0:t.charAt(0))||"-",s.replaceChild(e,l)}}}),(0,r.jsx)(w.Z,{children:Z.provider||"Not Set"})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"LiteLLM Model"}),(0,r.jsx)("pre",{children:(0,r.jsx)(w.Z,{children:Z.litellm_model_name||"Not Set"})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Pricing"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Input: $",Z.input_cost,"/1M tokens"]}),(0,r.jsxs)(b.Z,{children:["Output: $",Z.output_cost,"/1M tokens"]})]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Model Settings"}),D&&!A&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>P(!0),children:"Edit Settings"})]}),A?(0,r.jsx)(eL,{visible:A,onCancel:()=>P(!1),model:Z,onSubmit:e=>eD(e,_,S,C)}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model ID"}),(0,r.jsx)("div",{className:"font-mono",children:Z.model_info.id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Public Model Name"}),(0,r.jsx)("div",{children:eM(Z)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Model Name"}),(0,r.jsx)("div",{children:Z.litellm_model_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Input Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(l=Z.litellm_params)||void 0===l?void 0:l.input_cost_per_token)?(1e6*Z.litellm_params.input_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Output Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(s=Z.litellm_params)||void 0===s?void 0:s.output_cost_per_token)?(1e6*Z.litellm_params.output_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"API Base"}),(0,r.jsx)("div",{children:(null===(t=Z.litellm_params)||void 0===t?void 0:t.api_base)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Custom LLM Provider"}),(0,r.jsx)("div",{children:(null===(a=Z.litellm_params)||void 0===a?void 0:a.custom_llm_provider)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model"}),(0,r.jsx)("div",{children:(null===(n=Z.litellm_params)||void 0===n?void 0:n.model)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)("div",{children:(null===(o=Z.litellm_params)||void 0===o?void 0:o.organization)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"TPM (Tokens per Minute)"}),(0,r.jsx)("div",{children:(null===(d=Z.litellm_params)||void 0===d?void 0:d.tpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"RPM (Requests per Minute)"}),(0,r.jsx)("div",{children:(null===(c=Z.litellm_params)||void 0===c?void 0:c.rpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Max Retries"}),(0,r.jsx)("div",{children:(null===(m=Z.litellm_params)||void 0===m?void 0:m.max_retries)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(u=Z.litellm_params)||void 0===u?void 0:u.timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Stream Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(h=Z.litellm_params)||void 0===h?void 0:h.stream_timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{children:Z.model_info.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:Z.model_info.created_at?new Date(Z.model_info.created_at).toLocaleString():"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created By"}),(0,r.jsx)("div",{children:Z.model_info.created_by||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Parameters"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(Z.cleanedLitellmParams,null,2)})]})]})]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsx)("pre",{className:"bg-gray-100 p-4 rounded text-xs overflow-auto",children:JSON.stringify(Z,null,2)})})})]})]}),T&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Model"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this model?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(O.ZP,{onClick:L,className:"ml-2",danger:!0,children:"Delete"}),(0,r.jsx)(O.ZP,{onClick:()=>M(!1),children:"Cancel"})]})]})]})})]})}var e1=s(67960),e2=s(47451),e4=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,i=k.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,r.jsx)(k.Z.Item,{name:"model",rules:[{required:!0,message:"Please select at least one model."}],noStyle:!0,children:l===a.Azure||l===a.OpenAI_Compatible||l===a.Ollama?(0,r.jsx)(Z.Z,{placeholder:t(l)}):s.length>0?(0,r.jsx)(S.default,{mode:"multiple",allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{let l=Array.isArray(e)?e:[e];if(l.includes("all-wildcard"))i.setFieldsValue({model_name:void 0,model_mappings:[]});else{let e=l.map(e=>({public_name:e,litellm_model:e}));i.setFieldsValue({model_mappings:e})}},optionFilterProp:"children",filterOption:(e,l)=>{var s;return(null!==(s=null==l?void 0:l.label)&&void 0!==s?s:"").toLowerCase().includes(e.toLowerCase())},options:[{label:"All ".concat(l," Models (Wildcard)"),value:"all-wildcard"},...s.map(e=>({label:e,value:e})),{label:"Custom Model Name (Enter below)",value:"custom"}],style:{width:"100%"}}):(0,r.jsx)(Z.Z,{placeholder:t(l)})}),(0,r.jsx)(k.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,r.jsx)(k.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name."}],className:"mt-2",children:(0,r.jsx)(Z.Z,{placeholder:"Enter custom model name"})})}})]}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},e5=s(48379),e3=()=>{let e=k.Z.useFormInstance(),l=k.Z.useWatch("model",e)||[],s=!l.includes("all-wildcard");if((0,i.useEffect)(()=>{if(l.length>0&&!l.includes("all-wildcard")){let s=l.map(e=>({public_name:e,litellm_model:e}));e.setFieldValue("model_mappings",s)}},[l,e]),!s)return null;let t=[{title:"Public Name",dataIndex:"public_name",key:"public_name",render:(l,s,t)=>(0,r.jsx)(Z.Z,{defaultValue:l,onChange:l=>{let s=[...e.getFieldValue("model_mappings")];s[t].public_name=l.target.value,e.setFieldValue("model_mappings",s)}})},{title:"LiteLLM Model",dataIndex:"litellm_model",key:"litellm_model"}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Model Mappings",name:"model_mappings",tooltip:"Map public model names to LiteLLM model names for load balancing",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!0,children:(0,r.jsx)(e5.Z,{dataSource:e.getFieldValue("model_mappings"),columns:t,pagination:!1,size:"small"})}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})},e8=s(87024),e6=s(3632);let{Link:e7}=eS.default;var e9=e=>{let{selectedProvider:l,uploadProps:s}=e;console.log("Selected provider: ".concat(l)),console.log("type of selectedProvider: ".concat(typeof l));let t=a[l];return console.log("selectedProviderEnum: ".concat(t)),console.log("type of selectedProviderEnum: ".concat(typeof t)),(0,r.jsxs)(r.Fragment,{children:[t===a.OpenAI&&(0,r.jsx)(k.Z.Item,{label:"OpenAI Organization ID",name:"organization",children:(0,r.jsx)(Z.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),t===a.Vertex_AI&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,r.jsx)(Z.Z,{placeholder:"adroit-cadet-1234.."})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(e8.Z,{...s,children:(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(e6.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]})]}),t===a.AssemblyAI&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(S.default,{placeholder:"Select API Base",children:[(0,r.jsx)(S.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(S.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsx)(Z.Z,{placeholder:"https://..."})}),t===a.Azure&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"API Version",name:"api_version",tooltip:"By default litellm will use the latest version. If you want to use a different version, you can specify it here",children:(0,r.jsx)(Z.Z,{placeholder:"2023-07-01-preview"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(k.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,r.jsx)(Z.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(e7,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]})]}),t===a.Bedrock&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})})]}),t!=a.Bedrock&&t!=a.Vertex_AI&&t!=a.Ollama&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",tooltip:"LLM API Credentials",children:(0,r.jsx)(Z.Z,{placeholder:"sk-",type:"password"})})]})},le=s(63709),ll=s(90464);let{Link:ls}=eS.default;var lt=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s,teams:t}=e,[a]=k.Z.useForm(),[n,o]=i.useState(!1),[d,c]=i.useState("per_token"),m=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),u=(e,l)=>{if(!l)return Promise.resolve();try{return JSON.parse(l),Promise.resolve()}catch(e){return Promise.reject("Please enter valid JSON")}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(_.Z,{className:"mt-2 mb-4",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Advanced Settings"})}),(0,r.jsx)(y.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",className:"mb-4",children:(0,r.jsx)(L,{teams:t})}),(0,r.jsx)(k.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(le.Z,{onChange:e=>{o(e),e||a.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),n&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(k.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:"per_token",onChange:e=>c(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(k.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(k.Z.Item,{label:"Use in pass through routes",name:"use_in_pass_through",valuePropName:"checked",className:"mb-4 mt-4",tooltip:(0,r.jsxs)("span",{children:["Allow using these credentials in pass through routes."," ",(0,r.jsx)(ls,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(le.Z,{onChange:e=>{let l=a.getFieldValue("litellm_extra_params");try{let s=l?JSON.parse(l):{};e?s.use_in_pass_through=!0:delete s.use_in_pass_through,Object.keys(s).length>0?a.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):a.setFieldValue("litellm_extra_params","")}catch(l){e?a.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):a.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(k.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-4 mt-4",rules:[{validator:u}],children:(0,r.jsx)(ll.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(e2.Z,{className:"mb-4",children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(ls,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(k.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",rules:[{validator:u}],children:(0,r.jsx)(ll.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})};let{Title:la,Link:lr}=eS.default;var li=e=>{let{form:l,handleOk:s,selectedProvider:t,setSelectedProvider:i,providerModels:n,setProviderModelsFn:o,getPlaceholder:d,uploadProps:c,showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(la,{level:2,children:"Add new model"}),(0,r.jsx)(e1.Z,{children:(0,r.jsx)(k.Z,{form:l,onFinish:s,labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,r.jsx)(S.default,{showSearch:!0,value:t,onChange:e=>{i(e),o(e),l.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(S.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eA[s],alt:"".concat(l," logo"),className:"w-5 h-5",onError:e=>{let l=e.target,t=l.parentElement;if(t){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=s.charAt(0),t.replaceChild(e,l)}}}),(0,r.jsx)("span",{children:s})]})},l)})})}),(0,r.jsx)(e4,{selectedProvider:t,providerModels:n,getPlaceholder:d}),(0,r.jsx)(e3,{}),(0,r.jsx)(e9,{selectedProvider:t,uploadProps:c}),(0,r.jsx)(lt,{showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}),(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(R.Z,{title:"Get help on our github",children:(0,r.jsx)(eS.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]})};let{Title:ln,Link:lo}=eS.default,ld={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var lc=e=>{let{accessToken:l,token:s,userRole:t,userID:n,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m,teams:u}=e,[h,p]=(0,i.useState)([]),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(""),[N,S]=(0,i.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[C,A]=(0,i.useState)([]),[E,O]=(0,i.useState)(a.OpenAI),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(!1),[F,z]=(0,i.useState)(null),[U,V]=(0,i.useState)([]),[q,B]=(0,i.useState)([]),[K,W]=(0,i.useState)(null),[H,G]=(0,i.useState)([]),[el,em]=(0,i.useState)([]),[eh,ex]=(0,i.useState)([]),[ep,ej]=(0,i.useState)([]),[eg,eZ]=(0,i.useState)([]),[e_,ey]=(0,i.useState)([]),[ev,eb]=(0,i.useState)([]),[ew,eN]=(0,i.useState)([]),[ek,eA]=(0,i.useState)([]),[eW,eH]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eY,eJ]=(0,i.useState)(null),[e$,eX]=(0,i.useState)(0),[e1,e2]=(0,i.useState)({}),[e4,e5]=(0,i.useState)([]),[e3,e8]=(0,i.useState)(!1),[e6,e7]=(0,i.useState)(null),[e9,le]=(0,i.useState)(null),[ll,ls]=(0,i.useState)([]),[lt,la]=(0,i.useState)(!1),[lr,ln]=(0,i.useState)(null),[lo,lc]=(0,i.useState)(!1),[lm,lu]=(0,i.useState)(null),lh=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!n||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),W(e);let r=null==e6?void 0:e6.token;void 0===r&&(r=null);let i=e9;void 0===i&&(i=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,x.o6)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model metrics response:",o),em(o.data),ex(o.all_api_bases);let d=await (0,x.Rg)(l,e,s.toISOString(),a.toISOString());ej(d.data),eZ(d.all_api_bases);let c=await (0,x.N8)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model exceptions response:",c),ey(c.data),eb(c.exception_types);let m=await (0,x.fP)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);if(console.log("slowResponses:",m),eA(m),e){let t=await (0,x.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e2(t);let r=await (0,x.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e5(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,i.useEffect)(()=>{lh(K,eW.from,eW.to)},[e6,e9]);let lx=e=>{z(e),L(!0)},lp=()=>{v(new Date().toLocaleString())},lj=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eY);try{await (0,x.K_)(l,{router_settings:{model_group_retry_policy:eY}}),I.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),I.ZP.error("Failed to save retry settings")}};if((0,i.useEffect)(()=>{if(!l||!s||!t||!n)return;let e=async()=>{try{var e,s,a,r,i,o,d,m,u,h,p,j;let g=await (0,x.hy)(l);A(g);let f=await (0,x.AZ)(l,n,t);console.log("Model data response:",f.data),c(f);let Z=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",K);let v=await (0,x.o6)(l,n,t,y,null===(e=eW.from)||void 0===e?void 0:e.toISOString(),null===(s=eW.to)||void 0===s?void 0:s.toISOString(),null==e6?void 0:e6.token,e9);console.log("Model metrics response:",v),em(v.data),ex(v.all_api_bases);let b=await (0,x.Rg)(l,y,null===(a=eW.from)||void 0===a?void 0:a.toISOString(),null===(r=eW.to)||void 0===r?void 0:r.toISOString());ej(b.data),eZ(b.all_api_bases);let w=await (0,x.N8)(l,n,t,y,null===(i=eW.from)||void 0===i?void 0:i.toISOString(),null===(o=eW.to)||void 0===o?void 0:o.toISOString(),null==e6?void 0:e6.token,e9);console.log("Model exceptions response:",w),ey(w.data),eb(w.exception_types);let N=await (0,x.fP)(l,n,t,y,null===(d=eW.from)||void 0===d?void 0:d.toISOString(),null===(m=eW.to)||void 0===m?void 0:m.toISOString(),null==e6?void 0:e6.token,e9),S=await (0,x.n$)(l,null===(u=eW.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=eW.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);e2(S);let k=await (0,x.v9)(l,null===(p=eW.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=eW.to)||void 0===j?void 0:j.toISOString().split("T")[0],y);e5(k),console.log("dailyExceptions:",S),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",N),eA(N);let I=await (0,x.j2)(l);ls(null==I?void 0:I.end_users);let C=(await (0,x.BL)(l,n,t)).router_settings;console.log("routerSettingsInfo:",C);let P=C.model_group_retry_policy,E=C.num_retries;console.log("model_group_retry_policy:",P),console.log("default_retries:",E),eJ(P),eX(E)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&n&&e();let a=async()=>{let e=await (0,x.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),_(e)};null==Z&&a(),lp()},[l,s,t,n,Z,y]),!o||!l||!s||!t||!n)return(0,r.jsx)("div",{children:"Loading..."});let lg=[],lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(Z)),null!=Z&&"object"==typeof Z&&e in Z)?Z[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(r=t)||(r=1===e.length?u(s):l)}else r="-";a&&(i=null==a?void 0:a.input_cost_per_token,n=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==l?void 0:l.litellm_params)&&(m=Object.fromEntries(Object.entries(null==l?void 0:l.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),o.data[e].provider=r,o.data[e].input_cost=i,o.data[e].output_cost=n,o.data[e].litellm_model_name=s,lf.push(r),o.data[e].input_cost&&(o.data[e].input_cost=(1e6*Number(o.data[e].input_cost)).toFixed(2)),o.data[e].output_cost&&(o.data[e].output_cost=(1e6*Number(o.data[e].output_cost)).toFixed(2)),o.data[e].max_tokens=d,o.data[e].max_input_tokens=c,o.data[e].api_base=null==l?void 0:null===(ly=l.litellm_params)||void 0===ly?void 0:ly.api_base,o.data[e].cleanedLitellmParams=m,lg.push(l.model_name),console.log(o.data[e])}if(o.data&&o.data.length>0&&o.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lv=async()=>{try{I.ZP.info("Running health check..."),M("");let e=await (0,x.EY)(l);M(e)}catch(e){console.error("Error running health check:",e),M("Error running health check")}},lb=(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Select API Key Name"}),m?(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{e7(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{le(e)},children:e},l))]})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsxs)(et.Z,{value:String(l),disabled:!0,onClick:()=>{e7(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{le(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lw=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let i=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,n=t.sort((e,l)=>l.value-e.value);if(n.length>5){let e=n.length-5;(n=n.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,r.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[i&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",i]}),n.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,r.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,r.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})};console.log("selectedProvider: ".concat(E)),console.log("providerModels.length: ".concat(N.length));let lN=Object.keys(a).find(e=>a[e]===E);return(lN&&C.find(e=>e.name===eC[lN]),lm)?(0,r.jsx)("div",{className:"w-full h-full",children:(0,r.jsx)(eQ,{teamId:lm,onClose:()=>lu(null),accessToken:l,is_team_admin:"Admin"===t,is_proxy_admin:"Proxy Admin"===t,userModels:lg,editTeam:!1})}):(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:lr?(0,r.jsx)(e0,{modelId:lr,editModel:!0,onClose:()=>{ln(null),lc(!1)},modelData:o.data.find(e=>e.model_info.id===lr),accessToken:l,userID:n,userRole:t,setEditModalVisible:L,setSelectedModel:z}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"All Models"}),(0,r.jsx)(ei.Z,{children:"Add Model"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(ei.Z,{children:"Model Analytics"}),(0,r.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[y&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",y]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lp})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||void 0,onValueChange:e=>W("all"===e?"all":e),value:K||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Model ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created At":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created By":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Team ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:o.data.filter(e=>"all"===K||e.model_name===K||null==K||""===K).map((e,s)=>{var a;return(0,r.jsxs)(ee.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.model_info.id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>ln(e.model_info.id),children:[e.model_info.id.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:eM(e)||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[e.provider&&(0,r.jsx)("img",{src:eP(e.provider).logo,alt:"".concat(e.provider," logo"),className:"w-4 h-4",onError:l=>{let s=l.target,t=s.parentElement;if(t){var a;let l=document.createElement("div");l.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",l.textContent=(null===(a=e.provider)||void 0===a?void 0:a.charAt(0))||"-",t.replaceChild(l,s)}}}),(0,r.jsx)("p",{className:"text-xs",children:e.provider||"-"})]})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.litellm_model_name,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.litellm_model_name?e.litellm_model_name:"",children:e&&e.litellm_model_name?e.litellm_model_name.slice(0,20)+(e.litellm_model_name.length>20?"...":""):"-"})})}),"Admin"===t&&(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.api_base,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:null!=e.litellm_params.input_cost_per_token&&void 0!=e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&((a=e.model_info.created_at)?new Date(a).toLocaleDateString("en-US"):null)||"-"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:e.model_info.team_id?(0,r.jsx)(R.Z,{title:e.model_info.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-purple-500 bg-purple-50 hover:bg-purple-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{lu(e.model_info.team_id)},children:[e.model_info.team_id.slice(0,7),"..."]})}):"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,r.jsx)(ea.Z,{size:"xs",className:"text-white",children:(0,r.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,r.jsx)(ea.Z,{size:"xs",className:"text-black",children:(0,r.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>lx(e)})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eK,{modelID:e.model_info.id,accessToken:l,callback:lp})})]})})]},s)})})]})})]}),(0,r.jsx)(eL,{visible:D,onCancel:()=>{L(!1),z(null)},model:F,onSubmit:e=>eD(e,l,L,z)})]}),(0,r.jsx)(ed.Z,{className:"h-full",children:(0,r.jsx)(li,{form:j,handleOk:()=>{j.validateFields().then(e=>{eT(e,l,j,lp)}).catch(e=>{console.error("Validation failed:",e)})},selectedProvider:E,setSelectedProvider:O,providerModels:N,setProviderModelsFn:e=>{let l=eO(e,Z);S(l),console.log("providerModels: ".concat(l))},getPlaceholder:eE,uploadProps:{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;j.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?I.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&I.ZP.error("".concat(e.file.name," file upload failed."))}},showAdvancedSettings:lt,setShowAdvancedSettings:la,teams:u})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(f.Z,{onClick:lv,children:"Run `/health`"}),T&&(0,r.jsx)("pre",{children:JSON.stringify(T,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:eW,className:"mr-2",onValueChange:e=>{eH(e),lh(K,e.from,e.to)}})]}),(0,r.jsxs)(eV.Z,{className:"ml-2",children:[(0,r.jsx)(b.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:K||U[0],value:K||U[0],children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lh(e,eW.from,eW.to),children:e},l))})]}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eq.Z,{trigger:"click",content:lb,overlayStyle:{width:"20vw"},children:(0,r.jsx)(f.Z,{icon:ef.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>e8(!0)})})})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,r.jsx)(b.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),el&&eh&&(0,r.jsx)(ez.Z,{title:"Model Latency",className:"h-72",data:el,showLegend:!1,index:"date",categories:eh,connectNulls:!0,customTooltip:lw})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(eG,{modelMetrics:ep,modelMetricsCategories:eg,customTooltip:lw,premiumUser:m})})]})]})})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Deployment"}),(0,r.jsx)(Q.Z,{children:"Success Responses"}),(0,r.jsxs)(Q.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(J.Z,{children:ek.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.api_base}),(0,r.jsx)($.Z,{children:e.total_count}),(0,r.jsx)($.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Exceptions for ",K]}),(0,r.jsx)(eU.Z,{className:"h-60",data:e_,index:"model",categories:ev,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Up Rate Limit Errors (429) for ",K]}),(0,r.jsxs)(g.Z,{numItems:1,children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e1.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e1.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eV.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:e4.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,r.jsx)(r.Fragment,{children:e4&&e4.length>0&&e4.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||U[0],value:K||U[0],onValueChange:e=>W(e),children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))})]}),(0,r.jsxs)(w.Z,{children:["Retry Policy for ",K]}),(0,r.jsx)(b.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),ld&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(ld).map((e,l)=>{var s;let[t,a]=e,i=null==eY?void 0:null===(s=eY[K])||void 0===s?void 0:s[a];return null==i&&(i=e$),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(P.Z,{className:"ml-5",value:i,min:0,step:1,onChange:e=>{eJ(l=>{var s;let t=null!==(s=null==l?void 0:l[K])&&void 0!==s?s:{};return{...null!=l?l:{},[K]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(f.Z,{className:"mt-6 mr-8",onClick:lj,children:"Save"})]})]})]})})};function lm(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:i,Paragraph:n}=eS.default,o=()=>(null==a?void 0:a.has_user_setup_sso)?new URL("/ui",t).toString():new URL("/ui?invitation_id=".concat(null==a?void 0:a.id),t).toString();return(0,r.jsxs)(C.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(n,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(b.Z,{children:null==a?void 0:a.user_id})]}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{children:"Invitation Link"}),(0,r.jsx)(b.Z,{children:(0,r.jsx)(b.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>I.ZP.success("Copied!"),children:(0,r.jsx)(f.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:lu}=S.default;var lh=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,i.useState)(null),[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[j,g]=(0,i.useState)([]),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(null),N=(0,n.useRouter)(),[A,P]=(0,i.useState)("http://localhost:4000");(0,i.useEffect)(()=>{(async()=>{try{let e=await (0,x.So)(s,l,"any"),t=[];for(let l=0;l{N&&P(new URL("/",window.location.href).toString())},[N]);let T=async e=>{try{var t;I.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,x.Ov)(s,null,e);console.log("user create Response:",a),p(a.key);let r=(null===(t=a.data)||void 0===t?void 0:t.user_id)||a.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:r,is_accepted:!1,accepted_at:null,expires_at:new Date(Date.now()+6048e5),created_at:new Date,created_by:l,updated_at:new Date,updated_by:l,has_user_setup_sso:!0};w(e),y(!0)}else(0,x.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,w(e),y(!0)});I.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(C.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),p(null),c.resetFields()},children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(k.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(S.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(lu,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(lu,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(lm,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:y,baseUrl:A,invitationLinkData:v})]})},lx=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:n}=e,[o,d]=(0,i.useState)(a),[c]=k.Z.useForm();(0,i.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{n(e),c.resetFields(),t()};return a?(0,r.jsx)(C.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(k.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",help:"Across all keys (including keys with team_id).",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",help:"Ignored if the key has a team_id; team budget applies there.",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var lp=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:n,teams:o,setKeys:d}=e,[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(1),[y,v]=i.useState(null),[b,w]=(0,i.useState)(null),[N,S]=(0,i.useState)(!1),[k,C]=(0,i.useState)(null),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(null),[T,M]=(0,i.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let D=e=>{O(e),P(!0)},L=async()=>{if(E&&l)try{if(await (0,x.Eb)(l,[E]),I.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==E);h(e)}}catch(e){console.error("Error deleting user:",e),I.ZP.error("Failed to delete user")}P(!1),O(null)},F=async()=>{C(null),S(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&n){try{await (0,x.pf)(l,e,null),I.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}u&&h(u.map(l=>l.user_id===e.user_id?e:l)),C(null),S(!1)}};return((0,i.useEffect)(()=>{if(!l||!s||!a||!n)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,x.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)M(JSON.parse(s));else{let e=await (0,x.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),M(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&n&&e()},[l,s,a,n,Z]),u&&l&&s&&a&&n)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(g.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(lh,{userID:n,accessToken:l,teams:o,possibleUIRoles:T}),(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,r.jsx)("div",{className:"mb-4 mt-1"}),(0,r.jsx)(en.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(Y.Z,{className:"mt-5",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(Q.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(Q.Z,{children:"API Keys"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.user_id||"-"}),(0,r.jsx)($.Z,{children:e.user_email||"-"}),(0,r.jsx)($.Z,{children:(null==T?void 0:null===(l=T[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,r.jsx)($.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)($.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)($.Z,{children:(0,r.jsx)(g.Z,{numItems:2,children:e.key_count>0?(0,r.jsxs)(ea.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,r.jsx)(ea.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,onClick:()=>{C(e),S(!0)},children:"View Keys"}),(0,r.jsx)(eR.Z,{icon:eh.Z,onClick:()=>D(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,r.jsx)(lx,{visible:N,possibleUIRoles:T,onCancel:F,user:k,onSubmit:R}),A&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,r.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),_(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},lj=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,i.useState)([]);(0,i.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,x.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let n=async e=>{if(l&&s)try{await (0,x.cu)(l,e,{user_id:s,role:"user"}),I.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),I.ZP.error("Failed to join team")}};return(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Description"}),(0,r.jsx)(Q.Z,{children:"Members"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsxs)(J.Z,{children:[t.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.team_alias})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.description||"No description available"})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"flex flex-col",children:e.models&&0!==e.models.length?e.models.map((e,l)=>(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,r.jsx)(ea.Z,{size:"xs",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{size:"xs",variant:"secondary",onClick:()=>n(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(b.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};let lg=(e,l)=>{let s=[];return e&&e.models.length>0?(console.log("organization.models: ".concat(e.models)),s=e.models):s=l,D(s,l)};var lf=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:n,userRole:o,organizations:d}=e,[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(null),[w,N]=(0,i.useState)(null);(0,i.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&p(t,n,o,u,a),eO()},[c]);let[A]=k.Z.useForm(),[E]=k.Z.useForm(),{Title:D,Paragraph:L}=eS.default,[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(!1),[es,et]=(0,i.useState)(!1),[em,ex]=(0,i.useState)(!1),[ep,ej]=(0,i.useState)(!1),[eg,ef]=(0,i.useState)([]),[eZ,e_]=(0,i.useState)(!1),[ey,ev]=(0,i.useState)(null),[eb,ew]=(0,i.useState)([]),[eN,ek]=(0,i.useState)({}),[eI,eC]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("currentOrgForCreateTeam: ".concat(w));let e=lg(w,eg);console.log("models: ".concat(e)),ew(e),A.setFieldValue("models",[])},[w,eg]),(0,i.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,x.t3)(t)).guardrails.map(e=>e.guardrail_name);eC(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let eA=async e=>{ev(e),e_(!0)},eP=async()=>{if(null!=ey&&null!=l&&null!=t){try{await (0,x.rs)(t,ey),p(t,n,o,u,a)}catch(e){console.error("Error deleting the team:",e)}e_(!1),ev(null)}};(0,i.useEffect)(()=>{(async()=>{try{if(null===n||null===o||null===t)return;let e=await T(n,o,t);e&&ef(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,n,o,l]);let eE=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,i=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],n=(null==e?void 0:e.organization_id)||(null==u?void 0:u.organization_id);if(""===n||"string"!=typeof n?e.organization_id=null:e.organization_id=n.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,i.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));I.ZP.info("Creating Team");let o=await (0,x.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),I.ZP.success("Team created"),et(!1)}}catch(e){console.error("Error creating the team:",e),I.ZP.error("Error creating the team: "+e,20)}},eO=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:W?(0,r.jsx)(eQ,{teamId:W,onClose:()=>{H(null),el(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===W)),is_proxy_admin:"Admin"==o,userModels:eg,editTeam:G}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Your Teams"}),(0,r.jsx)(ei.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:eO})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(b.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-hidden overflow-y-auto max-h-[50vh]",children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Team ID"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Organization"}),(0,r.jsx)(Q.Z,{children:"Info"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.filter(e=>!u||e.organization_id===u.organization_id).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{H(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!==e.max_budget&&void 0!==e.max_budget?e.max_budget:"No limit"}),(0,r.jsx)($.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)($.Z,{children:e.organization_id}),(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].keys&&eN[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].members_with_roles&&eN[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)($.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{H(e.team_id),el(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>eA(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),eZ&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eP,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{e_(!1),ev(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>et(!0),children:"+ Create New Team"}),(0,r.jsx)(C.Z,{title:"Create Team",visible:es,width:800,footer:null,onOk:()=>{et(!1),A.resetFields()},onCancel:()=>{et(!1),A.resetFields()},children:(0,r.jsxs)(k.Z,{form:A,onFinish:eE,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Organization",name:"organization_id",initialValue:u?u.organization_id:null,className:"mt-8",children:(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{A.setFieldValue("organization_id",e),N((null==d?void 0:d.find(l=>l.organization_id===e))||null)},filterOption:(e,l)=>{var s;return!!l&&((null===(s=l.children)||void 0===s?void 0:s.toString())||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==d?void 0:d.map(e=>(0,r.jsxs)(S.default.Option,{value:e.organization_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.organization_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.organization_id,")"]})]},e.organization_id))})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected organization has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),eb.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Additional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",help:"ID of the team you want to create. If not provided, it will be generated automatically.",children:(0,r.jsx)(Z.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eI.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lj,{accessToken:t,userID:n})})]})]})})},lZ=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:n,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,i.useState)(null),[h,p]=(0,i.useState)(!0),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(!1),[y,v]=(0,i.useState)(!1),[N,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),D=n||o,L=async()=>{try{if(p(!0),!a)return;let e=await (0,x.t$)(a,s);u(e)}catch(e){I.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{p(!1)}};(0,i.useEffect)(()=>{L()},[s,a]);let F=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.vh)(a,s,l),I.ZP.success("Organization member added successfully"),v(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to add organization member"),console.error("Error adding organization member:",e)}},R=async e=>{try{if(!a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.LY)(a,s,l),I.ZP.success("Organization member updated successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,x.Sb)(a,s,e.user_id),I.ZP.success("Organization member deleted successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to delete organization member"),console.error("Error deleting organization member:",e)}},U=async e=>{try{if(!a)return;let l={organization_id:s,organization_alias:e.organization_alias,models:e.models,litellm_budget_table:{tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration}};if(!(await fetch("/organization/update",{method:"POST",headers:{Authorization:"Bearer ".concat(a),"Content-Type":"application/json"},body:JSON.stringify(l)})).ok)throw Error("Failed to update organization");I.ZP.success("Organization settings updated successfully"),_(!1),L()}catch(e){I.ZP.error("Failed to update organization settings"),console.error("Error updating organization:",e)}};return h?(0,r.jsx)("div",{className:"p-4",children:"Loading..."}):m?(0,r.jsxs)("div",{className:"w-full h-screen p-4 bg-white",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:m.organization_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===m.litellm_budget_table.max_budget?"Unlimited":"$".concat(m.litellm_budget_table.max_budget)]}),m.litellm_budget_table.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[75vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Created At"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)($.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{T({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),C(!0)}}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(f.Z,{onClick:()=>{v(!0)},children:"Add Member"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Organization Settings"}),D&&!Z&&(0,r.jsx)(f.Z,{onClick:()=>_(!0),children:"Edit Settings"})]}),Z?(0,r.jsxs)(k.Z,{form:j,onFinish:U,initialValues:{organization_alias:m.organization_alias,models:m.models,tpm_limit:m.litellm_budget_table.tpm_limit,rpm_limit:m.litellm_budget_table.rpm_limit,max_budget:m.litellm_budget_table.max_budget,budget_duration:m.litellm_budget_table.budget_duration},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>_(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization ID"}),(0,r.jsx)("div",{className:"font-mono",children:m.organization_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(m.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==m.litellm_budget_table.max_budget?"$".concat(m.litellm_budget_table.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",m.litellm_budget_table.budget_duration||"Never"]})]})]})]})})]})]}),(0,r.jsx)(eX,{isVisible:y,onCancel:()=>v(!1),onSubmit:F,accessToken:a,title:"Add Organization Member",roles:[{label:"org_admin",value:"org_admin",description:"Can add and remove members, and change their roles."},{label:"internal_user",value:"internal_user",description:"Can view/create keys for themselves within organization."},{label:"internal_user_viewer",value:"internal_user_viewer",description:"Can only view their keys within organization."}],defaultRole:"internal_user"}),(0,r.jsx)(eY,{visible:N,onCancel:()=>C(!1),onSubmit:R,initialData:A,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Org Admin",value:"org_admin"},{label:"Internal User",value:"internal_user"},{label:"Internal User Viewer",value:"internal_user_viewer"}]}})]}):(0,r.jsx)("div",{className:"p-4",children:"Organization not found"})};let l_=async(e,l)=>{l(await (0,x.r6)(e))};var ly=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:n,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,p]=(0,i.useState)(null),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(!1),[N,A]=(0,i.useState)(null),[E,O]=(0,i.useState)(!1),[T]=k.Z.useForm();(0,i.useEffect)(()=>{0===l.length&&a&&l_(a,m)},[l,a]);let D=e=>{e&&(A(e),w(!0))},L=async()=>{if(N&&a)try{await (0,x.cq)(a,N),I.ZP.success("Organization deleted successfully"),w(!1),A(null),l_(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,x.H1)(a,e),O(!1),T.resetFields(),l_(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(lZ,{organizationId:h,onClose:()=>{p(null),y(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:_}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsx)("div",{className:"flex",children:(0,r.jsx)(ei.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[n&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",n]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:o})]})]}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(b.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Organization ID"}),(0,r.jsx)(Q.Z,{children:"Organization Name"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(Q.Z,{children:"Info"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>{var l,t,a,i,n,o,d,c,m;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>p(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{children:e.organization_alias}),(0,r.jsx)($.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{children:e.spend}),(0,r.jsx)($.Z,{children:(null===(t=e.litellm_budget_table)||void 0===t?void 0:t.max_budget)!==null&&(null===(a=e.litellm_budget_table)||void 0===a?void 0:a.max_budget)!==void 0?null===(i=e.litellm_budget_table)||void 0===i?void 0:i.max_budget:"No limit"}),(0,r.jsx)($.Z,{children:Array.isArray(e.models)&&(0,r.jsx)("div",{className:"flex flex-col",children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)},l))})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["TPM: ",(null===(n=e.litellm_budget_table)||void 0===n?void 0:n.tpm_limit)?null===(o=e.litellm_budget_table)||void 0===o?void 0:o.tpm_limit:"Unlimited",(0,r.jsx)("br",{}),"RPM: ",(null===(d=e.litellm_budget_table)||void 0===d?void 0:d.rpm_limit)?null===(c=e.litellm_budget_table)||void 0===c?void 0:c.rpm_limit:"Unlimited"]})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)($.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{p(e.organization_id),y(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>D(e.organization_id),icon:eh.Z,size:"sm"})]})})]},e.organization_id)}):null})]})})}),("Admin"===s||"Org Admin"===s)&&(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>O(!0),children:"+ Create New Organization"}),(0,r.jsx)(C.Z,{title:"Create Organization",visible:E,width:800,footer:null,onCancel:()=>{O(!1),T.resetFields()},children:(0,r.jsxs)(k.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(f.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),v?(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Organization"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this organization?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{w(!1),A(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(b.Z,{children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,r.jsx)("a",{href:"https://litellm.ai/pricing",target:"_blank",rel:"noopener noreferrer",children:"here"}),"."]})})};let lv=()=>{let[e,l]=(0,i.useState)("http://localhost:4000");return(0,i.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lb=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=k.Z.useForm(),[d]=k.Z.useForm(),{Title:c,Paragraph:m}=eS.default,[u,h]=(0,i.useState)(""),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(!1),[w,N]=(0,i.useState)(!1),[S,A]=(0,i.useState)(!1),[P,T]=(0,i.useState)(!1),[M,D]=(0,i.useState)(!1),[L,F]=(0,i.useState)(!1),[R,z]=(0,i.useState)(!1),[U,V]=(0,i.useState)(!1),[q,B]=(0,i.useState)(!1),[K,W]=(0,i.useState)([]),[H,G]=(0,i.useState)(null);(0,n.useRouter)();let[el,es]=(0,i.useState)(null);console.log=function(){};let et=lv(),ea="All IP Addresses Allowed",ei=et;ei+="/fallback/login";let en=async()=>{try{if(!0!==a){I.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,x.PT)(s);W(e&&e.length>0?e:[ea])}else W([ea])}catch(e){console.error("Error fetching allowed IPs:",e),I.ZP.error("Failed to fetch allowed IPs ".concat(e)),W([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,x.eH)(s,e.ip);let l=await (0,x.PT)(s);W(l),I.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),I.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{G(e),B(!0)},ec=async()=>{if(H&&s)try{await (0,x.$I)(s,H);let e=await (0,x.PT)(s);W(e.length>0?e:[ea]),I.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),I.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),G(null)}},em=()=>{F(!1)};(0,i.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,x.Xd)(s,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let t=l.users;console.log("proxy viewers response: ".concat(t)),t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(t));let a=(await (0,x.Xd)(s,"proxy_admin")).users;a.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(a)),console.log("combinedList: ".concat(e)),j(e),es(await (0,x.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=p){var l;I.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,x.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,x.XO)(s,a).then(e=>{_(e),v(!0)}),console.log("response for team create call: ".concat(t));let r=p.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===t.user_id));console.log("foundIndex: ".concat(r)),-1==r&&(console.log("updates admin with new user"),p.push(t),j(p)),o.resetFields(),A(!1)}}catch(e){console.error("Error creating the key:",e)}},eh=async e=>{if(null==s)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,x.K_)(s,l)};return console.log("admins: ".concat(null==p?void 0:p.length)),(0,r.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,r.jsx)(c,{level:4,children:"Admin Access "}),(0,r.jsx)(m,{children:"Go to 'Internal Users' page to add other admins."}),(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(c,{level:4,children:" ✨ Security Settings"}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:()=>!0===a?D(!0):I.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:en,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(C.Z,{title:"Add SSO",visible:M,width:800,footer:null,onOk:()=>{D(!1),o.resetFields()},onCancel:()=>{D(!1),o.resetFields()},children:(0,r.jsxs)(k.Z,{form:o,onFinish:e=>{eu(e),eh(e),D(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,r.jsx)(E.Z.Password,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,r.jsx)(E.Z.Password,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(C.Z,{title:"SSO Setup Instructions",visible:L,width:800,footer:null,onOk:em,onCancel:()=>{F(!1)},children:[(0,r.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(C.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(f.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"IP Address"}),(0,r.jsx)(Q.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(J.Z,{children:K.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e}),(0,r.jsx)($.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(f.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(C.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(k.Z,{onFinish:eo,children:[(0,r.jsx)(k.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,r.jsx)(E.Z,{placeholder:"Enter IP address"})}),(0,r.jsx)(k.Z.Item,{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(C.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(f.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",H,"?"]})})]}),(0,r.jsxs)(eW.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:ei,target:"_blank",children:[(0,r.jsx)("b",{children:ei})," "]})]})]})]})},lw=s(92858),lN=s(44643),lS=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:i}=e,[n]=k.Z.useForm();return(0,r.jsxs)(k.Z,{form:n,onFinish:()=>{console.log("INSIDE ONFINISH");let e=n.getFieldsValue(),l=Object.entries(e).every(e=>{let[l,s]=e;return"boolean"!=typeof s&&(""===s||null==s)});console.log("formData: ".concat(JSON.stringify(e),", isEmpty: ").concat(l)),l?console.log("Some form fields are empty."):a(e)},labelAlign:"left",children:[l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{align:"center",children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?i?(0,r.jsx)(k.Z.Item,{name:e.field_name,children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lw.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,r.jsx)(k.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lw.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),n.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lN.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lk=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(0,x.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lS,{alertingSettings:t,handleInputChange:(e,l)=>{let s=t.map(s=>s.field_name===e?{...s,field_value:l}:s);console.log("updatedSettings: ".concat(JSON.stringify(s))),a(s)},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);a(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||(console.log("formValues: ".concat(e)),null==e||void 0==e))return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let a={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(a)));let{slack_alerting:r,...i}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(i)));try{(0,x.jA)(l,"alerting_args",i),"boolean"==typeof r&&(!0==r?(0,x.jA)(l,"alerting",["slack"]):(0,x.jA)(l,"alerting",[])),I.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lI=s(86582);let{Title:lC,Paragraph:lA}=eS.default;console.log=function(){};var lP=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[n,o]=(0,i.useState)([]),[d,c]=(0,i.useState)([]),[m,u]=(0,i.useState)(!1),[h]=k.Z.useForm(),[p,j]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,w]=(0,i.useState)(""),[N,A]=(0,i.useState)({}),[P,E]=(0,i.useState)([]),[T,M]=(0,i.useState)(!1),[D,L]=(0,i.useState)([]),[F,R]=(0,i.useState)(null),[z,U]=(0,i.useState)([]),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),W=e=>{P.includes(e)?E(P.filter(l=>l!==e)):E([...P,e])},H={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,i.useEffect)(()=>{l&&s&&t&&(0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),L(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),E(e.active_alerts),w(s),A(e.alerts_to_webhook)}c(l)})},[l,s,t]);let G=e=>P&&P.includes(e),el=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));a&&a.value&&(e[s]=null==a?void 0:a.value)})}),console.log("updatedVariables",e);try{(0,x.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Email settings updated successfully")},es=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,x.K_)(l,{environment_variables:s}),I.ZP.success("Callback added successfully"),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},ea=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,x.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),I.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),j(e.litellm_callback_name),console.log("all callbacks",D),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(n)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(lC,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(g.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)(Q.Z,{children:"Callback Name"})})}),(0,r.jsx)(J.Z,{children:n.map((e,s)=>(0,r.jsxs)(ee.Z,{className:"flex justify-between",children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.name})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>M(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(b.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,r.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(H).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lw.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)}):(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,r.jsx)(lw.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:N&&N[s]?N[s]:v})})]},l)})})]}),(0,r.jsx)(f.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(H).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let r=(null==a?void 0:a.value)||"";console.log("newWebhookValue",r),e[s]=r}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:P}};console.log("payload",s);try{(0,x.K_)(l,s)}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lk,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(lC,{level:4,children:"Email Settings"}),(0,r.jsxs)(b.Z,{children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,r.jsx)("br",{})]}),(0,r.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,r.jsx)($.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(g.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,r.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,r.jsxs)("div",{children:[(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,r.jsxs)(b.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-2",children:l}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,r.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,r.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(C.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>M(!1),footer:null,children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,r.jsx)(k.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lI.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(S.default,{onChange:e=>{let l=D[e];l&&(console.log(l.ui_callback_name),em(l))},children:D&&Object.values(D).map(e=>(0,r.jsx)(et.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),z&&z.map(e=>(0,r.jsx)(lI.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,r.jsx)(Z.Z,{type:"password"})},e)),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(C.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(k.Z,{form:h,onFinish:es,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(r.Fragment,{children:B&&B.variables&&Object.entries(B.variables).map(e=>{let[l,s]=e;return(0,r.jsx)(lI.Z,{label:l,name:l,children:(0,r.jsx)(Z.Z,{type:"password",defaultValue:s})},l)})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lE=s(92414),lO=s(46030);let{Option:lT}=S.default;var lM=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(C.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),n.resetFields()},onCancel:()=>{d(!1),n.resetFields()},children:(0,r.jsxs)(k.Z,{form:n,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,i=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:i};console.log(o);try{(0,x.K_)(s,{router_settings:o}),a(o)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully"),d(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,r.jsx)(es.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,r.jsx)(k.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lE.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lO.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lD=s(33619);async function lL(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lD.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});I.ZP.success((0,r.jsxs)("span",{children:["Test model=",(0,r.jsx)("strong",{children:e}),", received model=",(0,r.jsx)("strong",{children:l.model}),". See"," ",(0,r.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lF={ttl:3600,lowest_latency_buffer:0},lR=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,r.jsxs)(_.Z,{children:[(0,r.jsx)(v.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,r.jsx)(y.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(b.Z,{children:"No specific settings"})})]})};var lz=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)({}),[d,c]=(0,i.useState)({}),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[_]=k.Z.useForm(),[y,v]=(0,i.useState)(null),[N,S]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,i.useEffect)(()=>{l&&s&&t&&((0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e);let l=e.router_settings;"model_group_retry_policy"in l&&delete l.model_group_retry_policy,o(l)}),(0,x.YU)(l).then(e=>{u(e)}))},[l,s,t]);let O=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(n.fallbacks));let s=n.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...n,fallbacks:s};try{await (0,x.K_)(l,{router_settings:t}),o(t),I.ZP.success("Router settings updated successfully")}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}},T=(e,l)=>{u(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},M=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,x.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,x.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(s)}catch(e){}},L=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,x.K_)(l,{router_settings:s})}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(w.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(n).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,r.jsx)($.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:S,children:[(0,r.jsx)(et.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,r.jsx)(et.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,r.jsx)(et.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,r.jsx)(lR,{selectedStrategy:N,strategyArgs:n&&n.routing_strategy_args&&Object.keys(n.routing_strategy_args).length>0?n.routing_strategy_args:lF,paramExplanation:E})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>L(n),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Model Name"}),(0,r.jsx)(Q.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(J.Z,{children:n.fallbacks&&n.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:t}),(0,r.jsx)($.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{onClick:()=>lL(t,l),children:"Test Fallback"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lM,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:n,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"}),(0,r.jsx)(Q.Z,{children:"Status"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,r.jsx)($.Z,{children:"Integer"==e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lN.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(f.Z,{onClick:()=>M(e.field_name,l),children:"Update"}),(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lU=s(93142),lV=s(45246),lq=s(96473),lB=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,i.useState)(Object.entries(l)),n=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let i=[...t];i[e]=[l,r],a(i),null==s||s(Object.fromEntries(i))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lU.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,r.jsx)(Z.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,r.jsx)(Z.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,r.jsx)(lV.Z,{onClick:()=>n(l)})]},l)}),(0,r.jsx)(O.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lq.Z,{}),children:"Add Header"})]})};let{Option:lK}=S.default;var lW=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=k.Z.useForm(),[n,o]=(0,i.useState)(!1),[d,c]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(C.Z,{title:"Add Pass-Through Endpoint",visible:n,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(k.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,x.Vt)(l,e),s(r)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Target",name:"target",rules:[{required:!0,message:"The URL to which requests for this path should be forwarded."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Headers",name:"headers",rules:[{required:!0,message:"Key-value pairs of headers to be forwarded with the request. You can set any key value pair here and it will be forwarded to your target endpoint"}],help:"required",children:(0,r.jsx)(lB,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lH=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&s&&t&&(0,x.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,x.EG)(l,e);let s=n.filter(l=>l.path!==e);o(s),I.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Path"}),(0,r.jsx)(Q.Z,{children:"Target"}),(0,r.jsx)(Q.Z,{children:"Headers"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:n.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.path})}),(0,r.jsx)($.Z,{children:e.target}),(0,r.jsx)($.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lW,{accessToken:l,setPassThroughItems:o,passThroughItems:n})]})})}):null},lG=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[i]=k.Z.useForm(),n=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call");let l=await (0,x.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),I.ZP.success("API Key Created"),i.resetFields()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),i.resetFields()},onCancel:()=>{t(!1),i.resetFields()},children:(0,r.jsxs)(k.Z,{form:i,onFinish:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lY=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:n,handleUpdateCall:o}=e;console.log("existingBudget",n);let[d]=k.Z.useForm();(0,i.useEffect)(()=>{d.setFieldsValue(n)},[n,d]);let c=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call"),t(!0);let l=await (0,x.qI)(s,e);a(e=>e?[...e,l]:[l]),I.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(k.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:n,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},lJ=s(17906),l$=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)(!1),[a,n]=(0,i.useState)(!1),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&(0,x.O3)(l).then(e=>{m(e)})},[l]);let u=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),n(!0))},h=async(e,s)=>{if(null==l)return;I.ZP.info("Request made"),await (0,x.NV)(l,e);let t=[...c];t.splice(s,1),m(t),I.ZP.success("Budget Deleted.")},p=async()=>{null!=l&&(0,x.O3)(l).then(e=>{m(e)})};return(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsx)(f.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lG,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lY,{accessToken:l,isModalVisible:a,setIsModalVisible:n,setBudgetList:m,existingBudget:o,handleUpdateCall:p}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Budget ID"}),(0,r.jsx)(Q.Z,{children:"Max Budget"}),(0,r.jsx)(Q.Z,{children:"TPM"}),(0,r.jsx)(Q.Z,{children:"RPM"})]})}),(0,r.jsx)(J.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.budget_id}),(0,r.jsx)($.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)($.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)($.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,r.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="",\n api_key=""\n)\n\ncompletion = client.chat.completions.create(\n model="gpt-3.5-turbo",\n messages=[\n {"role": "system", "content": "You are a helpful assistant."},\n {"role": "user", "content": "Hello!"}\n ],\n user="my-customer-id"\n)\n\nprint(completion.choices[0].message)'})})]})]})]})]})},lX=s(77398),lQ=s.n(lX),l0=s(20016);async function l1(e){try{let l=await fetch("http://ip-api.com/json/".concat(e)),s=await l.json();console.log("ip lookup data",s);let t=s.countryCode?s.countryCode.toUpperCase().split("").map(e=>String.fromCodePoint(e.charCodeAt(0)+127397)).join(""):"";return s.country?"".concat(t," ").concat(s.country):"Unknown"}catch(e){return console.error("Error looking up IP:",e),"Unknown"}}let l2=e=>{let{ipAddress:l}=e,[s,t]=i.useState("-");return i.useEffect(()=>{if(!l)return;let e=!0;return l1(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},l4=e=>{try{return new Date(e).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).replace(",","")}catch(e){return"Error converting time"}},l5=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:l4(l)})},l3=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):"●"}},{header:"Time",accessorKey:"startTime",cell:e=>(0,r.jsx)(l5,{utcTime:e.getValue()})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,r.jsx)(R.Z,{title:String(e.getValue()||""),children:(0,r.jsx)("span",{className:"font-mono text-xs max-w-[100px] truncate block",children:String(e.getValue()||"")})})},{header:"Cost",accessorKey:"spend",cell:e=>(0,r.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Country",accessorKey:"requester_ip_address",cell:e=>(0,r.jsx)(l2,{ipAddress:e.getValue()})},{header:"Team Name",accessorKey:"metadata.user_api_key_team_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Key Hash",accessorKey:"metadata.user_api_key",cell:e=>{let l=String(e.getValue()||"-");return(0,r.jsx)(R.Z,{title:l,children:(0,r.jsxs)("span",{className:"font-mono",children:[l.slice(0,5),"..."]})})}},{header:"Key Name",accessorKey:"metadata.user_api_key_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Model",accessorKey:"model",cell:e=>{let l=e.row.original.custom_llm_provider,s=String(e.getValue()||"");return(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[l&&(0,r.jsx)("img",{src:eP(l).logo,alt:"",className:"w-4 h-4",onError:e=>{e.target.style.display="none"}}),(0,r.jsx)(R.Z,{title:s,children:(0,r.jsx)("span",{className:"max-w-[100px] truncate",children:s})})]})}},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,r.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,r.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"Internal User",accessorKey:"user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"End User",accessorKey:"end_user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();if(!l||0===Object.keys(l).length)return"-";let s=Object.entries(l),t=s[0],a=s.slice(1);return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:(0,r.jsx)(R.Z,{title:(0,r.jsx)("div",{className:"flex flex-col gap-1",children:s.map(e=>{let[l,s]=e;return(0,r.jsxs)("span",{children:[l,": ",String(s)]},l)})}),children:(0,r.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[t[0],": ",String(t[1]),a.length>0&&" +".concat(a.length)]})})})}}],l8=async(e,l,s,t)=>{console.log("prefetchLogDetails called with",e.length,"logs");let a=e.map(e=>{if(e.request_id)return console.log("Prefetching details for request_id:",e.request_id),t.prefetchQuery({queryKey:["logDetails",e.request_id,l],queryFn:async()=>{console.log("Fetching details for",e.request_id);let t=await (0,x.qk)(s,e.request_id,l);return console.log("Received details for",e.request_id,":",t?"success":"failed"),t},staleTime:6e5,gcTime:6e5})});try{let e=await Promise.all(a);return console.log("All prefetch promises completed:",e.length),e}catch(e){throw console.error("Error in prefetchLogDetails:",e),e}};function l6(e){var l,s,t;let{accessToken:a,token:n,userRole:o,userID:d}=e,[m,u]=(0,i.useState)(""),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)(!1),[f,Z]=(0,i.useState)(1),[_]=(0,i.useState)(50),y=(0,i.useRef)(null),v=(0,i.useRef)(null),b=(0,i.useRef)(null),[w,N]=(0,i.useState)(lQ()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[S,k]=(0,i.useState)(lQ()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,i.useState)(!1),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(""),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(""),[F,R]=(0,i.useState)(""),[z,U]=(0,i.useState)("Team ID"),V=(0,c.NL)();(0,i.useEffect)(()=>{function e(e){y.current&&!y.current.contains(e.target)&&g(!1),v.current&&!v.current.contains(e.target)&&p(!1),b.current&&!b.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,l0.a)({queryKey:["logs","table",f,_,w,S,D,F],queryFn:async()=>{if(!a||!n||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:_,total_pages:0};let e=lQ()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?lQ()(S).utc().format("YYYY-MM-DD HH:mm:ss"):lQ()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,x.h3)(a,F||void 0,D||void 0,void 0,e,l,f,_);return await l8(s.data,e,a,V),s.data=s.data.map(l=>{let s=V.getQueryData(["logDetails",l.request_id,e]);return(null==s?void 0:s.messages)&&(null==s?void 0:s.response)&&(l.messages=s.messages,l.response=s.response),l}),s},enabled:!!a&&!!n&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!n||!o||!d)return console.log("got None values for one of accessToken, token, userRole, userID"),null;let B=(null===(s=q.data)||void 0===s?void 0:null===(l=s.data)||void 0===l?void 0:l.filter(e=>!m||e.request_id.includes(m)||e.model.includes(m)||e.user&&e.user.includes(m)))||[],K=()=>{if(I)return"".concat(lQ()(w).format("MMM D, h:mm A")," - ").concat(lQ()(S).format("MMM D, h:mm A"));let e=lQ()(),l=lQ()(w),s=e.diff(l,"minutes");if(s<=15)return"Last 15 Minutes";if(s<=60)return"Last Hour";let t=e.diff(l,"hours");return t<=4?"Last 4 Hours":t<=24?"Last 24 Hours":t<=168?"Last 7 Days":"".concat(l.format("MMM D")," - ").concat(e.format("MMM D"))};return(0,r.jsxs)("div",{className:"w-full p-6",children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,r.jsx)("h1",{className:"text-xl font-semibold",children:"Request Logs"})}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"border-b px-6 py-4",children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between space-y-4 md:space-y-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("div",{className:"relative w-64",children:[(0,r.jsx)("input",{type:"text",placeholder:"Search by Request ID",className:"w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:m,onChange:e=>u(e.target.value)}),(0,r.jsx)("svg",{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),(0,r.jsxs)("div",{className:"relative",ref:v,children:[(0,r.jsxs)("button",{className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",onClick:()=>p(!h),children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),"Filter"]}),h&&(0,r.jsx)("div",{className:"absolute left-0 mt-2 w-[500px] bg-white rounded-lg shadow-lg border p-4 z-50",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>g(!j),className:"px-3 py-1.5 border rounded-md bg-white text-sm min-w-[160px] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-left flex justify-between items-center",children:[z,(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),j&&(0,r.jsx)("div",{className:"absolute left-0 mt-1 w-[160px] bg-white border rounded-md shadow-lg z-50",children:["Team ID","Key Hash"].map(e=>(0,r.jsxs)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 ".concat(z===e?"bg-blue-50 text-blue-600":""),onClick:()=>{U(e),g(!1),"Team ID"===e?M(""):O("")},children:[z===e&&(0,r.jsx)("svg",{className:"h-4 w-4 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e]},e))})]}),(0,r.jsx)("input",{type:"text",placeholder:"Enter value...",className:"px-3 py-1.5 border rounded-md text-sm flex-1 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:"Team ID"===z?E:T,onChange:e=>{"Team ID"===z?O(e.target.value):M(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{O(""),M("")},children:(0,r.jsx)("span",{className:"text-gray-500",children:"\xd7"})})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50",onClick:()=>{O(""),M(""),p(!1)},children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>{L(E),R(T),Z(1),p(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsxs)("button",{onClick:()=>P(!A),className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),K()]}),A&&(0,r.jsx)("div",{className:"absolute right-0 mt-2 w-64 bg-white rounded-lg shadow-lg border p-2 z-50",children:(0,r.jsxs)("div",{className:"space-y-1",children:[[{label:"Last 15 Minutes",value:15,unit:"minutes"},{label:"Last Hour",value:1,unit:"hours"},{label:"Last 4 Hours",value:4,unit:"hours"},{label:"Last 24 Hours",value:24,unit:"hours"},{label:"Last 7 Days",value:7,unit:"days"}].map(e=>(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(K()===e.label?"bg-blue-50 text-blue-600":""),onClick:()=>{k(lQ()().format("YYYY-MM-DDTHH:mm")),N(lQ()().subtract(e.value,e.unit).format("YYYY-MM-DDTHH:mm")),P(!1),C(!1)},children:e.label},e.label)),(0,r.jsx)("div",{className:"border-t my-2"}),(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(I?"bg-blue-50 text-blue-600":""),onClick:()=>C(!I),children:"Custom Range"})]})})]}),(0,r.jsxs)("button",{onClick:()=>{q.refetch()},className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",title:"Refresh data",children:[(0,r.jsx)("svg",{className:"w-4 h-4 ".concat(q.isFetching?"animate-spin":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,r.jsx)("span",{children:"Refresh"})]})]}),I&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:w,onChange:e=>{N(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})}),(0,r.jsx)("span",{className:"text-gray-500",children:"to"}),(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:S,onChange:e=>{k(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Showing"," ",q.isLoading?"...":q.data?(f-1)*_+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*_,q.data.total):0," ","of"," ",q.isLoading?"...":q.data?q.data.total:0," ","results"]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",q.isLoading?"...":f," of"," ",q.isLoading?"...":q.data?q.data.total_pages:1]}),(0,r.jsx)("button",{onClick:()=>Z(e=>Math.max(1,e-1)),disabled:q.isLoading||1===f,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>Z(e=>{var l;return Math.min((null===(l=q.data)||void 0===l?void 0:l.total_pages)||1,e+1)}),disabled:q.isLoading||f===((null===(t=q.data)||void 0===t?void 0:t.total_pages)||1),className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]})}),(0,r.jsx)(el,{columns:l3,data:B,renderSubComponent:l7,getRowCanExpand:()=>!0})]})]})}function l7(e){var l,s;let{row:t}=e,a=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,r.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium ",children:"Request Details"})}),(0,r.jsxs)("div",{className:"space-y-2 p-4 ",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request ID:"}),(0,r.jsx)("span",{children:t.original.request_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Key:"}),(0,r.jsx)("span",{children:t.original.api_key})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Team ID:"}),(0,r.jsx)("span",{children:t.original.team_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Model:"}),(0,r.jsx)("span",{children:t.original.model})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Base:"}),(0,r.jsx)("span",{children:t.original.api_base})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Call Type:"}),(0,r.jsx)("span",{children:t.original.call_type})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Spend:"}),(0,r.jsx)("span",{children:t.original.spend})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Total Tokens:"}),(0,r.jsx)("span",{children:t.original.total_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Prompt Tokens:"}),(0,r.jsx)("span",{children:t.original.prompt_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Completion Tokens:"}),(0,r.jsx)("span",{children:t.original.completion_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Start Time:"}),(0,r.jsx)("span",{children:t.original.startTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"End Time:"}),(0,r.jsx)("span",{children:t.original.endTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Hit:"}),(0,r.jsx)("span",{children:t.original.cache_hit})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Key:"}),(0,r.jsx)("span",{children:t.original.cache_key})]}),(null==t?void 0:null===(l=t.original)||void 0===l?void 0:l.requester_ip_address)&&(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request IP Address:"}),(0,r.jsx)("span",{children:null==t?void 0:null===(s=t.original)||void 0===s?void 0:s.requester_ip_address})]})]})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request Tags"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.request_tags),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.messages),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,r.jsx)("div",{})]}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.response),null,2)})]}),t.original.metadata&&Object.keys(t.original.metadata).length>0&&(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm ",children:JSON.stringify(t.original.metadata,null,2)})]})]})}var l9=s(92699),se=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,r.jsx)(b.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(ei.Z,{children:"LlamaIndex"}),(0,r.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="'.concat(s,'", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="').concat(s,'",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="'.concat(s,'",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})})},sl=s(243),ss=s(94263);async function st(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lD.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await r.chat.completions.create({model:s,stream:!0,messages:e})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content,t.model)}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var sa=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:n}=e,[o,d]=(0,i.useState)(n?"custom":"session"),[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[p,_]=(0,i.useState)([]),[y,v]=(0,i.useState)(void 0),[w,N]=(0,i.useState)([]),k=(0,i.useRef)(null);(0,i.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,x.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),v(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,i.useEffect)(()=>{k.current&&setTimeout(()=>{var e;null===(e=k.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[p]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===u.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){I.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},i=[...p.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];_([...p,r]);try{y&&await st(i,(e,l)=>C("assistant",e,l),y,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,r.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(ei.Z,{children:"Chat"})}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"API Key Source"}),(0,r.jsx)(S.default,{disabled:n,defaultValue:"session",style:{width:"100%"},onChange:e=>d(e),options:[{value:"session",label:"Current UI Session"},{value:"custom",label:"Virtual Key"}]}),"custom"===o&&(0,r.jsx)(Z.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:m,value:c})]}),(0,r.jsxs)(j.Z,{className:"mx-2",children:[(0,r.jsx)(b.Z,{children:"Select Model:"}),(0,r.jsx)(S.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),v(e)},options:w,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(f.Z,{onClick:()=>{_([]),I.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(Y.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{})})}),(0,r.jsxs)(J.Z,{children:[p.map((e,l)=>(0,r.jsx)(ee.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,r.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,r.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,r.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,r.jsx)(sl.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...i}=e,n=/language-(\w+)/.exec(t||"");return!s&&n?(0,r.jsx)(lJ.Z,{style:ss.Z,language:n[1],PreTag:"div",...i,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...i,children:a})}},children:e.content})})]})},l)),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{ref:k,style:{height:"1px"}})})})]})]}),(0,r.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,r.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,r.jsx)(Z.Z,{type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,r.jsx)(f.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},sr=s(19226),si=s(45937),sn=s(92403),so=s(28595),sd=s(68208),sc=s(9775),sm=s(41361),su=s(37527),sh=s(15883),sx=s(12660),sp=s(88009),sj=s(48231),sg=s(41169),sf=s(44625),sZ=s(57400),s_=s(55322);let{Sider:sy}=sr.default,sv=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],sb=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(sn.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(so.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(sd.Z,{}),roles:sv},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(sc.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(sm.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(su.Z,{}),roles:sv},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(sh.Z,{}),roles:sv},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(sx.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sp.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sj.Z,{}),roles:sv},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sg.Z,{}),roles:sv,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(sf.Z,{}),roles:sv},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(su.Z,{}),roles:sv},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(sZ.Z,{}),roles:sv}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(s_.Z,{}),roles:sv,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(s_.Z,{}),roles:sv},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(sx.Z,{}),roles:sv},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(s_.Z,{}),roles:sv},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(s_.Z,{}),roles:sv}]}];var sw=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=sb.find(l=>l.page===e);if(l)return l.key;for(let l of sb)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),i=sb.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(sr.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sy,{theme:"light",width:220,children:(0,r.jsx)(si.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:i.map(e=>{var s;return{key:e.key,icon:e.icon,label:e.label,children:null===(s=e.children)||void 0===s?void 0:s.map(e=>({key:e.key,icon:e.icon,label:e.label,onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}})),onClick:e.children?void 0:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}}})})})})},sN=s(96889);console.log=function(){};var sS=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:n,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,i.useState)(null!==a?a:0),[m,u]=(0,i.useState)(o?o.max_budget:null);(0,i.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(n);else{let e=!1;if(o.team_memberships)for(let s of o.team_memberships)s.user_id===l&&"max_budget"in s.litellm_budget_table&&null!==s.litellm_budget_table.max_budget&&(u(s.litellm_budget_table.max_budget),e=!0);e||u(o.max_budget)}}},[o,n]);let[h,p]=(0,i.useState)([]);(0,i.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,x.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,i.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",h),j=h):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=h);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,r.jsx)("div",{className:"flex items-center",children:(0,r.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,r.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})},sk=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sI=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sC=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:n,premiumUser:o}=e,d=new Date,[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)([]),[v,N]=(0,i.useState)([]),[S,k]=(0,i.useState)([]),[I,C]=(0,i.useState)([]),[A,P]=(0,i.useState)([]),[E,O]=(0,i.useState)([]),[T,M]=(0,i.useState)([]),[D,L]=(0,i.useState)({}),[F,R]=(0,i.useState)([]),[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(["all-tags"]),[B,K]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(0),ea=new Date(d.getFullYear(),d.getMonth(),1),em=new Date(d.getFullYear(),d.getMonth()+1,0),eu=ef(ea),eh=ef(em);function ex(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",n),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,x.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,i.useEffect)(()=>{eg(B.from,B.to)},[B,V]);let ej=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let a=await (0,x.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),y(a)},eg=async(e,s)=>{if(!e||!s||!l)return;let t=await ep();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),k((await (0,x.J$)(l,e.toISOString(),s.toISOString(),0===V.length?void 0:V)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ef(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}console.log("Start date is ".concat(eu)),console.log("End date is ".concat(eh));let eZ=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},e_=(e,l,s,t)=>{let a=[],r=new Date(l),i=e=>{if(e.includes("-"))return e;{let[l,s]=e.split(" ");return new Date(new Date().getFullYear(),new Date("".concat(l," 01 2024")).getMonth(),parseInt(s)).toISOString().split("T")[0]}},n=new Map(e.map(e=>{let l=i(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(n.has(e))a.push(n.get(e));else{let l={date:e,api_requests:0,total_tokens:0};t.forEach(e=>{l[e]||(l[e]=0)}),a.push(l)}r.setDate(r.getDate()+1)}return a},ey=async()=>{if(l)try{let e=await (0,x.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e,t,a,[]),i=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(i),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},ev=()=>eZ(()=>l&&s?(0,x.OU)(l,s,eu,eh):Promise.reject("No access token or token"),M,"Error fetching provider spend"),eb=async()=>{l&&await eZ(async()=>(await (0,x.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:Number(e.total_spend.toFixed(2))})),h,"Error fetching top keys")},ew=async()=>{l&&await eZ(async()=>(await (0,x.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),Z,"Error fetching top models")},eN=async()=>{l&&await eZ(async()=>{let e=await (0,x.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return N(e_(e.daily_spend,t,a,e.teams)),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:Number(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eS=()=>{l&&eZ(async()=>(await (0,x.X)(l)).tag_names,C,"Error fetching tag names")},ek=()=>{l&&eZ(()=>{var e,s;return(0,x.J$)(l,null===(e=B.from)||void 0===e?void 0:e.toISOString(),null===(s=B.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>k(e.spend_per_tag),"Error fetching top tags")},eC=()=>{l&&eZ(()=>(0,x.b1)(l,null,void 0,void 0),y,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,x.wd)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e.daily_data||[],t,a,["api_requests","total_tokens"]);L({...e,daily_data:r})}catch(e){console.error("Error fetching global activity:",e)}},eP=async()=>{if(l)try{let e=await (0,x.xA)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e.map(e=>({...e,daily_data:e_(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,i.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(H(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",W),ey(),ev(),eb(),ew(),eA(),eP(),sI(t)&&(eN(),eS(),ek(),eC()))}})()},[l,s,t,a,eu,eh]),null==W?void 0:W.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(b.Z,{className:"mt-4",children:["SpendLogs in DB has ",W.NUM_SPEND_LOGS_ROWS," rows.",(0,r.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,r.jsx)(f.Z,{className:"mt-4",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(ei.Z,{children:"All Up"}),sI(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ei.Z,{children:"Team Based Usage"}),(0,r.jsx)(ei.Z,{children:"Customer Usage"}),(0,r.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{})})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(ei.Z,{children:"Cost"}),(0,r.jsx)(ei.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(b.Z,{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content mb-2 mt-2 text-lg",children:["Project Spend ",new Date().toLocaleString("default",{month:"long"})," 1 - ",new Date(new Date().getFullYear(),new Date().getMonth()+1,0).getDate()]}),(0,r.jsx)(sS,{userID:a,userRole:t,accessToken:l,userSpend:G,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Monthly Spend"}),(0,r.jsx)(eU.Z,{data:c,index:"date",categories:["spend"],colors:["cyan"],valueFormatter:e=>"$ ".concat(e.toFixed(2)),yAxisWidth:100,tickGap:5})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top API Keys"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:u,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top Models"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:p,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sk.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend",colors:["cyan"],valueFormatter:e=>"$".concat(e.toFixed(2))})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Provider"}),(0,r.jsx)(Q.Z,{children:"Spend"})]})}),(0,r.jsx)(J.Z,{children:T.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.provider}),(0,r.jsx)($.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})})]})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"All Up"}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(D.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(D.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),(0,r.jsx)(r.Fragment,{children:F.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.model}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ex,onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ex,onValueChange:e=>console.log(e)})]})]})]},l))})]})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sN.Z,{data:E})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eU.Z,{className:"h-72",data:v,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,r.jsx)(j.Z,{numColSpan:2})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{ej(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==n?void 0:n.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{ej(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(Y.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Customer"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Total Events"})]})}),(0,r.jsx)(J.Z,{children:null==_?void 0:_.map((e,l)=>{var s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.end_user}),(0,r.jsx)($.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)($.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eF.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lE.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lO.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsx)(lO.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lE.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lO.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsxs)(et.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(b.Z,{children:["Get Started Tracking cost per tag ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,r.jsx)(eU.Z,{className:"h-72",data:S,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sA=e=>{if(e)return e.toISOString().split("T")[0]};function sP(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var sE=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:n}=e,[o,d]=(0,i.useState)([]),[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)("0"),[v,w]=(0,i.useState)("0"),[N,S]=(0,i.useState)("0"),[k,C]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,i.useState)(""),[E,O]=(0,i.useState)("");(0,i.useEffect)(()=>{l&&k&&((async()=>{Z(await (0,x.zg)(l,sA(k.from),sA(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),M=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let D=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,x.zg)(l,sA(e),sA(s))))};(0,i.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",p);let e=p;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),u.length>0&&(e=e.filter(e=>u.includes(e.model))),console.log("before processed data in cache dashboard",e);let l=0,s=0,t=0,a=e.reduce((e,a)=>{console.log("Processing item:",a),a.call_type||(console.log("Item has no call_type:",a),a.call_type="Unknown"),l+=(a.total_rows||0)-(a.cache_hit_true_rows||0),s+=a.cache_hit_true_rows||0,t+=a.cached_completion_tokens||0;let r=e.find(e=>e.name===a.call_type);return r?(r["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),r["Cache hit"]+=a.cache_hit_true_rows||0,r["Cached Completion Tokens"]+=a.cached_completion_tokens||0,r["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(sP(s)),w(sP(t));let r=s+l;r>0?S((s/r*100).toFixed(2)):S("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,p]);let L=async()=>{try{I.ZP.info("Running cache health check..."),O("");let e=await (0,x.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),O(e)}catch(e){console.error("Error running health check:",e),O("Error running health check")}};return(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-full w-full mt-2 mb-8",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Cache Analytics"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"Cache Health"})})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[A&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:()=>{P(new Date().toLocaleString())}})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(g.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lE.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lO.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lE.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:M.map(e=>(0,r.jsx)(lO.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eF.Z,{enableSelect:!0,value:k,onValueChange:e=>{C(e),D(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[N,"%"]})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:v})})]})]}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eU.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sP,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eU.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sP,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{className:"mt-4",children:[(0,r.jsx)(b.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(f.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),E&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(E,null,2)})]})})]})]})},sO=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(async()=>{try{let e=await (0,x.t3)(l);console.log("guardrails: ".concat(JSON.stringify(e))),t(e.guardrails)}catch(e){console.error("Error fetching guardrails:",e)}})()},[l]),(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsxs)(b.Z,{className:"mb-4",children:["Configured guardrails and their current status. Setup guardrails in config.yaml."," ",(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-700 underline",children:"Docs"})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Guardrail Name"}),(0,r.jsx)(Q.Z,{children:"Mode"}),(0,r.jsx)(Q.Z,{children:"Status"})]})}),(0,r.jsx)(J.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.guardrail_name}),(0,r.jsx)($.Z,{children:e.litellm_params.mode}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"inline-flex rounded-full px-2 py-1 text-xs font-medium\n ".concat(e.litellm_params.default_on?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:e.litellm_params.default_on?"Always On":"Per Request"})})]},l)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};let sT=new d.S;function sM(){let[e,l]=(0,i.useState)(""),[s,t]=(0,i.useState)(!1),[a,d]=(0,i.useState)(!1),[m,u]=(0,i.useState)(null),[j,g]=(0,i.useState)(null),[f,Z]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,b]=(0,i.useState)([]),[w,N]=(0,i.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[S,k]=(0,i.useState)(!0),I=(0,n.useSearchParams)(),[C,A]=(0,i.useState)({data:[]}),[P,E]=(0,i.useState)(null),O=I.get("userID"),T=I.get("invitation_id"),[M,D]=(0,i.useState)(()=>I.get("page")||"api-keys"),[L,F]=(0,i.useState)(null);return(0,i.useEffect)(()=>{E(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,i.useEffect)(()=>{if(!P)return;let e=(0,o.o)(P);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),F(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"org_admin":return"Org Admin";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&D("usage")}else console.log("User role not defined");e.user_email?u(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?k("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&t(e.premium_user),e.auth_header_name&&(0,x.K8)(e.auth_header_name)}},[P]),(0,i.useEffect)(()=>{L&&O&&e&&q(O,e,L,b),L&&O&&e&&p(L,O,e,null,g),L&&l_(L,y)},[L,O,e]),(0,r.jsx)(i.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sT,children:T?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(h,{userID:O,userRole:e,premiumUser:s,setProxySettings:N,proxySettings:w}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sw,{setPage:e=>{let l=new URLSearchParams(I);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),D(e)},userRole:e,defaultSelectedKey:M})}),"api-keys"==M?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):"models"==M?(0,r.jsx)(lc,{userID:O,userRole:e,token:P,keys:f,accessToken:L,modelData:C,setModelData:A,premiumUser:s,teams:j}):"llm-playground"==M?(0,r.jsx)(sa,{userID:O,userRole:e,token:P,accessToken:L,disabledPersonalKeyCreation:a}):"users"==M?(0,r.jsx)(lp,{userID:O,userRole:e,token:P,keys:f,teams:j,accessToken:L,setKeys:Z}):"teams"==M?(0,r.jsx)(lf,{teams:j,setTeams:g,searchParams:I,accessToken:L,userID:O,userRole:e,organizations:_}):"organizations"==M?(0,r.jsx)(ly,{organizations:_,setOrganizations:y,userModels:v,accessToken:L,userRole:e,premiumUser:s}):"admin-panel"==M?(0,r.jsx)(lb,{setTeams:g,searchParams:I,accessToken:L,showSSOBanner:S,premiumUser:s}):"api_ref"==M?(0,r.jsx)(se,{proxySettings:w}):"settings"==M?(0,r.jsx)(lP,{userID:O,userRole:e,accessToken:L,premiumUser:s}):"budgets"==M?(0,r.jsx)(l$,{accessToken:L}):"guardrails"==M?(0,r.jsx)(sO,{accessToken:L}):"general-settings"==M?(0,r.jsx)(lz,{userID:O,userRole:e,accessToken:L,modelData:C}):"model-hub"==M?(0,r.jsx)(l9.Z,{accessToken:L,publicPage:!1,premiumUser:s}):"caching"==M?(0,r.jsx)(sE,{userID:O,userRole:e,token:P,accessToken:L,premiumUser:s}):"pass-through-settings"==M?(0,r.jsx)(lH,{userID:O,userRole:e,accessToken:L,modelData:C}):"logs"==M?(0,r.jsx)(l6,{userID:O,userRole:e,token:P,accessToken:L}):(0,r.jsx)(sC,{userID:O,userRole:e,token:P,accessToken:L,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,812,250,699,971,117,744],function(){return e(e.s=1900)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/r-JFaQKckChAbyF6OLpws/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/r-JFaQKckChAbyF6OLpws/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/r-JFaQKckChAbyF6OLpws/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/r-JFaQKckChAbyF6OLpws/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/index.html b/litellm/proxy/_experimental/out/index.html index 8b55c7037d..3c08487efa 100644 --- a/litellm/proxy/_experimental/out/index.html +++ b/litellm/proxy/_experimental/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.txt b/litellm/proxy/_experimental/out/index.txt index bbed2c879b..7ca4e40a7b 100644 --- a/litellm/proxy/_experimental/out/index.txt +++ b/litellm/proxy/_experimental/out/index.txt @@ -1,7 +1,7 @@ 2:I[19107,[],"ClientPageRoot"] -3:I[79333,["665","static/chunks/3014691f-0b72c78cfebbd712.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-1cbed529ecb084e0.js","261","static/chunks/261-57d48f76eec1e568.js","755","static/chunks/755-8a74d7ff30e7d680.js","812","static/chunks/812-34d6bec3abb0e912.js","250","static/chunks/250-f1e2db7aa40a2982.js","699","static/chunks/699-fcda99cfef09c606.js","931","static/chunks/app/page-46aa398e93cfa70d.js"],"default",1] +3:I[15940,["665","static/chunks/3014691f-0b72c78cfebbd712.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-1cbed529ecb084e0.js","261","static/chunks/261-57d48f76eec1e568.js","755","static/chunks/755-8a74d7ff30e7d680.js","812","static/chunks/812-34d6bec3abb0e912.js","250","static/chunks/250-f1e2db7aa40a2982.js","699","static/chunks/699-fcda99cfef09c606.js","931","static/chunks/app/page-e673cacf03d84561.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["yJuobVnL1vdr5eQA0jUcl",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] +0:["r-JFaQKckChAbyF6OLpws",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/litellm/proxy/_experimental/out/model_hub.txt b/litellm/proxy/_experimental/out/model_hub.txt index a8d428dceb..c230f94244 100644 --- a/litellm/proxy/_experimental/out/model_hub.txt +++ b/litellm/proxy/_experimental/out/model_hub.txt @@ -2,6 +2,6 @@ 3:I[52829,["42","static/chunks/42-1cbed529ecb084e0.js","261","static/chunks/261-57d48f76eec1e568.js","250","static/chunks/250-f1e2db7aa40a2982.js","699","static/chunks/699-fcda99cfef09c606.js","418","static/chunks/app/model_hub/page-068a441595bd0fc3.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["yJuobVnL1vdr5eQA0jUcl",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] +0:["r-JFaQKckChAbyF6OLpws",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.html new file mode 100644 index 0000000000..dfa3a56228 --- /dev/null +++ b/litellm/proxy/_experimental/out/onboarding.html @@ -0,0 +1 @@ +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/onboarding.txt b/litellm/proxy/_experimental/out/onboarding.txt index 0d25fdf541..dd4f3a9b24 100644 --- a/litellm/proxy/_experimental/out/onboarding.txt +++ b/litellm/proxy/_experimental/out/onboarding.txt @@ -2,6 +2,6 @@ 3:I[12011,["665","static/chunks/3014691f-0b72c78cfebbd712.js","42","static/chunks/42-1cbed529ecb084e0.js","755","static/chunks/755-8a74d7ff30e7d680.js","250","static/chunks/250-f1e2db7aa40a2982.js","461","static/chunks/app/onboarding/page-0992dd0b4cd99a23.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["yJuobVnL1vdr5eQA0jUcl",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] +0:["r-JFaQKckChAbyF6OLpws",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/404.html b/ui/litellm-dashboard/out/404.html index 748a4e9b30..cc4b51c6af 100644 --- a/ui/litellm-dashboard/out/404.html +++ b/ui/litellm-dashboard/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-46aa398e93cfa70d.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-46aa398e93cfa70d.js deleted file mode 100644 index 7ddd2196aa..0000000000 --- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-46aa398e93cfa70d.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,79333))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),r=s(99376),i=s(20831),n=s(94789),o=s(12514),d=s(49804),c=s(67101),m=s(84264),u=s(26637),h=s(96761),x=s(84566),p=s(19250),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,r.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,_]=(0,a.useState)(null),[y,v]=(0,a.useState)(""),[b,w]=(0,a.useState)(""),[N,S]=(0,a.useState)(null),[k,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),S(t.user_id)})},[s]),(0,t.jsx)("div",{className:"mx-auto w-full max-w-md mt-10",children:(0,t.jsxs)(o.Z,{children:[(0,t.jsx)(h.Z,{className:"text-sm mb-5 text-center",children:"\uD83D\uDE85 LiteLLM"}),(0,t.jsx)(h.Z,{className:"text-xl",children:"Sign up"}),(0,t.jsx)(m.Z,{children:"Claim your user account to login to Admin UI."}),(0,t.jsx)(n.Z,{className:"mt-4",title:"SSO",icon:x.GH$,color:"sky",children:(0,t.jsxs)(c.Z,{numItems:2,className:"flex justify-between items-center",children:[(0,t.jsx)(d.Z,{children:"SSO is under the Enterprise Tirer."}),(0,t.jsx)(d.Z,{children:(0,t.jsx)(i.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=b,N&&s&&(0,p.m_)(Z,s,N,e.password).then(e=>{var l;let s="/ui/";s+="?userID="+((null===(l=e.data)||void 0===l?void 0:l.user_id)||e.user_id),document.cookie="token="+C,console.log("redirecting to:",s),window.location.href=s}))},children:[(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:b,defaultValue:b,className:"max-w-md"})}),(0,t.jsx)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},79333:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sD}});var t,a,r=s(57437),i=s(2265),n=s(99376),o=s(14474),d=s(90946),c=s(29827),m=s(27648),u=s(80795),h=e=>{let{userID:l,userRole:s,premiumUser:t,proxySettings:a}=e,i=(null==a?void 0:a.PROXY_LOGOUT_URL)||"",n=[{key:"1",label:(0,r.jsxs)("div",{className:"px-1 py-1",children:[(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Role: ",s]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["ID: ",l]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Premium User: ",String(t)]})]})},{key:"2",label:(0,r.jsx)("p",{className:"text-sm hover:text-gray-900",onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=i},children:"Logout"})}];return(0,r.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,r.jsx)("div",{className:"w-full",children:(0,r.jsxs)("div",{className:"flex items-center h-12 px-4",children:[(0,r.jsx)("div",{className:"flex items-center flex-shrink-0",children:(0,r.jsx)(m.default,{href:"/",className:"flex items-center",children:(0,r.jsx)("img",{src:"/get_image",alt:"LiteLLM Brand",className:"h-8 w-auto"})})}),(0,r.jsxs)("div",{className:"flex items-center space-x-5 ml-auto",children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:"Docs"}),(0,r.jsx)(u.Z,{menu:{items:n,style:{padding:"4px",marginTop:"4px"}},children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:["User",(0,r.jsx)("svg",{className:"ml-1 w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})},x=s(19250);let p=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,x.It)(e,(null==t?void 0:t.organization_id)||null,l):await (0,x.It)(e,(null==t?void 0:t.organization_id)||null),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),g=s(67101),f=s(20831),Z=s(26637),_=s(87452),y=s(88829),v=s(72208),b=s(84264),w=s(96761),N=s(29233),S=s(52787),k=s(13634),I=s(41021),C=s(51369),A=s(29967),P=s(20577),E=s(56632),O=s(73002);let T=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,x.So)(s,e,l,!0)).data.map(e=>e.id),a=[],r=[];return t.forEach(e=>{e.endsWith("/*")?a.push(e):r.push(e)}),[...a,...r]}}catch(e){console.error("Error fetching user models:",e)}},M=e=>{if(e.endsWith("/*")){let l=e.replace("/*","");return"All ".concat(l," models")}return e},D=(e,l)=>{let s=[],t=[];return console.log("teamModels",e),console.log("allModels",l),e.forEach(e=>{if(e.endsWith("/*")){let a=e.replace("/*",""),r=l.filter(e=>e.startsWith(a+"/"));t.push(...r),s.push(e)}else t.push(e)}),[...s,...t].filter((e,l,s)=>s.indexOf(e)===l)};var L=e=>{let{teams:l,value:s,onChange:t}=e;return(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",value:s,onChange:t,filterOption:(e,l)=>{var s,t,a;return!!l&&((null===(a=l.children)||void 0===a?void 0:null===(t=a[0])||void 0===t?void 0:null===(s=t.props)||void 0===s?void 0:s.children)||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==l?void 0:l.map(e=>(0,r.jsxs)(S.default.Option,{value:e.team_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.team_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.team_id,")"]})]},e.team_id))})},F=s(15424),R=s(75957);let{Option:z}=S.default,U=e=>{let l=[];if(console.log("data:",JSON.stringify(e)),e)for(let s of e)s.metadata&&s.metadata.tags&&l.push(...s.metadata.tags);let s=Array.from(new Set(l)).map(e=>({value:e,label:e}));return console.log("uniqueTags:",s),s},V=(e,l)=>D(e&&e.models.length>0?e.models.includes("all-proxy-models")?l:e.models:l,l),q=async(e,l,s,t)=>{try{if(null===e||null===l)return;if(null!==s){let a=(await (0,x.So)(s,e,l)).data.map(e=>e.id);console.log("available_model_names:",a),t(a)}}catch(e){console.error("Error fetching user models:",e)}};var B=e=>{let{userID:l,team:s,teams:t,userRole:a,accessToken:n,data:o,setData:d}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[T,D]=(0,i.useState)(null),[B,K]=(0,i.useState)([]),[W,H]=(0,i.useState)([]),[G,Y]=(0,i.useState)("you"),[J,$]=(0,i.useState)(U(o)),[X,Q]=(0,i.useState)([]),[ee,el]=(0,i.useState)(s),es=()=>{u(!1),c.resetFields()},et=()=>{u(!1),p(null),c.resetFields()};(0,i.useEffect)(()=>{l&&a&&n&&q(l,a,n,K)},[n,l,a]),(0,i.useEffect)(()=>{(async()=>{try{let e=(await (0,x.t3)(n)).guardrails.map(e=>e.guardrail_name);Q(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[n]);let ea=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",i=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===i).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(i,", please provide another key alias"));if(I.ZP.info("Making API Call"),u(!0),"you"===G&&(e.user_id=l),"service_account"===G){let l={};try{l=JSON.parse(e.metadata||"{}")}catch(e){console.error("Error parsing metadata:",e)}l.service_account_id=e.key_alias,e.metadata=JSON.stringify(l)}let m=await (0,x.wX)(n,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),p(m.key),D(m.soft_budget),I.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),I.ZP.error("Error creating the key: ".concat(e))}};return(0,i.useEffect)(()=>{H(V(ee,B)),c.setFieldValue("models",[])},[ee,B]),(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(C.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:es,onCancel:et,children:(0,r.jsxs)(k.Z,{form:c,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(A.ZP.Group,{onChange:e=>Y(e.target.value),value:G,children:[(0,r.jsx)(A.ZP,{value:"you",children:"You"}),(0,r.jsx)(A.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(A.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==G,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===G,message:"Please input the user ID of the user you are assigning the key to"}],help:"Get User ID - Click on the 'Users' tab in the sidebar.",children:(0,r.jsx)(Z.Z,{placeholder:"User ID",onChange:e=>c.setFieldValue("user_id",e.target.value)})}),(0,r.jsx)(k.Z.Item,{label:"you"===G||"another_user"===G?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===G?"key name":"service account ID")}],help:"you"===G?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(L,{teams:t})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected team has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,r.jsx)(z,{value:"all-team-models",children:"All Team Models"},"all-team-models"),W.map(e=>(0,r.jsx)(z,{value:e,children:M(e)},e))]})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:X.map(e=>({value:e,label:e}))})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)(k.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:J})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(C.Z,{visible:m,onOk:es,onCancel:et,footer:null,children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Save your Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:null!=h?(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:h})}),(0,r.jsx)(N.CopyToClipboard,{text:h,onCopy:()=>{I.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(b.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,n]=(0,i.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,i.useState)(!0),[c,m]=(0,i.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!t){console.log("accessToken",t);return}d(!0);let a=await (0,x.OD)(t,(null==s?void 0:s.organization_id)||null,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),n(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,i.useEffect)(()=>{u(),console.log("selectedTeam",l,"currentOrg",s,"accessToken",t)},[l,s,t]),{keys:r.keys,isLoading:o,error:c,pagination:{currentPage:r.current_page,totalPages:r.total_pages,totalCount:r.total_count},refresh:u}},H=s(71594),G=s(24525),Y=s(21626),J=s(97214),$=s(28241),X=s(58834),Q=s(69552),ee=s(71876);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:n=!1}=e,o=(0,H.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,G.sC)(),getExpandedRowModel:(0,G.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(Y.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(X.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)(ee.Z,{children:e.headers.map(e=>(0,r.jsx)(Q.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,H.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(J.Z,{children:n?(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"\uD83D\uDE85 Loading logs..."})})})}):o.getRowModel().rows.length>0?o.getRowModel().rows.map(e=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)(ee.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)($.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,H.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"No logs found"})})})})})]})})}var es=s(27281),et=s(57365),ea=s(41649),er=s(12514),ei=s(12485),en=s(18135),eo=s(35242),ed=s(29706),ec=s(77991),em=s(10900),eu=s(23628),eh=s(74998);function ex(e){var l,s;let{keyData:t,onCancel:a,onSubmit:n,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=k.Z.useForm(),[h,p]=(0,i.useState)([]),j=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,i.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,x.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let g={...t,budget_duration:(s=t.budget_duration)&&({"24h":"daily","7d":"weekly","30d":"monthly"})[s]||null,metadata:t.metadata?JSON.stringify(t.metadata,null,2):"",guardrails:(null===(l=t.metadata)||void 0===l?void 0:l.guardrails)||[]};return(0,r.jsxs)(k.Z,{form:u,onFinish:n,initialValues:g,layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[j.length>0&&(0,r.jsx)(S.default.Option,{value:"all-team-models",children:"All Team Models"}),j.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(S.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(S.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(k.Z.Item,{name:"token",hidden:!0,children:(0,r.jsx)(E.Z,{})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(f.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,_]=(0,i.useState)(!1);(0,i.useEffect)(()=>{s&&l&&n.setFieldsValue({key_alias:l.key_alias,max_budget:l.max_budget,tpm_limit:l.tpm_limit,rpm_limit:l.rpm_limit,duration:l.duration||""})},[s,l,n]),(0,i.useEffect)(()=>{s||(d(null),_(!1),n.resetFields())},[s,n]),(0,i.useEffect)(()=>{(null==c?void 0:c.duration)?h((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString()}catch(e){return null}})(c.duration)):h(null)},[null==c?void 0:c.duration]);let y=async()=>{if(l&&a){_(!0);try{let e=await n.validateFields(),s=await (0,x.s0)(a,l.token,e);d(s.key),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key"),_(!1)}}},v=()=>{d(null),_(!1),n.resetFields(),t()};return(0,r.jsx)(C.Z,{title:"Regenerate API Key",open:s,onCancel:v,footer:o?[(0,r.jsx)(f.Z,{onClick:v,children:"Close"},"close")]:[(0,r.jsx)(f.Z,{onClick:v,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:y,disabled:p,children:p?"Regenerating...":"Regenerate"},"regenerate")],children:o?(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:(null==l?void 0:l.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:o})}),(0,r.jsx)(N.CopyToClipboard,{text:o,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(k.Z,{form:n,layout:"vertical",onValuesChange:e=>{"duration"in e&&m(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==l?void 0:l.expires)?new Date(l.expires).toLocaleString():"Never"]}),u&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",u]})]})})}function ej(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:n,userRole:o,teams:d}=e,[c,m]=(0,i.useState)(!1),[u]=k.Z.useForm(),[h,p]=(0,i.useState)(!1),[j,Z]=(0,i.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(b.Z,{children:"Key not found"})]});let _=async e=>{try{var l,s;if(!a)return;let t=e.token;if(e.key=t,e.metadata&&"string"==typeof e.metadata)try{let s=JSON.parse(e.metadata);e.metadata={...s,...(null===(l=e.guardrails)||void 0===l?void 0:l.length)>0?{guardrails:e.guardrails}:{}}}catch(e){console.error("Error parsing metadata JSON:",e),I.ZP.error("Invalid metadata JSON");return}else e.metadata={...e.metadata||{},...(null===(s=e.guardrails)||void 0===s?void 0:s.length)>0?{guardrails:e.guardrails}:{}};e.budget_duration&&(e.budget_duration=({daily:"24h",weekly:"7d",monthly:"30d"})[e.budget_duration]),await (0,x.Nc)(a,e),I.ZP.success("Key updated successfully"),m(!1)}catch(e){I.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},y=async()=>{try{if(!a)return;await (0,x.I1)(a,t.token),I.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),I.ZP.error("Failed to delete key")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(f.Z,{icon:eu.Z,variant:"secondary",onClick:()=>Z(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>p(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:j,onClose:()=>Z(!1),accessToken:a}),h&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:y,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>p(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(b.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:_,teams:d,accessToken:a,userID:n,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(b.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(b.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(b.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(b.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(b.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(b.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(b.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Metadata"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(t.metadata,null,2)})]})]})]})})]})]})]})}var eg=s(82422),ef=s(2356),eZ=s(44633),e_=s(86462),ey=s(3837),ev=e=>{var l;let{options:s,onApplyFilters:t,onResetFilters:a,initialValues:n={},buttonLabel:o="Filter"}=e,[d,c]=(0,i.useState)(!1),[m,h]=(0,i.useState)((null===(l=s[0])||void 0===l?void 0:l.name)||""),[x,p]=(0,i.useState)(n),[j,g]=(0,i.useState)(n),[f,Z]=(0,i.useState)(!1),_=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{let l=e.target;!_.current||_.current.contains(l)||l.closest(".ant-dropdown")||c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let y=e=>{g(l=>({...l,[m]:e}))},v=()=>{let e={};s.forEach(l=>{e[l.name]=""}),g(e)},b=s.map(e=>({key:e.name,label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[m===e.name&&(0,r.jsx)(eg.Z,{className:"h-4 w-4 text-blue-600"}),e.label||e.name]})}));return(0,r.jsxs)("div",{className:"relative",ref:_,children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(ef.Z,{className:"h-4 w-4"}),onClick:()=>c(!d),children:o}),d&&(0,r.jsx)(er.Z,{className:"absolute left-0 mt-2 w-96 z-50",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsx)(u.Z,{menu:{items:b,onClick:e=>{let{key:l}=e;h(l),Z(!1)}},onOpenChange:Z,open:f,trigger:["click"],children:(0,r.jsxs)(O.ZP,{className:"min-w-32 text-left flex justify-between items-center",children:[m,f?(0,r.jsx)(eZ.Z,{className:"h-4 w-4"}):(0,r.jsx)(e_.Z,{className:"h-4 w-4"})]})}),(0,r.jsx)(E.Z,{placeholder:"Enter value...",value:j[m]||"",onChange:e=>y(e.target.value),suffix:j[m]?(0,r.jsx)(ey.Z,{className:"h-4 w-4 cursor-pointer text-gray-400 hover:text-gray-500",onClick:e=>{e.stopPropagation(),y("")}}):null})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(O.ZP,{onClick:()=>{v();let e={};s.forEach(l=>{e[l.name]=""}),a(),c(!1)},children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"primary",onClick:()=>{p(j),t(j),c(!1)},children:"Apply Filters"})]})]})})]})};function eb(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:n=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h,organizations:x,setCurrentOrg:p}=e,[j,g]=(0,i.useState)(null),[Z,_]=(0,i.useState)({"Team ID":"","Organization ID":""}),y=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):null}},{header:"Key ID",accessorKey:"token",cell:e=>(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.getValue(),children:(0,r.jsx)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>g(e.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{header:"Team ID",accessorKey:"team_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Key Alias",accessorKey:"key_alias",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Organization ID",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Created",accessorKey:"created_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"-"}},{header:"Expires",accessorKey:"expires",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"Never"}},{header:"Spend (USD)",accessorKey:"spend",cell:e=>Number(e.getValue()).toFixed(4)},{header:"Budget (USD)",accessorKey:"max_budget",cell:e=>null!==e.getValue()&&void 0!==e.getValue()?e.getValue():"Unlimited"},{header:"Budget Reset",accessorKey:"budget_reset_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleString():"Never"}},{header:"Models",accessorKey:"models",cell:e=>{let l=e.getValue();return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:l&&l.length>0?l.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):"-"})}},{header:"Rate Limits",cell:e=>{let{row:l}=e,s=l.original;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{children:["TPM: ",null!==s.tpm_limit?s.tpm_limit:"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",null!==s.rpm_limit?s.rpm_limit:"Unlimited"]})]})}}];return(0,r.jsx)("div",{className:"w-full h-full overflow-hidden",children:j?(0,r.jsx)(ej,{keyId:j,onClose:()=>g(null),keyData:l.find(e=>e.token===j),accessToken:m,userID:u,userRole:h,teams:o}):(0,r.jsxs)("div",{className:"border-b py-4 flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between w-full mb-2",children:[(0,r.jsx)(ev,{options:[{name:"Team ID",label:"Team ID"},{name:"Organization ID",label:"Organization ID"}],onApplyFilters:e=>{if(_({"Team ID":e["Team ID"]||"","Organization ID":e["Organization ID"]||""}),e["Team ID"]){let l=null==o?void 0:o.find(l=>l.team_id===e["Team ID"]);l&&c(l)}if(e["Organization ID"]){let l=null==x?void 0:x.find(l=>l.organization_id===e["Organization ID"]);l&&p(l)}},initialValues:Z,onResetFilters:()=>{_({"Team ID":"","Organization ID":""}),c(null),p(null)}}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsxs)("span",{className:"inline-flex text-sm text-gray-700",children:["Showing ",s?"...":"".concat((t.currentPage-1)*n+1," - ").concat(Math.min(t.currentPage*n,t.totalCount))," of ",s?"...":t.totalCount," results"]}),(0,r.jsxs)("div",{className:"inline-flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",s?"...":t.currentPage," of ",s?"...":t.totalPages]}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage-1),disabled:s||1===t.currentPage,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage+1),disabled:s||t.currentPage===t.totalPages,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]}),(0,r.jsx)("div",{className:"h-[32rem] overflow-auto",children:(0,r.jsx)(el,{columns:y.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ew=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:n,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u,organizations:h,setCurrentOrg:p}=e,[_,y]=(0,i.useState)(!1),[v,S]=(0,i.useState)(!1),[A,E]=(0,i.useState)(null),[O,M]=(0,i.useState)(null),[D,L]=(0,i.useState)(null),[F,R]=(0,i.useState)((null==a?void 0:a.team_id)||""),[z,U]=(0,i.useState)("");(0,i.useEffect)(()=>{R((null==a?void 0:a.team_id)||"")},[a]);let{keys:V,isLoading:q,error:B,pagination:H,refresh:G}=W({selectedTeam:a,currentOrg:u,accessToken:t}),[Y,J]=(0,i.useState)(!1),[$,X]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(null),[el,es]=(0,i.useState)([]),et=new Set,[ea,er]=(0,i.useState)(!1),[ei,en]=(0,i.useState)(!1),[eo,ed]=(0,i.useState)(null),[ec,em]=(0,i.useState)(null),[eu]=k.Z.useForm(),[eh,ex]=(0,i.useState)(null),[ep,ej]=(0,i.useState)(et),[eg,ef]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",Q),(null==ec?void 0:ec.duration)?ex((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0})}catch(e){return null}})(ec.duration)):ex(null),console.log("calculateNewExpiryTime:",eh)},[Q,null==ec?void 0:ec.duration]),(0,i.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await T(l,s,t);e&&es(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,i.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ej(e)}},[c]);let eZ=async()=>{if(null!=A&&null!=o){try{await (0,x.I1)(t,A);let e=o.filter(e=>e.token!==A);d(e)}catch(e){console.error("Error deleting the key:",e)}S(!1),E(null)}},e_=(e,l)=>{em(s=>({...s,[e]:l}))},ey=async()=>{if(!m){I.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=Q)try{let e=await eu.validateFields(),l=await (0,x.s0)(t,Q.token,e);if(ed(l.key),o){let s=o.map(s=>s.token===(null==Q?void 0:Q.token)?{...s,key_name:l.key_name,...e}:s);d(s)}en(!1),eu.resetFields(),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key")}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eb,{keys:V,isLoading:q,pagination:H,onPageChange:e=>{G({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:n,accessToken:t,userID:l,userRole:s,organizations:h,setCurrentOrg:p}),v&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eZ,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{S(!1),E(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(C.Z,{title:"Regenerate API Key",visible:ei,onCancel:()=>{en(!1),eu.resetFields()},footer:[(0,r.jsx)(f.Z,{onClick:()=>{en(!1),eu.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:ey,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(k.Z,{form:eu,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&e_("duration",e.duration)},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry:"," ",(null==Q?void 0:Q.expires)!=null?new Date(Q.expires).toLocaleString():"Never"]}),eh&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eh]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),eo&&(0,r.jsx)(C.Z,{visible:!!eo,onCancel:()=>ed(null),footer:[(0,r.jsx)(f.Z,{onClick:()=>ed(null),children:"Close"},"close")],children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==Q?void 0:Q.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:eo})}),(0,r.jsx)(N.CopyToClipboard,{text:eo,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eN=s(12011),eS=s(93192);console.log=function(){},console.log("isLocal:",!1);var ek=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,premiumUser:f,organizations:Z}=e,[_,y]=(0,i.useState)(null),[v,b]=(0,i.useState)(null),w=(0,n.useSearchParams)(),N=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),S=w.get("invitation_id"),[k,I]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),[P,E]=(0,i.useState)([]),[O,T]=(0,i.useState)(null),[M,D]=(0,i.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,i.useEffect)(()=>{if(N){let e=(0,o.o)(N);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),d(l)}else console.log("User role not defined");e.user_email?m(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&k&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);e?E(JSON.parse(e)):(console.log("currentOrg: ".concat(JSON.stringify(v))),(async()=>{try{let e=await (0,x.g)(k);T(e);let t=await (0,x.Br)(k,l,s,!1,null,null);y(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(_))),(null==t?void 0:t.teams[0].keys)?h(t.keys.concat(t.teams.filter(e=>"Admin"===s||e.user_id===l).flatMap(e=>e.keys))):h(t.keys),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,x.So)(k,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),E(a),console.log("userModels:",P),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),p(k,l,s,v,u))}},[l,N,k,a,s]),(0,i.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(v),", accessToken: ").concat(k,", userID: ").concat(l,", userRole: ").concat(s)),k&&(console.log("fetching teams"),p(k,l,s,v,u))},[v]),(0,i.useEffect)(()=>{if(null!==a&&null!=M&&null!==M.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))M.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===M.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),A(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;A(e)}},[M]),null!=S)return(0,r.jsx)(eN.default,{});if(null==l||null==N){let e="/sso/key/generate";return document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",console.log("Full URL:",e),window.location.href=e,null}if(null==k)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",M),(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(j.Z,{numColSpan:1,className:"flex flex-col gap-2",children:[(0,r.jsx)(B,{userID:l,team:M,teams:t,userRole:s,accessToken:k,data:a,setData:h},M?M.team_id:null),(0,r.jsx)(ew,{userID:l,userRole:s,accessToken:k,selectedTeam:M||null,setSelectedTeam:D,data:a,setData:h,premiumUser:f,teams:t,currentOrg:v,setCurrentOrg:b,organizations:Z})]})})})},eI=s(97765);(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.Groq="Groq",t.MistralAI="Mistral AI",t.Deepseek="Deepseek",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI",t.AssemblyAI="AssemblyAI";let eC={OpenAI:"openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",Groq:"groq",MistralAI:"mistral",Cohere:"cohere_chat",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",xAI:"xai",Deepseek:"deepseek",Ollama:"ollama",AssemblyAI:"assemblyai"},eA={OpenAI:"https://artificialanalysis.ai/img/logos/openai_small.svg",Azure:"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg","Azure AI Studio":"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg",Anthropic:"https://artificialanalysis.ai/img/logos/anthropic_small.svg","Google AI Studio":"https://artificialanalysis.ai/img/logos/google_small.svg","Amazon Bedrock":"https://artificialanalysis.ai/img/logos/aws_small.png",Groq:"https://artificialanalysis.ai/img/logos/groq_small.png","Mistral AI":"https://artificialanalysis.ai/img/logos/mistral_small.png",Cohere:"https://artificialanalysis.ai/img/logos/cohere_small.png","OpenAI-Compatible Endpoints (Together AI, etc.)":"https://upload.wikimedia.org/wikipedia/commons/4/4e/OpenAI_Logo.svg","Vertex AI (Anthropic, Gemini, etc.)":"https://artificialanalysis.ai/img/logos/google_small.svg",Databricks:"https://artificialanalysis.ai/img/logos/databricks_small.png",Ollama:"https://artificialanalysis.ai/img/logos/ollama_small.svg",xAI:"https://artificialanalysis.ai/img/logos/xai_small.svg",Deepseek:"https://artificialanalysis.ai/img/logos/deepseek_small.jpg",AssemblyAI:"https://artificialanalysis.ai/img/logos/assemblyai_small.png"},eP=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(eC).find(l=>eC[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eA[s],displayName:s}},eE=e=>"Vertex AI (Anthropic, Gemini, etc.)"===e?"gemini-pro":"Anthropic"==e||"Amazon Bedrock"==e?"claude-3-opus":"Google AI Studio"==e?"gemini-pro":"Azure AI Studio"==e?"azure_ai/command-r-plus":"Azure"==e?"azure/my-deployment":"gpt-3.5-turbo",eO=(e,l)=>{console.log("Provider key: ".concat(e));let s=eC[e];console.log("Provider mapped to: ".concat(s));let t=[];return e&&"object"==typeof l&&(Object.entries(l).forEach(e=>{let[l,a]=e;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===s||a.litellm_provider.includes(s))&&t.push(l)}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(l).forEach(e=>{let[l,s]=e;null!==s&&"object"==typeof s&&"litellm_provider"in s&&"cohere"===s.litellm_provider&&t.push(l)}))),t},eT=async(e,l,s,t)=>{try{if(console.log("handling submit for formValues:",e),e.model&&e.model.includes("all-wildcard")){let l=eC[e.custom_llm_provider]+"/*";e.model_name=l,e.model=l}let a=e.model_mappings||[];for(let s of("model_mappings"in e&&delete e.model_mappings,a)){let t={},a={},r=s.public_name;for(let[l,r]of(t.model=s.litellm_model,e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),t.model=s.litellm_model,console.log("formValues add deployment:",e),Object.entries(e)))if(""!==r&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)t.model=r;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",r);let e=eC[r];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=r;else if("team_id"===l)a.team_id=r;else if("custom_model_name"===l)t.model=r;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))a[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){r&&(t[l]=Number(r));continue}else t[l]=r}let i={model_name:r,litellm_params:t,model_info:a},n=await (0,x.kK)(l,i);console.log("response for model create call: ".concat(n.data))}t&&t(),s.resetFields()}catch(e){I.ZP.error("Failed to create model: "+e,10)}},eM=e=>{var l;return(null==e?void 0:null===(l=e.model_info)||void 0===l?void 0:l.team_public_model_name)?e.model_info.team_public_model_name:(null==e?void 0:e.model_name)||"-"},eD=async(e,l,s,t)=>{if(console.log("handleEditSubmit:",e),null==l)return;let a={},r=null;for(let[l,s]of(e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),Object.entries(e)))"model_id"!==l?a[l]=""===s?null:s:r=""===s?null:s;let i={litellm_params:Object.keys(a).length>0?a:void 0,model_info:void 0!==r?{id:r}:void 0};console.log("handleEditSubmit payload:",i);try{await (0,x.um)(l,i),I.ZP.success("Model updated successfully, restart server to see updates"),s(!1),t(null)}catch(e){console.log("Error occurred")}};var eL=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[i]=k.Z.useForm(),n={},o="",d="";if(t){var c,m;n={...t.litellm_params,input_cost_per_token:(null===(c=t.litellm_params)||void 0===c?void 0:c.input_cost_per_token)?1e6*t.litellm_params.input_cost_per_token:void 0,output_cost_per_token:(null===(m=t.litellm_params)||void 0===m?void 0:m.output_cost_per_token)?1e6*t.litellm_params.output_cost_per_token:void 0},o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),n.model_id=d)}return(0,r.jsx)(C.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{a({...e,input_cost_per_token:e.input_cost_per_token?Number(e.input_cost_per_token)/1e6:void 0,output_cost_per_token:e.output_cost_per_token?Number(e.output_cost_per_token)/1e6:void 0}),i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(k.Z,{form:i,onFinish:a,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},eF=s(53003),eR=s(47323),ez=s(75105),eU=s(40278),eV=s(69410),eq=s(14301),eB=s(53410),eK=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,n]=(0,i.useState)(!1),o=async()=>{try{I.ZP.info("Making API Call"),n(!0);let e=await (0,x.Og)(s,l);console.log("model delete Response:",e),I.ZP.success("Model ".concat(l," deleted successfully")),n(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eR.Z,{onClick:()=>n(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(C.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>n(!1),children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Delete Model"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Model ID: ",(0,r.jsx)("b",{children:l})]})})]})})]})},eW=s(94789),eH=s(59664),eG=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eH.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,r.jsxs)("div",{children:[(0,r.jsx)(eW.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,r.jsx)(f.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eY=e=>{var l,s,t;let{visible:a,onCancel:n,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=k.Z.useForm();console.log("Initial Data:",d),(0,i.useEffect)(()=>{if(a){if("edit"===c&&d)u.setFieldsValue({...d,role:d.role||m.defaultRole});else{var e;u.resetFields(),u.setFieldsValue({role:m.defaultRole||(null===(e=m.roleOptions[0])||void 0===e?void 0:e.value)})}}},[a,d,c,u,m.defaultRole,m.roleOptions]);let h=async e=>{try{let l=Object.entries(e).reduce((e,l)=>{let[s,t]=l;return{...e,[s]:"string"==typeof t?t.trim():t}},{});o(l),u.resetFields(),I.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){I.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}},x=e=>{switch(e.type){case"input":return(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",onChange:e=>{e.target.value=e.target.value.trim()}});case"select":var l;return(0,r.jsx)(S.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(C.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:n,children:(0,r.jsxs)(k.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),m.showEmail&&m.showUserId&&(0,r.jsx)("div",{className:"text-center mb-4",children:(0,r.jsx)(b.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{children:"Role"}),"edit"===c&&d&&(0,r.jsxs)("span",{className:"text-gray-500 text-sm",children:["(Current: ",(s=d.role,(null===(t=m.roleOptions.find(e=>e.value===s))||void 0===t?void 0:t.label)||s),")"]})]}),name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,r.jsx)(S.default,{children:"edit"===c&&d?[...m.roleOptions.filter(e=>e.value===d.role),...m.roleOptions.filter(e=>e.value!==d.role)].map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))})}),null===(l=m.additionalFields)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.Z.Item,{label:e.label,name:e.name,className:"mb-4",rules:e.rules,children:x(e)},e.name)),(0,r.jsxs)("div",{className:"text-right mt-6",children:[(0,r.jsx)(O.ZP,{onClick:n,className:"mr-2",children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},eJ=s(7310),e$=s.n(eJ),eX=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:n="Add Team Member",roles:o=[{label:"admin",value:"admin",description:"Admin role. Can create team keys, add members, and manage settings."},{label:"user",value:"user",description:"User role. Can view team info, but not manage it."}],defaultRole:d="user"}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}p(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,x.u5)(a,s)).map(e=>({label:"user_email"===l?"".concat(e.user_email):"".concat(e.user_id),value:"user_email"===l?e.user_email:e.user_id,user:e}));u(t)}catch(e){console.error("Error fetching users:",e)}finally{p(!1)}},Z=(0,i.useCallback)(e$()((e,l)=>f(e,l),300),[]),_=(e,l)=>{g(l),Z(e,l)},y=(e,l)=>{let s=l.user;c.setFieldsValue({user_email:s.user_email,user_id:s.user_id,role:c.getFieldValue("role")})};return(0,r.jsx)(C.Z,{title:n,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(k.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>_(e,"user_email"),onSelect:(e,l)=>y(e,l),options:"user_email"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>_(e,"user_id"),onSelect:(e,l)=>y(e,l),options:"user_id"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(k.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:(0,r.jsxs)(R.Z,{title:e.description,children:[(0,r.jsx)("span",{className:"font-medium",children:e.label}),(0,r.jsxs)("span",{className:"ml-2 text-gray-500 text-sm",children:["- ",e.description]})]})},e.value))})}),(0,r.jsx)("div",{className:"text-right mt-4",children:(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},eQ=e=>{let{teamId:l,accessToken:s,currentAliases:t,availableModels:a,onUpdate:n}=e,[o,d]=(0,i.useState)(!1),[c]=k.Z.useForm(),m=async e=>{try{if(!s)return;let a={...t,[e.alias_name]:e.original_model};await (0,x.Gh)(s,{team_id:l,model_aliases:a}),I.ZP.success("Model alias created successfully"),d(!1),c.resetFields(),t[e.alias_name]=e.original_model}catch(e){I.ZP.error("Failed to create model alias"),console.error("Error creating model alias:",e)}};return(0,r.jsxs)("div",{className:"mt-8",children:[(0,r.jsx)(w.Z,{children:"Team Aliases"}),(0,r.jsx)(b.Z,{className:"text-gray-600 mb-4",children:"Allow a team to use an alias that points to a specific model deployment."}),(0,r.jsxs)("div",{className:"bg-white rounded-lg p-6 border border-gray-200",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsx)("div",{children:(0,r.jsxs)("div",{className:"flex space-x-4 text-gray-600",children:[(0,r.jsx)("div",{className:"w-64",children:"ALIAS"}),(0,r.jsx)("div",{children:"POINTS TO"})]})}),(0,r.jsx)(f.Z,{size:"md",variant:"primary",onClick:()=>d(!0),children:"Create Model Alias"})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[Object.entries(t).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)("div",{className:"flex space-x-4 border-t border-gray-200 pt-4",children:[(0,r.jsx)("div",{className:"w-64",children:(0,r.jsx)("span",{className:"bg-gray-100 px-2 py-1 rounded font-mono text-sm text-gray-700",children:s})}),(0,r.jsx)("div",{children:(0,r.jsx)("span",{className:"bg-gray-100 px-2 py-1 rounded font-mono text-sm text-gray-700",children:t})})]},l)}),0===Object.keys(t).length&&(0,r.jsx)("div",{className:"text-gray-500 text-center py-4 border-t border-gray-200",children:"No model aliases configured"})]})]}),(0,r.jsx)(C.Z,{title:"Create Model Alias",open:o,onCancel:()=>{d(!1),c.resetFields()},footer:null,width:500,children:(0,r.jsxs)(k.Z,{form:c,onFinish:m,layout:"vertical",className:"mt-4",children:[(0,r.jsx)(k.Z.Item,{label:"Alias Name",name:"alias_name",rules:[{required:!0,message:"Please enter an alias name"}],children:(0,r.jsx)(E.Z,{placeholder:"Enter the model alias (e.g., gpt-4o)",type:""})}),(0,r.jsx)(k.Z.Item,{label:"Points To",name:"original_model",rules:[{required:!0,message:"Please select a model"}],children:(0,r.jsx)(S.default,{placeholder:"Select model version",className:"w-full font-mono",showSearch:!0,optionFilterProp:"children",children:a.map(e=>(0,r.jsx)(S.default.Option,{value:e,className:"font-mono",children:e},e))})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(f.Z,{size:"md",variant:"secondary",onClick:()=>{d(!1),c.resetFields()},className:"bg-white text-gray-700 border border-gray-300 hover:bg-gray-50",children:"Cancel"}),(0,r.jsx)(f.Z,{size:"md",variant:"secondary",type:"submit",children:"Create Alias"})]})]})})]})},e0=e=>{var l,s,t;let{teamId:a,onClose:n,accessToken:o,is_team_admin:d,is_proxy_admin:c,userModels:m,editTeam:u}=e,[h,p]=(0,i.useState)(null),[j,Z]=(0,i.useState)(!0),[_,y]=(0,i.useState)(!1),[v]=k.Z.useForm(),[N,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),[D,L]=(0,i.useState)(!1);console.log("userModels in team info",m);let z=d||c,U=async()=>{try{if(Z(!0),!o)return;let e=await (0,x.Xm)(o,a);p(e)}catch(e){I.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{Z(!1)}};(0,i.useEffect)(()=>{U()},[a,o]);let V=async e=>{try{if(null==o)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.cu)(o,a,l),I.ZP.success("Team member added successfully"),y(!1),v.resetFields(),U()}catch(e){I.ZP.error("Failed to add team member"),console.error("Error adding team member:",e)}},q=async e=>{try{if(null==o)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.sN)(o,a,l),I.ZP.success("Team member updated successfully"),C(!1),U()}catch(e){I.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},B=async e=>{try{if(null==o)return;await (0,x.Lp)(o,a,e),I.ZP.success("Team member removed successfully"),U()}catch(e){I.ZP.error("Failed to remove team member"),console.error("Error removing team member:",e)}},K=async e=>{try{var l;if(!o)return;let s={team_id:a,team_alias:e.team_alias,models:e.models,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration,metadata:{...null==h?void 0:null===(l=h.team_info)||void 0===l?void 0:l.metadata,guardrails:e.guardrails||[]}};await (0,x.Gh)(o,s),I.ZP.success("Team settings updated successfully"),L(!1),U()}catch(e){I.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(j)return(0,r.jsx)("div",{className:"p-4",children:"Loading..."});if(!(null==h?void 0:h.team_info))return(0,r.jsx)("div",{className:"p-4",children:"Team not found"});let{team_info:W}=h;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:n,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:W.team_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:W.team_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:u?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",W.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===W.max_budget?"Unlimited":"$".concat(W.max_budget)]}),W.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",W.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",W.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",W.rpm_limit||"Unlimited"]}),W.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",W.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:W.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:h.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)($.Z,{children:z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{T(e),C(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>B(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(f.Z,{onClick:()=>y(!0),children:"Add Member"})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Team Settings"}),z&&!D&&(0,r.jsx)(f.Z,{onClick:()=>L(!0),children:"Edit Settings"})]}),D?(0,r.jsxs)(k.Z,{form:v,onFinish:K,initialValues:{...W,team_alias:W.team_alias,models:W.models,tpm_limit:W.tpm_limit,rpm_limit:W.rpm_limit,max_budget:W.max_budget,budget_duration:W.budget_duration,guardrails:(null===(l=W.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(E.Z,{type:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),m.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>L(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:W.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:W.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(W.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:W.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",W.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",W.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==W.max_budget?"$".concat(W.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",W.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:W.blocked?"red":"green",children:W.blocked?"Blocked":"Active"})]})]})]}),(0,r.jsx)(eQ,{teamId:a,accessToken:o,currentAliases:(null==h?void 0:null===(t=h.team_info)||void 0===t?void 0:null===(s=t.litellm_model_table)||void 0===s?void 0:s.model_aliases)||{},availableModels:m,onUpdate:U})]})]})]}),(0,r.jsx)(eY,{visible:N,onCancel:()=>C(!1),onSubmit:q,initialData:A,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Admin",value:"admin"},{label:"User",value:"user"}]}}),(0,r.jsx)(eX,{isVisible:_,onCancel:()=>y(!1),onSubmit:V,accessToken:o})]})};function e1(e){var l,s,t,a,n,o,d,c,m,u,h;let{modelId:p,onClose:j,modelData:Z,accessToken:_,userID:y,userRole:v,editModel:N,setEditModalVisible:S,setSelectedModel:C}=e,[A,P]=(0,i.useState)(!1),[E]=k.Z.useForm(),[T,M]=(0,i.useState)(!1),D="Admin"===v;if(!Z)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsx)(b.Z,{children:"Model not found"})]});let L=async()=>{try{if(!_)return;await (0,x.Og)(_,p),I.ZP.success("Model deleted successfully"),j()}catch(e){console.error("Error deleting the model:",e),I.ZP.error("Failed to delete model")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsxs)(w.Z,{children:["Public Model Name: ",eM(Z)]}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:Z.model_info.id})]}),D&&(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>M(!0),className:"flex items-center",children:"Delete Model"})})]}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-6",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Raw JSON"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6 mb-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Provider"}),(0,r.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[Z.provider&&(0,r.jsx)("img",{src:eP(Z.provider).logo,alt:"".concat(Z.provider," logo"),className:"w-4 h-4",onError:e=>{let l=e.target,s=l.parentElement;if(s){var t;let e=document.createElement("div");e.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=(null===(t=Z.provider)||void 0===t?void 0:t.charAt(0))||"-",s.replaceChild(e,l)}}}),(0,r.jsx)(w.Z,{children:Z.provider||"Not Set"})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"LiteLLM Model"}),(0,r.jsx)("pre",{children:(0,r.jsx)(w.Z,{children:Z.litellm_model_name||"Not Set"})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Pricing"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Input: $",Z.input_cost,"/1M tokens"]}),(0,r.jsxs)(b.Z,{children:["Output: $",Z.output_cost,"/1M tokens"]})]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Model Settings"}),D&&!A&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>P(!0),children:"Edit Settings"})]}),A?(0,r.jsx)(eL,{visible:A,onCancel:()=>P(!1),model:Z,onSubmit:e=>eD(e,_,S,C)}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model ID"}),(0,r.jsx)("div",{className:"font-mono",children:Z.model_info.id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Public Model Name"}),(0,r.jsx)("div",{children:eM(Z)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Model Name"}),(0,r.jsx)("div",{children:Z.litellm_model_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Input Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(l=Z.litellm_params)||void 0===l?void 0:l.input_cost_per_token)?(1e6*Z.litellm_params.input_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Output Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(s=Z.litellm_params)||void 0===s?void 0:s.output_cost_per_token)?(1e6*Z.litellm_params.output_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"API Base"}),(0,r.jsx)("div",{children:(null===(t=Z.litellm_params)||void 0===t?void 0:t.api_base)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Custom LLM Provider"}),(0,r.jsx)("div",{children:(null===(a=Z.litellm_params)||void 0===a?void 0:a.custom_llm_provider)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model"}),(0,r.jsx)("div",{children:(null===(n=Z.litellm_params)||void 0===n?void 0:n.model)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)("div",{children:(null===(o=Z.litellm_params)||void 0===o?void 0:o.organization)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"TPM (Tokens per Minute)"}),(0,r.jsx)("div",{children:(null===(d=Z.litellm_params)||void 0===d?void 0:d.tpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"RPM (Requests per Minute)"}),(0,r.jsx)("div",{children:(null===(c=Z.litellm_params)||void 0===c?void 0:c.rpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Max Retries"}),(0,r.jsx)("div",{children:(null===(m=Z.litellm_params)||void 0===m?void 0:m.max_retries)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(u=Z.litellm_params)||void 0===u?void 0:u.timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Stream Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(h=Z.litellm_params)||void 0===h?void 0:h.stream_timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{children:Z.model_info.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:Z.model_info.created_at?new Date(Z.model_info.created_at).toLocaleString():"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created By"}),(0,r.jsx)("div",{children:Z.model_info.created_by||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Parameters"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(Z.cleanedLitellmParams,null,2)})]})]})]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsx)("pre",{className:"bg-gray-100 p-4 rounded text-xs overflow-auto",children:JSON.stringify(Z,null,2)})})})]})]}),T&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Model"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this model?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(O.ZP,{onClick:L,className:"ml-2",danger:!0,children:"Delete"}),(0,r.jsx)(O.ZP,{onClick:()=>M(!1),children:"Cancel"})]})]})]})})]})}var e2=s(67960),e4=s(47451),e5=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,i=k.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,r.jsx)(k.Z.Item,{name:"model",rules:[{required:!0,message:"Please select at least one model."}],noStyle:!0,children:l===a.Azure||l===a.OpenAI_Compatible||l===a.Ollama?(0,r.jsx)(Z.Z,{placeholder:t(l)}):s.length>0?(0,r.jsx)(S.default,{mode:"multiple",allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{let l=Array.isArray(e)?e:[e];if(l.includes("all-wildcard"))i.setFieldsValue({model_name:void 0,model_mappings:[]});else{let e=l.map(e=>({public_name:e,litellm_model:e}));i.setFieldsValue({model_mappings:e})}},optionFilterProp:"children",filterOption:(e,l)=>{var s;return(null!==(s=null==l?void 0:l.label)&&void 0!==s?s:"").toLowerCase().includes(e.toLowerCase())},options:[{label:"All ".concat(l," Models (Wildcard)"),value:"all-wildcard"},...s.map(e=>({label:e,value:e})),{label:"Custom Model Name (Enter below)",value:"custom"}],style:{width:"100%"}}):(0,r.jsx)(Z.Z,{placeholder:t(l)})}),(0,r.jsx)(k.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,r.jsx)(k.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name."}],className:"mt-2",children:(0,r.jsx)(Z.Z,{placeholder:"Enter custom model name"})})}})]}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},e3=s(48379),e6=()=>{let e=k.Z.useFormInstance(),l=k.Z.useWatch("model",e)||[],s=!l.includes("all-wildcard");if((0,i.useEffect)(()=>{if(l.length>0&&!l.includes("all-wildcard")){let s=l.map(e=>({public_name:e,litellm_model:e}));e.setFieldValue("model_mappings",s)}},[l,e]),!s)return null;let t=[{title:"Public Name",dataIndex:"public_name",key:"public_name",render:(l,s,t)=>(0,r.jsx)(Z.Z,{defaultValue:l,onChange:l=>{let s=[...e.getFieldValue("model_mappings")];s[t].public_name=l.target.value,e.setFieldValue("model_mappings",s)}})},{title:"LiteLLM Model",dataIndex:"litellm_model",key:"litellm_model"}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Model Mappings",name:"model_mappings",tooltip:"Map public model names to LiteLLM model names for load balancing",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!0,children:(0,r.jsx)(e3.Z,{dataSource:e.getFieldValue("model_mappings"),columns:t,pagination:!1,size:"small"})}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})},e8=s(87024),e7=s(3632);let{Link:e9}=eS.default;var le=e=>{let{selectedProvider:l,uploadProps:s}=e;console.log("Selected provider: ".concat(l)),console.log("type of selectedProvider: ".concat(typeof l));let t=a[l];return console.log("selectedProviderEnum: ".concat(t)),console.log("type of selectedProviderEnum: ".concat(typeof t)),(0,r.jsxs)(r.Fragment,{children:[t===a.OpenAI&&(0,r.jsx)(k.Z.Item,{label:"OpenAI Organization ID",name:"organization",children:(0,r.jsx)(Z.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),t===a.Vertex_AI&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,r.jsx)(Z.Z,{placeholder:"adroit-cadet-1234.."})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(e8.Z,{...s,children:(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(e7.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]})]}),t===a.AssemblyAI&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(S.default,{placeholder:"Select API Base",children:[(0,r.jsx)(S.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(S.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsx)(Z.Z,{placeholder:"https://..."})}),t===a.Azure&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"API Version",name:"api_version",tooltip:"By default litellm will use the latest version. If you want to use a different version, you can specify it here",children:(0,r.jsx)(Z.Z,{placeholder:"2023-07-01-preview"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(k.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,r.jsx)(Z.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,r.jsxs)(e4.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(e9,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]})]}),t===a.Bedrock&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})})]}),t!=a.Bedrock&&t!=a.Vertex_AI&&t!=a.Ollama&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",tooltip:"LLM API Credentials",children:(0,r.jsx)(Z.Z,{placeholder:"sk-",type:"password"})})]})},ll=s(63709),ls=s(90464);let{Link:lt}=eS.default;var la=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s,teams:t}=e,[a]=k.Z.useForm(),[n,o]=i.useState(!1),[d,c]=i.useState("per_token"),m=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),u=(e,l)=>{if(!l)return Promise.resolve();try{return JSON.parse(l),Promise.resolve()}catch(e){return Promise.reject("Please enter valid JSON")}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(_.Z,{className:"mt-2 mb-4",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Advanced Settings"})}),(0,r.jsx)(y.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",className:"mb-4",children:(0,r.jsx)(L,{teams:t})}),(0,r.jsx)(k.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(ll.Z,{onChange:e=>{o(e),e||a.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),n&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(k.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:"per_token",onChange:e=>c(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(k.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(k.Z.Item,{label:"Use in pass through routes",name:"use_in_pass_through",valuePropName:"checked",className:"mb-4 mt-4",tooltip:(0,r.jsxs)("span",{children:["Allow using these credentials in pass through routes."," ",(0,r.jsx)(lt,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(ll.Z,{onChange:e=>{let l=a.getFieldValue("litellm_extra_params");try{let s=l?JSON.parse(l):{};e?s.use_in_pass_through=!0:delete s.use_in_pass_through,Object.keys(s).length>0?a.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):a.setFieldValue("litellm_extra_params","")}catch(l){e?a.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):a.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(k.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-4 mt-4",rules:[{validator:u}],children:(0,r.jsx)(ls.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(e4.Z,{className:"mb-4",children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(lt,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(k.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",rules:[{validator:u}],children:(0,r.jsx)(ls.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})};let{Title:lr,Link:li}=eS.default;var ln=e=>{let{form:l,handleOk:s,selectedProvider:t,setSelectedProvider:i,providerModels:n,setProviderModelsFn:o,getPlaceholder:d,uploadProps:c,showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lr,{level:2,children:"Add new model"}),(0,r.jsx)(e2.Z,{children:(0,r.jsx)(k.Z,{form:l,onFinish:s,labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,r.jsx)(S.default,{showSearch:!0,value:t,onChange:e=>{i(e),o(e),l.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(S.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eA[s],alt:"".concat(l," logo"),className:"w-5 h-5",onError:e=>{let l=e.target,t=l.parentElement;if(t){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=s.charAt(0),t.replaceChild(e,l)}}}),(0,r.jsx)("span",{children:s})]})},l)})})}),(0,r.jsx)(e5,{selectedProvider:t,providerModels:n,getPlaceholder:d}),(0,r.jsx)(e6,{}),(0,r.jsx)(le,{selectedProvider:t,uploadProps:c}),(0,r.jsx)(la,{showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}),(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(R.Z,{title:"Get help on our github",children:(0,r.jsx)(eS.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]})};let{Title:lo,Link:ld}=eS.default,lc={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var lm=e=>{let{accessToken:l,token:s,userRole:t,userID:n,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m,teams:u}=e,[h,p]=(0,i.useState)([]),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(""),[N,S]=(0,i.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[C,A]=(0,i.useState)([]),[E,O]=(0,i.useState)(a.OpenAI),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(!1),[F,z]=(0,i.useState)(null),[U,V]=(0,i.useState)([]),[q,B]=(0,i.useState)([]),[K,W]=(0,i.useState)(null),[H,G]=(0,i.useState)([]),[el,em]=(0,i.useState)([]),[eh,ex]=(0,i.useState)([]),[ep,ej]=(0,i.useState)([]),[eg,eZ]=(0,i.useState)([]),[e_,ey]=(0,i.useState)([]),[ev,eb]=(0,i.useState)([]),[ew,eN]=(0,i.useState)([]),[ek,eA]=(0,i.useState)([]),[eW,eH]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eY,eJ]=(0,i.useState)(null),[e$,eX]=(0,i.useState)(0),[eQ,e2]=(0,i.useState)({}),[e4,e5]=(0,i.useState)([]),[e3,e6]=(0,i.useState)(!1),[e8,e7]=(0,i.useState)(null),[e9,le]=(0,i.useState)(null),[ll,ls]=(0,i.useState)([]),[lt,la]=(0,i.useState)(!1),[lr,li]=(0,i.useState)(null),[lo,ld]=(0,i.useState)(!1),[lm,lu]=(0,i.useState)(null),lh=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!n||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),W(e);let r=null==e8?void 0:e8.token;void 0===r&&(r=null);let i=e9;void 0===i&&(i=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,x.o6)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model metrics response:",o),em(o.data),ex(o.all_api_bases);let d=await (0,x.Rg)(l,e,s.toISOString(),a.toISOString());ej(d.data),eZ(d.all_api_bases);let c=await (0,x.N8)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model exceptions response:",c),ey(c.data),eb(c.exception_types);let m=await (0,x.fP)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);if(console.log("slowResponses:",m),eA(m),e){let t=await (0,x.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e2(t);let r=await (0,x.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e5(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,i.useEffect)(()=>{lh(K,eW.from,eW.to)},[e8,e9]);let lx=e=>{z(e),L(!0)},lp=()=>{v(new Date().toLocaleString())},lj=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eY);try{await (0,x.K_)(l,{router_settings:{model_group_retry_policy:eY}}),I.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),I.ZP.error("Failed to save retry settings")}};if((0,i.useEffect)(()=>{if(!l||!s||!t||!n)return;let e=async()=>{try{var e,s,a,r,i,o,d,m,u,h,p,j;let g=await (0,x.hy)(l);A(g);let f=await (0,x.AZ)(l,n,t);console.log("Model data response:",f.data),c(f);let Z=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",K);let v=await (0,x.o6)(l,n,t,y,null===(e=eW.from)||void 0===e?void 0:e.toISOString(),null===(s=eW.to)||void 0===s?void 0:s.toISOString(),null==e8?void 0:e8.token,e9);console.log("Model metrics response:",v),em(v.data),ex(v.all_api_bases);let b=await (0,x.Rg)(l,y,null===(a=eW.from)||void 0===a?void 0:a.toISOString(),null===(r=eW.to)||void 0===r?void 0:r.toISOString());ej(b.data),eZ(b.all_api_bases);let w=await (0,x.N8)(l,n,t,y,null===(i=eW.from)||void 0===i?void 0:i.toISOString(),null===(o=eW.to)||void 0===o?void 0:o.toISOString(),null==e8?void 0:e8.token,e9);console.log("Model exceptions response:",w),ey(w.data),eb(w.exception_types);let N=await (0,x.fP)(l,n,t,y,null===(d=eW.from)||void 0===d?void 0:d.toISOString(),null===(m=eW.to)||void 0===m?void 0:m.toISOString(),null==e8?void 0:e8.token,e9),S=await (0,x.n$)(l,null===(u=eW.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=eW.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);e2(S);let k=await (0,x.v9)(l,null===(p=eW.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=eW.to)||void 0===j?void 0:j.toISOString().split("T")[0],y);e5(k),console.log("dailyExceptions:",S),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",N),eA(N);let I=await (0,x.j2)(l);ls(null==I?void 0:I.end_users);let C=(await (0,x.BL)(l,n,t)).router_settings;console.log("routerSettingsInfo:",C);let P=C.model_group_retry_policy,E=C.num_retries;console.log("model_group_retry_policy:",P),console.log("default_retries:",E),eJ(P),eX(E)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&n&&e();let a=async()=>{let e=await (0,x.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),_(e)};null==Z&&a(),lp()},[l,s,t,n,Z,y]),!o||!l||!s||!t||!n)return(0,r.jsx)("div",{children:"Loading..."});let lg=[],lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(Z)),null!=Z&&"object"==typeof Z&&e in Z)?Z[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(r=t)||(r=1===e.length?u(s):l)}else r="-";a&&(i=null==a?void 0:a.input_cost_per_token,n=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==l?void 0:l.litellm_params)&&(m=Object.fromEntries(Object.entries(null==l?void 0:l.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),o.data[e].provider=r,o.data[e].input_cost=i,o.data[e].output_cost=n,o.data[e].litellm_model_name=s,lf.push(r),o.data[e].input_cost&&(o.data[e].input_cost=(1e6*Number(o.data[e].input_cost)).toFixed(2)),o.data[e].output_cost&&(o.data[e].output_cost=(1e6*Number(o.data[e].output_cost)).toFixed(2)),o.data[e].max_tokens=d,o.data[e].max_input_tokens=c,o.data[e].api_base=null==l?void 0:null===(ly=l.litellm_params)||void 0===ly?void 0:ly.api_base,o.data[e].cleanedLitellmParams=m,lg.push(l.model_name),console.log(o.data[e])}if(o.data&&o.data.length>0&&o.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lv=async()=>{try{I.ZP.info("Running health check..."),M("");let e=await (0,x.EY)(l);M(e)}catch(e){console.error("Error running health check:",e),M("Error running health check")}},lb=(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Select API Key Name"}),m?(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{e7(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{le(e)},children:e},l))]})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsxs)(et.Z,{value:String(l),disabled:!0,onClick:()=>{e7(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{le(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lw=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let i=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,n=t.sort((e,l)=>l.value-e.value);if(n.length>5){let e=n.length-5;(n=n.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,r.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[i&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",i]}),n.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,r.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,r.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})};console.log("selectedProvider: ".concat(E)),console.log("providerModels.length: ".concat(N.length));let lN=Object.keys(a).find(e=>a[e]===E);return(lN&&C.find(e=>e.name===eC[lN]),lm)?(0,r.jsx)("div",{className:"w-full h-full",children:(0,r.jsx)(e0,{teamId:lm,onClose:()=>lu(null),accessToken:l,is_team_admin:"Admin"===t,is_proxy_admin:"Proxy Admin"===t,userModels:lg,editTeam:!1})}):(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:lr?(0,r.jsx)(e1,{modelId:lr,editModel:!0,onClose:()=>{li(null),ld(!1)},modelData:o.data.find(e=>e.model_info.id===lr),accessToken:l,userID:n,userRole:t,setEditModalVisible:L,setSelectedModel:z}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"All Models"}),(0,r.jsx)(ei.Z,{children:"Add Model"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(ei.Z,{children:"Model Analytics"}),(0,r.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[y&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",y]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lp})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||void 0,onValueChange:e=>W("all"===e?"all":e),value:K||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Model ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created At":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created By":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Team ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:o.data.filter(e=>"all"===K||e.model_name===K||null==K||""===K).map((e,s)=>{var a;return(0,r.jsxs)(ee.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.model_info.id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>li(e.model_info.id),children:[e.model_info.id.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:eM(e)||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[e.provider&&(0,r.jsx)("img",{src:eP(e.provider).logo,alt:"".concat(e.provider," logo"),className:"w-4 h-4",onError:l=>{let s=l.target,t=s.parentElement;if(t){var a;let l=document.createElement("div");l.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",l.textContent=(null===(a=e.provider)||void 0===a?void 0:a.charAt(0))||"-",t.replaceChild(l,s)}}}),(0,r.jsx)("p",{className:"text-xs",children:e.provider||"-"})]})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.litellm_model_name,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.litellm_model_name?e.litellm_model_name:"",children:e&&e.litellm_model_name?e.litellm_model_name.slice(0,20)+(e.litellm_model_name.length>20?"...":""):"-"})})}),"Admin"===t&&(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.api_base,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:null!=e.litellm_params.input_cost_per_token&&void 0!=e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&((a=e.model_info.created_at)?new Date(a).toLocaleDateString("en-US"):null)||"-"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:e.model_info.team_id?(0,r.jsx)(R.Z,{title:e.model_info.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-purple-500 bg-purple-50 hover:bg-purple-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{lu(e.model_info.team_id)},children:[e.model_info.team_id.slice(0,7),"..."]})}):"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,r.jsx)(ea.Z,{size:"xs",className:"text-white",children:(0,r.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,r.jsx)(ea.Z,{size:"xs",className:"text-black",children:(0,r.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>lx(e)})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eK,{modelID:e.model_info.id,accessToken:l,callback:lp})})]})})]},s)})})]})})]}),(0,r.jsx)(eL,{visible:D,onCancel:()=>{L(!1),z(null)},model:F,onSubmit:e=>eD(e,l,L,z)})]}),(0,r.jsx)(ed.Z,{className:"h-full",children:(0,r.jsx)(ln,{form:j,handleOk:()=>{j.validateFields().then(e=>{eT(e,l,j,lp)}).catch(e=>{console.error("Validation failed:",e)})},selectedProvider:E,setSelectedProvider:O,providerModels:N,setProviderModelsFn:e=>{let l=eO(e,Z);S(l),console.log("providerModels: ".concat(l))},getPlaceholder:eE,uploadProps:{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;j.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?I.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&I.ZP.error("".concat(e.file.name," file upload failed."))}},showAdvancedSettings:lt,setShowAdvancedSettings:la,teams:u})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(f.Z,{onClick:lv,children:"Run `/health`"}),T&&(0,r.jsx)("pre",{children:JSON.stringify(T,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:eW,className:"mr-2",onValueChange:e=>{eH(e),lh(K,e.from,e.to)}})]}),(0,r.jsxs)(eV.Z,{className:"ml-2",children:[(0,r.jsx)(b.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:K||U[0],value:K||U[0],children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lh(e,eW.from,eW.to),children:e},l))})]}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eq.Z,{trigger:"click",content:lb,overlayStyle:{width:"20vw"},children:(0,r.jsx)(f.Z,{icon:ef.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>e6(!0)})})})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,r.jsx)(b.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),el&&eh&&(0,r.jsx)(ez.Z,{title:"Model Latency",className:"h-72",data:el,showLegend:!1,index:"date",categories:eh,connectNulls:!0,customTooltip:lw})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(eG,{modelMetrics:ep,modelMetricsCategories:eg,customTooltip:lw,premiumUser:m})})]})]})})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Deployment"}),(0,r.jsx)(Q.Z,{children:"Success Responses"}),(0,r.jsxs)(Q.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(J.Z,{children:ek.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.api_base}),(0,r.jsx)($.Z,{children:e.total_count}),(0,r.jsx)($.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Exceptions for ",K]}),(0,r.jsx)(eU.Z,{className:"h-60",data:e_,index:"model",categories:ev,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Up Rate Limit Errors (429) for ",K]}),(0,r.jsxs)(g.Z,{numItems:1,children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",eQ.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:eQ.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eV.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:e4.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,r.jsx)(r.Fragment,{children:e4&&e4.length>0&&e4.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||U[0],value:K||U[0],onValueChange:e=>W(e),children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))})]}),(0,r.jsxs)(w.Z,{children:["Retry Policy for ",K]}),(0,r.jsx)(b.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lc&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(lc).map((e,l)=>{var s;let[t,a]=e,i=null==eY?void 0:null===(s=eY[K])||void 0===s?void 0:s[a];return null==i&&(i=e$),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(P.Z,{className:"ml-5",value:i,min:0,step:1,onChange:e=>{eJ(l=>{var s;let t=null!==(s=null==l?void 0:l[K])&&void 0!==s?s:{};return{...null!=l?l:{},[K]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(f.Z,{className:"mt-6 mr-8",onClick:lj,children:"Save"})]})]})]})})};function lu(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:i,Paragraph:n}=eS.default,o=()=>(null==a?void 0:a.has_user_setup_sso)?new URL("/ui",t).toString():new URL("/ui?invitation_id=".concat(null==a?void 0:a.id),t).toString();return(0,r.jsxs)(C.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(n,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(b.Z,{children:null==a?void 0:a.user_id})]}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{children:"Invitation Link"}),(0,r.jsx)(b.Z,{children:(0,r.jsx)(b.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>I.ZP.success("Copied!"),children:(0,r.jsx)(f.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:lh}=S.default;var lx=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,i.useState)(null),[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[j,g]=(0,i.useState)([]),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(null),N=(0,n.useRouter)(),[A,P]=(0,i.useState)("http://localhost:4000");(0,i.useEffect)(()=>{(async()=>{try{let e=await (0,x.So)(s,l,"any"),t=[];for(let l=0;l{N&&P(new URL("/",window.location.href).toString())},[N]);let T=async e=>{try{var t;I.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,x.Ov)(s,null,e);console.log("user create Response:",a),p(a.key);let r=(null===(t=a.data)||void 0===t?void 0:t.user_id)||a.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:r,is_accepted:!1,accepted_at:null,expires_at:new Date(Date.now()+6048e5),created_at:new Date,created_by:l,updated_at:new Date,updated_by:l,has_user_setup_sso:!0};w(e),y(!0)}else(0,x.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,w(e),y(!0)});I.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(C.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),p(null),c.resetFields()},children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(k.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(S.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(lh,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(lh,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(lu,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:y,baseUrl:A,invitationLinkData:v})]})},lp=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:n}=e,[o,d]=(0,i.useState)(a),[c]=k.Z.useForm();(0,i.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{n(e),c.resetFields(),t()};return a?(0,r.jsx)(C.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(k.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",help:"Across all keys (including keys with team_id).",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",help:"Ignored if the key has a team_id; team budget applies there.",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var lj=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:n,teams:o,setKeys:d}=e,[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(1),[y,v]=i.useState(null),[b,w]=(0,i.useState)(null),[N,S]=(0,i.useState)(!1),[k,C]=(0,i.useState)(null),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(null),[T,M]=(0,i.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let D=e=>{O(e),P(!0)},L=async()=>{if(E&&l)try{if(await (0,x.Eb)(l,[E]),I.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==E);h(e)}}catch(e){console.error("Error deleting user:",e),I.ZP.error("Failed to delete user")}P(!1),O(null)},F=async()=>{C(null),S(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&n){try{await (0,x.pf)(l,e,null),I.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}u&&h(u.map(l=>l.user_id===e.user_id?e:l)),C(null),S(!1)}};return((0,i.useEffect)(()=>{if(!l||!s||!a||!n)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,x.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)M(JSON.parse(s));else{let e=await (0,x.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),M(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&n&&e()},[l,s,a,n,Z]),u&&l&&s&&a&&n)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(g.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(lx,{userID:n,accessToken:l,teams:o,possibleUIRoles:T}),(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,r.jsx)("div",{className:"mb-4 mt-1"}),(0,r.jsx)(en.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(Y.Z,{className:"mt-5",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(Q.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(Q.Z,{children:"API Keys"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.user_id||"-"}),(0,r.jsx)($.Z,{children:e.user_email||"-"}),(0,r.jsx)($.Z,{children:(null==T?void 0:null===(l=T[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,r.jsx)($.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)($.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)($.Z,{children:(0,r.jsx)(g.Z,{numItems:2,children:e.key_count>0?(0,r.jsxs)(ea.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,r.jsx)(ea.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,onClick:()=>{C(e),S(!0)},children:"View Keys"}),(0,r.jsx)(eR.Z,{icon:eh.Z,onClick:()=>D(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,r.jsx)(lp,{visible:N,possibleUIRoles:T,onCancel:F,user:k,onSubmit:R}),A&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,r.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),_(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},lg=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,i.useState)([]);(0,i.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,x.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let n=async e=>{if(l&&s)try{await (0,x.cu)(l,e,{user_id:s,role:"user"}),I.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),I.ZP.error("Failed to join team")}};return(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Description"}),(0,r.jsx)(Q.Z,{children:"Members"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsxs)(J.Z,{children:[t.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.team_alias})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.description||"No description available"})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"flex flex-col",children:e.models&&0!==e.models.length?e.models.map((e,l)=>(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,r.jsx)(ea.Z,{size:"xs",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{size:"xs",variant:"secondary",onClick:()=>n(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(b.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};let lf=(e,l)=>{let s=[];return e&&e.models.length>0?(console.log("organization.models: ".concat(e.models)),s=e.models):s=l,D(s,l)};var lZ=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:n,userRole:o,organizations:d}=e,[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(null),[w,N]=(0,i.useState)(null);(0,i.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&p(t,n,o,u,a),eO()},[c]);let[A]=k.Z.useForm(),[E]=k.Z.useForm(),{Title:D,Paragraph:L}=eS.default,[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(!1),[es,et]=(0,i.useState)(!1),[em,ex]=(0,i.useState)(!1),[ep,ej]=(0,i.useState)(!1),[eg,ef]=(0,i.useState)([]),[eZ,e_]=(0,i.useState)(!1),[ey,ev]=(0,i.useState)(null),[eb,ew]=(0,i.useState)([]),[eN,ek]=(0,i.useState)({}),[eI,eC]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("currentOrgForCreateTeam: ".concat(w));let e=lf(w,eg);console.log("models: ".concat(e)),ew(e),A.setFieldValue("models",[])},[w,eg]),(0,i.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,x.t3)(t)).guardrails.map(e=>e.guardrail_name);eC(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let eA=async e=>{ev(e),e_(!0)},eP=async()=>{if(null!=ey&&null!=l&&null!=t){try{await (0,x.rs)(t,ey),p(t,n,o,u,a)}catch(e){console.error("Error deleting the team:",e)}e_(!1),ev(null)}};(0,i.useEffect)(()=>{(async()=>{try{if(null===n||null===o||null===t)return;let e=await T(n,o,t);e&&ef(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,n,o,l]);let eE=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,i=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],n=(null==e?void 0:e.organization_id)||(null==u?void 0:u.organization_id);if(""===n||"string"!=typeof n?e.organization_id=null:e.organization_id=n.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,i.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));I.ZP.info("Creating Team");let o=await (0,x.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),I.ZP.success("Team created"),et(!1)}}catch(e){console.error("Error creating the team:",e),I.ZP.error("Error creating the team: "+e,20)}},eO=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:W?(0,r.jsx)(e0,{teamId:W,onClose:()=>{H(null),el(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===W)),is_proxy_admin:"Admin"==o,userModels:eg,editTeam:G}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Your Teams"}),(0,r.jsx)(ei.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:eO})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(b.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-hidden overflow-y-auto max-h-[50vh]",children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Team ID"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Organization"}),(0,r.jsx)(Q.Z,{children:"Info"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.filter(e=>!u||e.organization_id===u.organization_id).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{H(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!==e.max_budget&&void 0!==e.max_budget?e.max_budget:"No limit"}),(0,r.jsx)($.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)($.Z,{children:e.organization_id}),(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].keys&&eN[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].members_with_roles&&eN[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)($.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{H(e.team_id),el(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>eA(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),eZ&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eP,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{e_(!1),ev(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>et(!0),children:"+ Create New Team"}),(0,r.jsx)(C.Z,{title:"Create Team",visible:es,width:800,footer:null,onOk:()=>{et(!1),A.resetFields()},onCancel:()=>{et(!1),A.resetFields()},children:(0,r.jsxs)(k.Z,{form:A,onFinish:eE,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Organization",name:"organization_id",initialValue:u?u.organization_id:null,className:"mt-8",children:(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{A.setFieldValue("organization_id",e),N((null==d?void 0:d.find(l=>l.organization_id===e))||null)},filterOption:(e,l)=>{var s;return!!l&&((null===(s=l.children)||void 0===s?void 0:s.toString())||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==d?void 0:d.map(e=>(0,r.jsxs)(S.default.Option,{value:e.organization_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.organization_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.organization_id,")"]})]},e.organization_id))})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected organization has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),eb.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Additional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",help:"ID of the team you want to create. If not provided, it will be generated automatically.",children:(0,r.jsx)(Z.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eI.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lg,{accessToken:t,userID:n})})]})]})})},l_=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:n,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,i.useState)(null),[h,p]=(0,i.useState)(!0),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(!1),[y,v]=(0,i.useState)(!1),[N,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),D=n||o,L=async()=>{try{if(p(!0),!a)return;let e=await (0,x.t$)(a,s);u(e)}catch(e){I.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{p(!1)}};(0,i.useEffect)(()=>{L()},[s,a]);let F=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.vh)(a,s,l),I.ZP.success("Organization member added successfully"),v(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to add organization member"),console.error("Error adding organization member:",e)}},R=async e=>{try{if(!a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.LY)(a,s,l),I.ZP.success("Organization member updated successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,x.Sb)(a,s,e.user_id),I.ZP.success("Organization member deleted successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to delete organization member"),console.error("Error deleting organization member:",e)}},U=async e=>{try{if(!a)return;let l={organization_id:s,organization_alias:e.organization_alias,models:e.models,litellm_budget_table:{tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration}};if(!(await fetch("/organization/update",{method:"POST",headers:{Authorization:"Bearer ".concat(a),"Content-Type":"application/json"},body:JSON.stringify(l)})).ok)throw Error("Failed to update organization");I.ZP.success("Organization settings updated successfully"),_(!1),L()}catch(e){I.ZP.error("Failed to update organization settings"),console.error("Error updating organization:",e)}};return h?(0,r.jsx)("div",{className:"p-4",children:"Loading..."}):m?(0,r.jsxs)("div",{className:"w-full h-screen p-4 bg-white",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:m.organization_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===m.litellm_budget_table.max_budget?"Unlimited":"$".concat(m.litellm_budget_table.max_budget)]}),m.litellm_budget_table.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[75vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Created At"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)($.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{T({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),C(!0)}}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(f.Z,{onClick:()=>{v(!0)},children:"Add Member"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Organization Settings"}),D&&!Z&&(0,r.jsx)(f.Z,{onClick:()=>_(!0),children:"Edit Settings"})]}),Z?(0,r.jsxs)(k.Z,{form:j,onFinish:U,initialValues:{organization_alias:m.organization_alias,models:m.models,tpm_limit:m.litellm_budget_table.tpm_limit,rpm_limit:m.litellm_budget_table.rpm_limit,max_budget:m.litellm_budget_table.max_budget,budget_duration:m.litellm_budget_table.budget_duration},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>_(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization ID"}),(0,r.jsx)("div",{className:"font-mono",children:m.organization_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(m.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==m.litellm_budget_table.max_budget?"$".concat(m.litellm_budget_table.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",m.litellm_budget_table.budget_duration||"Never"]})]})]})]})})]})]}),(0,r.jsx)(eX,{isVisible:y,onCancel:()=>v(!1),onSubmit:F,accessToken:a,title:"Add Organization Member",roles:[{label:"org_admin",value:"org_admin",description:"Can add and remove members, and change their roles."},{label:"internal_user",value:"internal_user",description:"Can view/create keys for themselves within organization."},{label:"internal_user_viewer",value:"internal_user_viewer",description:"Can only view their keys within organization."}],defaultRole:"internal_user"}),(0,r.jsx)(eY,{visible:N,onCancel:()=>C(!1),onSubmit:R,initialData:A,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Org Admin",value:"org_admin"},{label:"Internal User",value:"internal_user"},{label:"Internal User Viewer",value:"internal_user_viewer"}]}})]}):(0,r.jsx)("div",{className:"p-4",children:"Organization not found"})};let ly=async(e,l)=>{l(await (0,x.r6)(e))};var lv=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:n,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,p]=(0,i.useState)(null),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(!1),[N,A]=(0,i.useState)(null),[E,O]=(0,i.useState)(!1),[T]=k.Z.useForm();(0,i.useEffect)(()=>{0===l.length&&a&&ly(a,m)},[l,a]);let D=e=>{e&&(A(e),w(!0))},L=async()=>{if(N&&a)try{await (0,x.cq)(a,N),I.ZP.success("Organization deleted successfully"),w(!1),A(null),ly(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,x.H1)(a,e),O(!1),T.resetFields(),ly(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(l_,{organizationId:h,onClose:()=>{p(null),y(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:_}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsx)("div",{className:"flex",children:(0,r.jsx)(ei.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[n&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",n]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:o})]})]}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(b.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Organization ID"}),(0,r.jsx)(Q.Z,{children:"Organization Name"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(Q.Z,{children:"Info"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>{var l,t,a,i,n,o,d,c,m;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>p(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{children:e.organization_alias}),(0,r.jsx)($.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{children:e.spend}),(0,r.jsx)($.Z,{children:(null===(t=e.litellm_budget_table)||void 0===t?void 0:t.max_budget)!==null&&(null===(a=e.litellm_budget_table)||void 0===a?void 0:a.max_budget)!==void 0?null===(i=e.litellm_budget_table)||void 0===i?void 0:i.max_budget:"No limit"}),(0,r.jsx)($.Z,{children:Array.isArray(e.models)&&(0,r.jsx)("div",{className:"flex flex-col",children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)},l))})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["TPM: ",(null===(n=e.litellm_budget_table)||void 0===n?void 0:n.tpm_limit)?null===(o=e.litellm_budget_table)||void 0===o?void 0:o.tpm_limit:"Unlimited",(0,r.jsx)("br",{}),"RPM: ",(null===(d=e.litellm_budget_table)||void 0===d?void 0:d.rpm_limit)?null===(c=e.litellm_budget_table)||void 0===c?void 0:c.rpm_limit:"Unlimited"]})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)($.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{p(e.organization_id),y(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>D(e.organization_id),icon:eh.Z,size:"sm"})]})})]},e.organization_id)}):null})]})})}),("Admin"===s||"Org Admin"===s)&&(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>O(!0),children:"+ Create New Organization"}),(0,r.jsx)(C.Z,{title:"Create Organization",visible:E,width:800,footer:null,onCancel:()=>{O(!1),T.resetFields()},children:(0,r.jsxs)(k.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(f.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),v?(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Organization"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this organization?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{w(!1),A(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(b.Z,{children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,r.jsx)("a",{href:"https://litellm.ai/pricing",target:"_blank",rel:"noopener noreferrer",children:"here"}),"."]})})};let lb=()=>{let[e,l]=(0,i.useState)("http://localhost:4000");return(0,i.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lw=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=k.Z.useForm(),[d]=k.Z.useForm(),{Title:c,Paragraph:m}=eS.default,[u,h]=(0,i.useState)(""),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(!1),[w,N]=(0,i.useState)(!1),[S,A]=(0,i.useState)(!1),[P,T]=(0,i.useState)(!1),[M,D]=(0,i.useState)(!1),[L,F]=(0,i.useState)(!1),[R,z]=(0,i.useState)(!1),[U,V]=(0,i.useState)(!1),[q,B]=(0,i.useState)(!1),[K,W]=(0,i.useState)([]),[H,G]=(0,i.useState)(null);(0,n.useRouter)();let[el,es]=(0,i.useState)(null);console.log=function(){};let et=lb(),ea="All IP Addresses Allowed",ei=et;ei+="/fallback/login";let en=async()=>{try{if(!0!==a){I.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,x.PT)(s);W(e&&e.length>0?e:[ea])}else W([ea])}catch(e){console.error("Error fetching allowed IPs:",e),I.ZP.error("Failed to fetch allowed IPs ".concat(e)),W([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,x.eH)(s,e.ip);let l=await (0,x.PT)(s);W(l),I.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),I.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{G(e),B(!0)},ec=async()=>{if(H&&s)try{await (0,x.$I)(s,H);let e=await (0,x.PT)(s);W(e.length>0?e:[ea]),I.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),I.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),G(null)}},em=()=>{F(!1)};(0,i.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,x.Xd)(s,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let t=l.users;console.log("proxy viewers response: ".concat(t)),t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(t));let a=(await (0,x.Xd)(s,"proxy_admin")).users;a.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(a)),console.log("combinedList: ".concat(e)),j(e),es(await (0,x.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=p){var l;I.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,x.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,x.XO)(s,a).then(e=>{_(e),v(!0)}),console.log("response for team create call: ".concat(t));let r=p.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===t.user_id));console.log("foundIndex: ".concat(r)),-1==r&&(console.log("updates admin with new user"),p.push(t),j(p)),o.resetFields(),A(!1)}}catch(e){console.error("Error creating the key:",e)}},eh=async e=>{if(null==s)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,x.K_)(s,l)};return console.log("admins: ".concat(null==p?void 0:p.length)),(0,r.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,r.jsx)(c,{level:4,children:"Admin Access "}),(0,r.jsx)(m,{children:"Go to 'Internal Users' page to add other admins."}),(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(c,{level:4,children:" ✨ Security Settings"}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:()=>!0===a?D(!0):I.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:en,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(C.Z,{title:"Add SSO",visible:M,width:800,footer:null,onOk:()=>{D(!1),o.resetFields()},onCancel:()=>{D(!1),o.resetFields()},children:(0,r.jsxs)(k.Z,{form:o,onFinish:e=>{eu(e),eh(e),D(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,r.jsx)(E.Z.Password,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,r.jsx)(E.Z.Password,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(C.Z,{title:"SSO Setup Instructions",visible:L,width:800,footer:null,onOk:em,onCancel:()=>{F(!1)},children:[(0,r.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(C.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(f.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"IP Address"}),(0,r.jsx)(Q.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(J.Z,{children:K.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e}),(0,r.jsx)($.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(f.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(C.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(k.Z,{onFinish:eo,children:[(0,r.jsx)(k.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,r.jsx)(E.Z,{placeholder:"Enter IP address"})}),(0,r.jsx)(k.Z.Item,{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(C.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(f.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",H,"?"]})})]}),(0,r.jsxs)(eW.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:ei,target:"_blank",children:[(0,r.jsx)("b",{children:ei})," "]})]})]})]})},lN=s(92858),lS=s(44643),lk=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:i}=e,[n]=k.Z.useForm();return(0,r.jsxs)(k.Z,{form:n,onFinish:()=>{console.log("INSIDE ONFINISH");let e=n.getFieldsValue(),l=Object.entries(e).every(e=>{let[l,s]=e;return"boolean"!=typeof s&&(""===s||null==s)});console.log("formData: ".concat(JSON.stringify(e),", isEmpty: ").concat(l)),l?console.log("Some form fields are empty."):a(e)},labelAlign:"left",children:[l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{align:"center",children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?i?(0,r.jsx)(k.Z.Item,{name:e.field_name,children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lN.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,r.jsx)(k.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lN.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),n.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lS.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lI=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(0,x.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lk,{alertingSettings:t,handleInputChange:(e,l)=>{let s=t.map(s=>s.field_name===e?{...s,field_value:l}:s);console.log("updatedSettings: ".concat(JSON.stringify(s))),a(s)},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);a(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||(console.log("formValues: ".concat(e)),null==e||void 0==e))return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let a={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(a)));let{slack_alerting:r,...i}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(i)));try{(0,x.jA)(l,"alerting_args",i),"boolean"==typeof r&&(!0==r?(0,x.jA)(l,"alerting",["slack"]):(0,x.jA)(l,"alerting",[])),I.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lC=s(86582);let{Title:lA,Paragraph:lP}=eS.default;console.log=function(){};var lE=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[n,o]=(0,i.useState)([]),[d,c]=(0,i.useState)([]),[m,u]=(0,i.useState)(!1),[h]=k.Z.useForm(),[p,j]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,w]=(0,i.useState)(""),[N,A]=(0,i.useState)({}),[P,E]=(0,i.useState)([]),[T,M]=(0,i.useState)(!1),[D,L]=(0,i.useState)([]),[F,R]=(0,i.useState)(null),[z,U]=(0,i.useState)([]),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),W=e=>{P.includes(e)?E(P.filter(l=>l!==e)):E([...P,e])},H={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,i.useEffect)(()=>{l&&s&&t&&(0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),L(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),E(e.active_alerts),w(s),A(e.alerts_to_webhook)}c(l)})},[l,s,t]);let G=e=>P&&P.includes(e),el=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));a&&a.value&&(e[s]=null==a?void 0:a.value)})}),console.log("updatedVariables",e);try{(0,x.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Email settings updated successfully")},es=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,x.K_)(l,{environment_variables:s}),I.ZP.success("Callback added successfully"),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},ea=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,x.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),I.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),j(e.litellm_callback_name),console.log("all callbacks",D),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(n)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(lA,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(g.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)(Q.Z,{children:"Callback Name"})})}),(0,r.jsx)(J.Z,{children:n.map((e,s)=>(0,r.jsxs)(ee.Z,{className:"flex justify-between",children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.name})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>M(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(b.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,r.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(H).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lN.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)}):(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,r.jsx)(lN.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:N&&N[s]?N[s]:v})})]},l)})})]}),(0,r.jsx)(f.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(H).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let r=(null==a?void 0:a.value)||"";console.log("newWebhookValue",r),e[s]=r}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:P}};console.log("payload",s);try{(0,x.K_)(l,s)}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lI,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(lA,{level:4,children:"Email Settings"}),(0,r.jsxs)(b.Z,{children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,r.jsx)("br",{})]}),(0,r.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,r.jsx)($.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(g.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,r.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,r.jsxs)("div",{children:[(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,r.jsxs)(b.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-2",children:l}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,r.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,r.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(C.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>M(!1),footer:null,children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,r.jsx)(k.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lC.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(S.default,{onChange:e=>{let l=D[e];l&&(console.log(l.ui_callback_name),em(l))},children:D&&Object.values(D).map(e=>(0,r.jsx)(et.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),z&&z.map(e=>(0,r.jsx)(lC.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,r.jsx)(Z.Z,{type:"password"})},e)),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(C.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(k.Z,{form:h,onFinish:es,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(r.Fragment,{children:B&&B.variables&&Object.entries(B.variables).map(e=>{let[l,s]=e;return(0,r.jsx)(lC.Z,{label:l,name:l,children:(0,r.jsx)(Z.Z,{type:"password",defaultValue:s})},l)})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lO=s(92414),lT=s(46030);let{Option:lM}=S.default;var lD=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(C.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),n.resetFields()},onCancel:()=>{d(!1),n.resetFields()},children:(0,r.jsxs)(k.Z,{form:n,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,i=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:i};console.log(o);try{(0,x.K_)(s,{router_settings:o}),a(o)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully"),d(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,r.jsx)(es.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,r.jsx)(k.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lO.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lT.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lL=s(33619);async function lF(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lL.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});I.ZP.success((0,r.jsxs)("span",{children:["Test model=",(0,r.jsx)("strong",{children:e}),", received model=",(0,r.jsx)("strong",{children:l.model}),". See"," ",(0,r.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lR={ttl:3600,lowest_latency_buffer:0},lz=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,r.jsxs)(_.Z,{children:[(0,r.jsx)(v.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,r.jsx)(y.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(b.Z,{children:"No specific settings"})})]})};var lU=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)({}),[d,c]=(0,i.useState)({}),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[_]=k.Z.useForm(),[y,v]=(0,i.useState)(null),[N,S]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,i.useEffect)(()=>{l&&s&&t&&((0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e);let l=e.router_settings;"model_group_retry_policy"in l&&delete l.model_group_retry_policy,o(l)}),(0,x.YU)(l).then(e=>{u(e)}))},[l,s,t]);let O=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(n.fallbacks));let s=n.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...n,fallbacks:s};try{await (0,x.K_)(l,{router_settings:t}),o(t),I.ZP.success("Router settings updated successfully")}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}},T=(e,l)=>{u(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},M=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,x.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,x.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(s)}catch(e){}},L=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,x.K_)(l,{router_settings:s})}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(w.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(n).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,r.jsx)($.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:S,children:[(0,r.jsx)(et.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,r.jsx)(et.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,r.jsx)(et.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,r.jsx)(lz,{selectedStrategy:N,strategyArgs:n&&n.routing_strategy_args&&Object.keys(n.routing_strategy_args).length>0?n.routing_strategy_args:lR,paramExplanation:E})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>L(n),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Model Name"}),(0,r.jsx)(Q.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(J.Z,{children:n.fallbacks&&n.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:t}),(0,r.jsx)($.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{onClick:()=>lF(t,l),children:"Test Fallback"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lD,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:n,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"}),(0,r.jsx)(Q.Z,{children:"Status"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,r.jsx)($.Z,{children:"Integer"==e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lS.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(f.Z,{onClick:()=>M(e.field_name,l),children:"Update"}),(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lV=s(93142),lq=s(45246),lB=s(96473),lK=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,i.useState)(Object.entries(l)),n=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let i=[...t];i[e]=[l,r],a(i),null==s||s(Object.fromEntries(i))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lV.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,r.jsx)(Z.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,r.jsx)(Z.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,r.jsx)(lq.Z,{onClick:()=>n(l)})]},l)}),(0,r.jsx)(O.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lB.Z,{}),children:"Add Header"})]})};let{Option:lW}=S.default;var lH=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=k.Z.useForm(),[n,o]=(0,i.useState)(!1),[d,c]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(C.Z,{title:"Add Pass-Through Endpoint",visible:n,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(k.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,x.Vt)(l,e),s(r)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Target",name:"target",rules:[{required:!0,message:"The URL to which requests for this path should be forwarded."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Headers",name:"headers",rules:[{required:!0,message:"Key-value pairs of headers to be forwarded with the request. You can set any key value pair here and it will be forwarded to your target endpoint"}],help:"required",children:(0,r.jsx)(lK,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lG=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&s&&t&&(0,x.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,x.EG)(l,e);let s=n.filter(l=>l.path!==e);o(s),I.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Path"}),(0,r.jsx)(Q.Z,{children:"Target"}),(0,r.jsx)(Q.Z,{children:"Headers"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:n.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.path})}),(0,r.jsx)($.Z,{children:e.target}),(0,r.jsx)($.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lH,{accessToken:l,setPassThroughItems:o,passThroughItems:n})]})})}):null},lY=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[i]=k.Z.useForm(),n=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call");let l=await (0,x.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),I.ZP.success("API Key Created"),i.resetFields()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),i.resetFields()},onCancel:()=>{t(!1),i.resetFields()},children:(0,r.jsxs)(k.Z,{form:i,onFinish:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lJ=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:n,handleUpdateCall:o}=e;console.log("existingBudget",n);let[d]=k.Z.useForm();(0,i.useEffect)(()=>{d.setFieldsValue(n)},[n,d]);let c=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call"),t(!0);let l=await (0,x.qI)(s,e);a(e=>e?[...e,l]:[l]),I.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(k.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:n,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},l$=s(17906),lX=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)(!1),[a,n]=(0,i.useState)(!1),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&(0,x.O3)(l).then(e=>{m(e)})},[l]);let u=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),n(!0))},h=async(e,s)=>{if(null==l)return;I.ZP.info("Request made"),await (0,x.NV)(l,e);let t=[...c];t.splice(s,1),m(t),I.ZP.success("Budget Deleted.")},p=async()=>{null!=l&&(0,x.O3)(l).then(e=>{m(e)})};return(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsx)(f.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lY,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lJ,{accessToken:l,isModalVisible:a,setIsModalVisible:n,setBudgetList:m,existingBudget:o,handleUpdateCall:p}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Budget ID"}),(0,r.jsx)(Q.Z,{children:"Max Budget"}),(0,r.jsx)(Q.Z,{children:"TPM"}),(0,r.jsx)(Q.Z,{children:"RPM"})]})}),(0,r.jsx)(J.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.budget_id}),(0,r.jsx)($.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)($.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)($.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,r.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="",\n api_key=""\n)\n\ncompletion = client.chat.completions.create(\n model="gpt-3.5-turbo",\n messages=[\n {"role": "system", "content": "You are a helpful assistant."},\n {"role": "user", "content": "Hello!"}\n ],\n user="my-customer-id"\n)\n\nprint(completion.choices[0].message)'})})]})]})]})]})},lQ=s(77398),l0=s.n(lQ),l1=s(20016);async function l2(e){try{let l=await fetch("http://ip-api.com/json/".concat(e)),s=await l.json();console.log("ip lookup data",s);let t=s.countryCode?s.countryCode.toUpperCase().split("").map(e=>String.fromCodePoint(e.charCodeAt(0)+127397)).join(""):"";return s.country?"".concat(t," ").concat(s.country):"Unknown"}catch(e){return console.error("Error looking up IP:",e),"Unknown"}}let l4=e=>{let{ipAddress:l}=e,[s,t]=i.useState("-");return i.useEffect(()=>{if(!l)return;let e=!0;return l2(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},l5=e=>{try{return new Date(e).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).replace(",","")}catch(e){return"Error converting time"}},l3=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:l5(l)})},l6=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):"●"}},{header:"Time",accessorKey:"startTime",cell:e=>(0,r.jsx)(l3,{utcTime:e.getValue()})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,r.jsx)(R.Z,{title:String(e.getValue()||""),children:(0,r.jsx)("span",{className:"font-mono text-xs max-w-[100px] truncate block",children:String(e.getValue()||"")})})},{header:"Cost",accessorKey:"spend",cell:e=>(0,r.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Country",accessorKey:"requester_ip_address",cell:e=>(0,r.jsx)(l4,{ipAddress:e.getValue()})},{header:"Team Name",accessorKey:"metadata.user_api_key_team_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Key Hash",accessorKey:"metadata.user_api_key",cell:e=>{let l=String(e.getValue()||"-");return(0,r.jsx)(R.Z,{title:l,children:(0,r.jsxs)("span",{className:"font-mono",children:[l.slice(0,5),"..."]})})}},{header:"Key Name",accessorKey:"metadata.user_api_key_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Model",accessorKey:"model",cell:e=>{let l=e.row.original.custom_llm_provider,s=String(e.getValue()||"");return(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[l&&(0,r.jsx)("img",{src:eP(l).logo,alt:"",className:"w-4 h-4",onError:e=>{e.target.style.display="none"}}),(0,r.jsx)(R.Z,{title:s,children:(0,r.jsx)("span",{className:"max-w-[100px] truncate",children:s})})]})}},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,r.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,r.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"Internal User",accessorKey:"user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"End User",accessorKey:"end_user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();if(!l||0===Object.keys(l).length)return"-";let s=Object.entries(l),t=s[0],a=s.slice(1);return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:(0,r.jsx)(R.Z,{title:(0,r.jsx)("div",{className:"flex flex-col gap-1",children:s.map(e=>{let[l,s]=e;return(0,r.jsxs)("span",{children:[l,": ",String(s)]},l)})}),children:(0,r.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[t[0],": ",String(t[1]),a.length>0&&" +".concat(a.length)]})})})}}],l8=async(e,l,s,t)=>{console.log("prefetchLogDetails called with",e.length,"logs");let a=e.map(e=>{if(e.request_id)return console.log("Prefetching details for request_id:",e.request_id),t.prefetchQuery({queryKey:["logDetails",e.request_id,l],queryFn:async()=>{console.log("Fetching details for",e.request_id);let t=await (0,x.qk)(s,e.request_id,l);return console.log("Received details for",e.request_id,":",t?"success":"failed"),t},staleTime:6e5,gcTime:6e5})});try{let e=await Promise.all(a);return console.log("All prefetch promises completed:",e.length),e}catch(e){throw console.error("Error in prefetchLogDetails:",e),e}};function l7(e){var l,s,t;let{accessToken:a,token:n,userRole:o,userID:d}=e,[m,u]=(0,i.useState)(""),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)(!1),[f,Z]=(0,i.useState)(1),[_]=(0,i.useState)(50),y=(0,i.useRef)(null),v=(0,i.useRef)(null),b=(0,i.useRef)(null),[w,N]=(0,i.useState)(l0()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[S,k]=(0,i.useState)(l0()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,i.useState)(!1),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(""),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(""),[F,R]=(0,i.useState)(""),[z,U]=(0,i.useState)("Team ID"),V=(0,c.NL)();(0,i.useEffect)(()=>{function e(e){y.current&&!y.current.contains(e.target)&&g(!1),v.current&&!v.current.contains(e.target)&&p(!1),b.current&&!b.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,l1.a)({queryKey:["logs","table",f,_,w,S,D,F],queryFn:async()=>{if(!a||!n||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:_,total_pages:0};let e=l0()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?l0()(S).utc().format("YYYY-MM-DD HH:mm:ss"):l0()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,x.h3)(a,F||void 0,D||void 0,void 0,e,l,f,_);return await l8(s.data,e,a,V),s.data=s.data.map(l=>{let s=V.getQueryData(["logDetails",l.request_id,e]);return(null==s?void 0:s.messages)&&(null==s?void 0:s.response)&&(l.messages=s.messages,l.response=s.response),l}),s},enabled:!!a&&!!n&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!n||!o||!d)return console.log("got None values for one of accessToken, token, userRole, userID"),null;let B=(null===(s=q.data)||void 0===s?void 0:null===(l=s.data)||void 0===l?void 0:l.filter(e=>!m||e.request_id.includes(m)||e.model.includes(m)||e.user&&e.user.includes(m)))||[],K=()=>{if(I)return"".concat(l0()(w).format("MMM D, h:mm A")," - ").concat(l0()(S).format("MMM D, h:mm A"));let e=l0()(),l=l0()(w),s=e.diff(l,"minutes");if(s<=15)return"Last 15 Minutes";if(s<=60)return"Last Hour";let t=e.diff(l,"hours");return t<=4?"Last 4 Hours":t<=24?"Last 24 Hours":t<=168?"Last 7 Days":"".concat(l.format("MMM D")," - ").concat(e.format("MMM D"))};return(0,r.jsxs)("div",{className:"w-full p-6",children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,r.jsx)("h1",{className:"text-xl font-semibold",children:"Request Logs"})}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"border-b px-6 py-4",children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between space-y-4 md:space-y-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("div",{className:"relative w-64",children:[(0,r.jsx)("input",{type:"text",placeholder:"Search by Request ID",className:"w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:m,onChange:e=>u(e.target.value)}),(0,r.jsx)("svg",{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),(0,r.jsxs)("div",{className:"relative",ref:v,children:[(0,r.jsxs)("button",{className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",onClick:()=>p(!h),children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),"Filter"]}),h&&(0,r.jsx)("div",{className:"absolute left-0 mt-2 w-[500px] bg-white rounded-lg shadow-lg border p-4 z-50",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>g(!j),className:"px-3 py-1.5 border rounded-md bg-white text-sm min-w-[160px] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-left flex justify-between items-center",children:[z,(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),j&&(0,r.jsx)("div",{className:"absolute left-0 mt-1 w-[160px] bg-white border rounded-md shadow-lg z-50",children:["Team ID","Key Hash"].map(e=>(0,r.jsxs)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 ".concat(z===e?"bg-blue-50 text-blue-600":""),onClick:()=>{U(e),g(!1),"Team ID"===e?M(""):O("")},children:[z===e&&(0,r.jsx)("svg",{className:"h-4 w-4 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e]},e))})]}),(0,r.jsx)("input",{type:"text",placeholder:"Enter value...",className:"px-3 py-1.5 border rounded-md text-sm flex-1 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:"Team ID"===z?E:T,onChange:e=>{"Team ID"===z?O(e.target.value):M(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{O(""),M("")},children:(0,r.jsx)("span",{className:"text-gray-500",children:"\xd7"})})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50",onClick:()=>{O(""),M(""),p(!1)},children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>{L(E),R(T),Z(1),p(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsxs)("button",{onClick:()=>P(!A),className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),K()]}),A&&(0,r.jsx)("div",{className:"absolute right-0 mt-2 w-64 bg-white rounded-lg shadow-lg border p-2 z-50",children:(0,r.jsxs)("div",{className:"space-y-1",children:[[{label:"Last 15 Minutes",value:15,unit:"minutes"},{label:"Last Hour",value:1,unit:"hours"},{label:"Last 4 Hours",value:4,unit:"hours"},{label:"Last 24 Hours",value:24,unit:"hours"},{label:"Last 7 Days",value:7,unit:"days"}].map(e=>(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(K()===e.label?"bg-blue-50 text-blue-600":""),onClick:()=>{k(l0()().format("YYYY-MM-DDTHH:mm")),N(l0()().subtract(e.value,e.unit).format("YYYY-MM-DDTHH:mm")),P(!1),C(!1)},children:e.label},e.label)),(0,r.jsx)("div",{className:"border-t my-2"}),(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(I?"bg-blue-50 text-blue-600":""),onClick:()=>C(!I),children:"Custom Range"})]})})]}),(0,r.jsxs)("button",{onClick:()=>{q.refetch()},className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",title:"Refresh data",children:[(0,r.jsx)("svg",{className:"w-4 h-4 ".concat(q.isFetching?"animate-spin":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,r.jsx)("span",{children:"Refresh"})]})]}),I&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:w,onChange:e=>{N(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})}),(0,r.jsx)("span",{className:"text-gray-500",children:"to"}),(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:S,onChange:e=>{k(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Showing"," ",q.isLoading?"...":q.data?(f-1)*_+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*_,q.data.total):0," ","of"," ",q.isLoading?"...":q.data?q.data.total:0," ","results"]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",q.isLoading?"...":f," of"," ",q.isLoading?"...":q.data?q.data.total_pages:1]}),(0,r.jsx)("button",{onClick:()=>Z(e=>Math.max(1,e-1)),disabled:q.isLoading||1===f,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>Z(e=>{var l;return Math.min((null===(l=q.data)||void 0===l?void 0:l.total_pages)||1,e+1)}),disabled:q.isLoading||f===((null===(t=q.data)||void 0===t?void 0:t.total_pages)||1),className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]})}),(0,r.jsx)(el,{columns:l6,data:B,renderSubComponent:l9,getRowCanExpand:()=>!0})]})]})}function l9(e){var l,s;let{row:t}=e,a=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,r.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium ",children:"Request Details"})}),(0,r.jsxs)("div",{className:"space-y-2 p-4 ",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request ID:"}),(0,r.jsx)("span",{children:t.original.request_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Key:"}),(0,r.jsx)("span",{children:t.original.api_key})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Team ID:"}),(0,r.jsx)("span",{children:t.original.team_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Model:"}),(0,r.jsx)("span",{children:t.original.model})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Base:"}),(0,r.jsx)("span",{children:t.original.api_base})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Call Type:"}),(0,r.jsx)("span",{children:t.original.call_type})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Spend:"}),(0,r.jsx)("span",{children:t.original.spend})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Total Tokens:"}),(0,r.jsx)("span",{children:t.original.total_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Prompt Tokens:"}),(0,r.jsx)("span",{children:t.original.prompt_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Completion Tokens:"}),(0,r.jsx)("span",{children:t.original.completion_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Start Time:"}),(0,r.jsx)("span",{children:t.original.startTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"End Time:"}),(0,r.jsx)("span",{children:t.original.endTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Hit:"}),(0,r.jsx)("span",{children:t.original.cache_hit})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Key:"}),(0,r.jsx)("span",{children:t.original.cache_key})]}),(null==t?void 0:null===(l=t.original)||void 0===l?void 0:l.requester_ip_address)&&(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request IP Address:"}),(0,r.jsx)("span",{children:null==t?void 0:null===(s=t.original)||void 0===s?void 0:s.requester_ip_address})]})]})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request Tags"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.request_tags),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.messages),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,r.jsx)("div",{})]}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.response),null,2)})]}),t.original.metadata&&Object.keys(t.original.metadata).length>0&&(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm ",children:JSON.stringify(t.original.metadata,null,2)})]})]})}var se=s(92699),sl=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,r.jsx)(b.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(ei.Z,{children:"LlamaIndex"}),(0,r.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="'.concat(s,'", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="').concat(s,'",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(l$.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="'.concat(s,'",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})})},ss=s(243),st=s(94263);async function sa(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lL.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await r.chat.completions.create({model:s,stream:!0,messages:e})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content,t.model)}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var sr=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:n}=e,[o,d]=(0,i.useState)(n?"custom":"session"),[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[p,_]=(0,i.useState)([]),[y,v]=(0,i.useState)(void 0),[w,N]=(0,i.useState)([]),k=(0,i.useRef)(null);(0,i.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,x.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),v(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,i.useEffect)(()=>{k.current&&setTimeout(()=>{var e;null===(e=k.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[p]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===u.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){I.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},i=[...p.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];_([...p,r]);try{y&&await sa(i,(e,l)=>C("assistant",e,l),y,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,r.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(ei.Z,{children:"Chat"})}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"API Key Source"}),(0,r.jsx)(S.default,{disabled:n,defaultValue:"session",style:{width:"100%"},onChange:e=>d(e),options:[{value:"session",label:"Current UI Session"},{value:"custom",label:"Virtual Key"}]}),"custom"===o&&(0,r.jsx)(Z.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:m,value:c})]}),(0,r.jsxs)(j.Z,{className:"mx-2",children:[(0,r.jsx)(b.Z,{children:"Select Model:"}),(0,r.jsx)(S.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),v(e)},options:w,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(f.Z,{onClick:()=>{_([]),I.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(Y.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{})})}),(0,r.jsxs)(J.Z,{children:[p.map((e,l)=>(0,r.jsx)(ee.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,r.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,r.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,r.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,r.jsx)(ss.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...i}=e,n=/language-(\w+)/.exec(t||"");return!s&&n?(0,r.jsx)(l$.Z,{style:st.Z,language:n[1],PreTag:"div",...i,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...i,children:a})}},children:e.content})})]})},l)),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{ref:k,style:{height:"1px"}})})})]})]}),(0,r.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,r.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,r.jsx)(Z.Z,{type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,r.jsx)(f.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},si=s(19226),sn=s(45937),so=s(92403),sd=s(28595),sc=s(68208),sm=s(9775),su=s(41361),sh=s(37527),sx=s(15883),sp=s(12660),sj=s(88009),sg=s(48231),sf=s(41169),sZ=s(44625),s_=s(57400),sy=s(55322);let{Sider:sv}=si.default,sb=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],sw=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(so.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(sd.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(sc.Z,{}),roles:sb},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(sm.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(su.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(sh.Z,{}),roles:sb},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(sx.Z,{}),roles:sb},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(sp.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sj.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sg.Z,{}),roles:sb},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sf.Z,{}),roles:sb,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(sZ.Z,{}),roles:sb},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(sh.Z,{}),roles:sb},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(s_.Z,{}),roles:sb}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(sy.Z,{}),roles:sb,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(sy.Z,{}),roles:sb},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(sp.Z,{}),roles:sb},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(sy.Z,{}),roles:sb},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(sy.Z,{}),roles:sb}]}];var sN=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=sw.find(l=>l.page===e);if(l)return l.key;for(let l of sw)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),i=sw.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(si.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sv,{theme:"light",width:220,children:(0,r.jsx)(sn.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:i.map(e=>{var s;return{key:e.key,icon:e.icon,label:e.label,children:null===(s=e.children)||void 0===s?void 0:s.map(e=>({key:e.key,icon:e.icon,label:e.label,onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}})),onClick:e.children?void 0:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}}})})})})},sS=s(96889);console.log=function(){};var sk=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:n,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,i.useState)(null!==a?a:0),[m,u]=(0,i.useState)(o?o.max_budget:null);(0,i.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(n);else{let e=!1;if(o.team_memberships)for(let s of o.team_memberships)s.user_id===l&&"max_budget"in s.litellm_budget_table&&null!==s.litellm_budget_table.max_budget&&(u(s.litellm_budget_table.max_budget),e=!0);e||u(o.max_budget)}}},[o,n]);let[h,p]=(0,i.useState)([]);(0,i.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,x.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,i.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",h),j=h):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=h);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,r.jsx)("div",{className:"flex items-center",children:(0,r.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,r.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})},sI=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sC=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sA=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:n,premiumUser:o}=e,d=new Date,[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)([]),[v,N]=(0,i.useState)([]),[S,k]=(0,i.useState)([]),[I,C]=(0,i.useState)([]),[A,P]=(0,i.useState)([]),[E,O]=(0,i.useState)([]),[T,M]=(0,i.useState)([]),[D,L]=(0,i.useState)({}),[F,R]=(0,i.useState)([]),[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(["all-tags"]),[B,K]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(0),ea=new Date(d.getFullYear(),d.getMonth(),1),em=new Date(d.getFullYear(),d.getMonth()+1,0),eu=ef(ea),eh=ef(em);function ex(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",n),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,x.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,i.useEffect)(()=>{eg(B.from,B.to)},[B,V]);let ej=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let a=await (0,x.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),y(a)},eg=async(e,s)=>{if(!e||!s||!l)return;let t=await ep();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),k((await (0,x.J$)(l,e.toISOString(),s.toISOString(),0===V.length?void 0:V)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ef(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}console.log("Start date is ".concat(eu)),console.log("End date is ".concat(eh));let eZ=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},e_=(e,l,s,t)=>{let a=[],r=new Date(l),i=e=>{if(e.includes("-"))return e;{let[l,s]=e.split(" ");return new Date(new Date().getFullYear(),new Date("".concat(l," 01 2024")).getMonth(),parseInt(s)).toISOString().split("T")[0]}},n=new Map(e.map(e=>{let l=i(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(n.has(e))a.push(n.get(e));else{let l={date:e,api_requests:0,total_tokens:0};t.forEach(e=>{l[e]||(l[e]=0)}),a.push(l)}r.setDate(r.getDate()+1)}return a},ey=async()=>{if(l)try{let e=await (0,x.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e,t,a,[]),i=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(i),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},ev=()=>eZ(()=>l&&s?(0,x.OU)(l,s,eu,eh):Promise.reject("No access token or token"),M,"Error fetching provider spend"),eb=async()=>{l&&await eZ(async()=>(await (0,x.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:Number(e.total_spend.toFixed(2))})),h,"Error fetching top keys")},ew=async()=>{l&&await eZ(async()=>(await (0,x.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),Z,"Error fetching top models")},eN=async()=>{l&&await eZ(async()=>{let e=await (0,x.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return N(e_(e.daily_spend,t,a,e.teams)),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:Number(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eS=()=>{l&&eZ(async()=>(await (0,x.X)(l)).tag_names,C,"Error fetching tag names")},ek=()=>{l&&eZ(()=>{var e,s;return(0,x.J$)(l,null===(e=B.from)||void 0===e?void 0:e.toISOString(),null===(s=B.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>k(e.spend_per_tag),"Error fetching top tags")},eC=()=>{l&&eZ(()=>(0,x.b1)(l,null,void 0,void 0),y,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,x.wd)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e.daily_data||[],t,a,["api_requests","total_tokens"]);L({...e,daily_data:r})}catch(e){console.error("Error fetching global activity:",e)}},eP=async()=>{if(l)try{let e=await (0,x.xA)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e.map(e=>({...e,daily_data:e_(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,i.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(H(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",W),ey(),ev(),eb(),ew(),eA(),eP(),sC(t)&&(eN(),eS(),ek(),eC()))}})()},[l,s,t,a,eu,eh]),null==W?void 0:W.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(b.Z,{className:"mt-4",children:["SpendLogs in DB has ",W.NUM_SPEND_LOGS_ROWS," rows.",(0,r.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,r.jsx)(f.Z,{className:"mt-4",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(ei.Z,{children:"All Up"}),sC(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ei.Z,{children:"Team Based Usage"}),(0,r.jsx)(ei.Z,{children:"Customer Usage"}),(0,r.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{})})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(ei.Z,{children:"Cost"}),(0,r.jsx)(ei.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(b.Z,{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content mb-2 mt-2 text-lg",children:["Project Spend ",new Date().toLocaleString("default",{month:"long"})," 1 - ",new Date(new Date().getFullYear(),new Date().getMonth()+1,0).getDate()]}),(0,r.jsx)(sk,{userID:a,userRole:t,accessToken:l,userSpend:G,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Monthly Spend"}),(0,r.jsx)(eU.Z,{data:c,index:"date",categories:["spend"],colors:["cyan"],valueFormatter:e=>"$ ".concat(e.toFixed(2)),yAxisWidth:100,tickGap:5})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top API Keys"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:u,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top Models"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:p,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sI.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend",colors:["cyan"],valueFormatter:e=>"$".concat(e.toFixed(2))})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Provider"}),(0,r.jsx)(Q.Z,{children:"Spend"})]})}),(0,r.jsx)(J.Z,{children:T.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.provider}),(0,r.jsx)($.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})})]})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"All Up"}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(D.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(D.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),(0,r.jsx)(r.Fragment,{children:F.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.model}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ex,onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ex,onValueChange:e=>console.log(e)})]})]})]},l))})]})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sS.Z,{data:E})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eU.Z,{className:"h-72",data:v,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,r.jsx)(j.Z,{numColSpan:2})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{ej(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==n?void 0:n.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{ej(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(Y.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Customer"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Total Events"})]})}),(0,r.jsx)(J.Z,{children:null==_?void 0:_.map((e,l)=>{var s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.end_user}),(0,r.jsx)($.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)($.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eF.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lO.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lT.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsx)(lT.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lO.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lT.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsxs)(et.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(b.Z,{children:["Get Started Tracking cost per tag ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,r.jsx)(eU.Z,{className:"h-72",data:S,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sP=e=>{if(e)return e.toISOString().split("T")[0]};function sE(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var sO=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:n}=e,[o,d]=(0,i.useState)([]),[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)("0"),[v,w]=(0,i.useState)("0"),[N,S]=(0,i.useState)("0"),[k,C]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,i.useState)(""),[E,O]=(0,i.useState)("");(0,i.useEffect)(()=>{l&&k&&((async()=>{Z(await (0,x.zg)(l,sP(k.from),sP(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),M=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let D=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,x.zg)(l,sP(e),sP(s))))};(0,i.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",p);let e=p;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),u.length>0&&(e=e.filter(e=>u.includes(e.model))),console.log("before processed data in cache dashboard",e);let l=0,s=0,t=0,a=e.reduce((e,a)=>{console.log("Processing item:",a),a.call_type||(console.log("Item has no call_type:",a),a.call_type="Unknown"),l+=(a.total_rows||0)-(a.cache_hit_true_rows||0),s+=a.cache_hit_true_rows||0,t+=a.cached_completion_tokens||0;let r=e.find(e=>e.name===a.call_type);return r?(r["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),r["Cache hit"]+=a.cache_hit_true_rows||0,r["Cached Completion Tokens"]+=a.cached_completion_tokens||0,r["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(sE(s)),w(sE(t));let r=s+l;r>0?S((s/r*100).toFixed(2)):S("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,p]);let L=async()=>{try{I.ZP.info("Running cache health check..."),O("");let e=await (0,x.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),O(e)}catch(e){console.error("Error running health check:",e),O("Error running health check")}};return(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-full w-full mt-2 mb-8",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Cache Analytics"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"Cache Health"})})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[A&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:()=>{P(new Date().toLocaleString())}})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(g.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lO.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lT.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lO.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:M.map(e=>(0,r.jsx)(lT.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eF.Z,{enableSelect:!0,value:k,onValueChange:e=>{C(e),D(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[N,"%"]})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:v})})]})]}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eU.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sE,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eU.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sE,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{className:"mt-4",children:[(0,r.jsx)(b.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(f.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),E&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(E,null,2)})]})})]})]})},sT=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(async()=>{try{let e=await (0,x.t3)(l);console.log("guardrails: ".concat(JSON.stringify(e))),t(e.guardrails)}catch(e){console.error("Error fetching guardrails:",e)}})()},[l]),(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsxs)(b.Z,{className:"mb-4",children:["Configured guardrails and their current status. Setup guardrails in config.yaml."," ",(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-700 underline",children:"Docs"})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Guardrail Name"}),(0,r.jsx)(Q.Z,{children:"Mode"}),(0,r.jsx)(Q.Z,{children:"Status"})]})}),(0,r.jsx)(J.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.guardrail_name}),(0,r.jsx)($.Z,{children:e.litellm_params.mode}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"inline-flex rounded-full px-2 py-1 text-xs font-medium\n ".concat(e.litellm_params.default_on?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:e.litellm_params.default_on?"Always On":"Per Request"})})]},l)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};let sM=new d.S;function sD(){let[e,l]=(0,i.useState)(""),[s,t]=(0,i.useState)(!1),[a,d]=(0,i.useState)(!1),[m,u]=(0,i.useState)(null),[j,g]=(0,i.useState)(null),[f,Z]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,b]=(0,i.useState)([]),[w,N]=(0,i.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[S,k]=(0,i.useState)(!0),I=(0,n.useSearchParams)(),[C,A]=(0,i.useState)({data:[]}),[P,E]=(0,i.useState)(null),O=I.get("userID"),T=I.get("invitation_id"),[M,D]=(0,i.useState)(()=>I.get("page")||"api-keys"),[L,F]=(0,i.useState)(null);return(0,i.useEffect)(()=>{E(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,i.useEffect)(()=>{if(!P)return;let e=(0,o.o)(P);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),F(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"org_admin":return"Org Admin";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&D("usage")}else console.log("User role not defined");e.user_email?u(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?k("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&t(e.premium_user),e.auth_header_name&&(0,x.K8)(e.auth_header_name)}},[P]),(0,i.useEffect)(()=>{L&&O&&e&&q(O,e,L,b),L&&O&&e&&p(L,O,e,null,g),L&&ly(L,y)},[L,O,e]),(0,r.jsx)(i.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sM,children:T?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(h,{userID:O,userRole:e,premiumUser:s,setProxySettings:N,proxySettings:w}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sN,{setPage:e=>{let l=new URLSearchParams(I);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),D(e)},userRole:e,defaultSelectedKey:M})}),"api-keys"==M?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):"models"==M?(0,r.jsx)(lm,{userID:O,userRole:e,token:P,keys:f,accessToken:L,modelData:C,setModelData:A,premiumUser:s,teams:j}):"llm-playground"==M?(0,r.jsx)(sr,{userID:O,userRole:e,token:P,accessToken:L,disabledPersonalKeyCreation:a}):"users"==M?(0,r.jsx)(lj,{userID:O,userRole:e,token:P,keys:f,teams:j,accessToken:L,setKeys:Z}):"teams"==M?(0,r.jsx)(lZ,{teams:j,setTeams:g,searchParams:I,accessToken:L,userID:O,userRole:e,organizations:_}):"organizations"==M?(0,r.jsx)(lv,{organizations:_,setOrganizations:y,userModels:v,accessToken:L,userRole:e,premiumUser:s}):"admin-panel"==M?(0,r.jsx)(lw,{setTeams:g,searchParams:I,accessToken:L,showSSOBanner:S,premiumUser:s}):"api_ref"==M?(0,r.jsx)(sl,{proxySettings:w}):"settings"==M?(0,r.jsx)(lE,{userID:O,userRole:e,accessToken:L,premiumUser:s}):"budgets"==M?(0,r.jsx)(lX,{accessToken:L}):"guardrails"==M?(0,r.jsx)(sT,{accessToken:L}):"general-settings"==M?(0,r.jsx)(lU,{userID:O,userRole:e,accessToken:L,modelData:C}):"model-hub"==M?(0,r.jsx)(se.Z,{accessToken:L,publicPage:!1,premiumUser:s}):"caching"==M?(0,r.jsx)(sO,{userID:O,userRole:e,token:P,accessToken:L,premiumUser:s}):"pass-through-settings"==M?(0,r.jsx)(lG,{userID:O,userRole:e,accessToken:L,modelData:C}):"logs"==M?(0,r.jsx)(l7,{userID:O,userRole:e,token:P,accessToken:L}):(0,r.jsx)(sA,{userID:O,userRole:e,token:P,accessToken:L,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,812,250,699,971,117,744],function(){return e(e.s=1900)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-e673cacf03d84561.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-e673cacf03d84561.js new file mode 100644 index 0000000000..89c78ea341 --- /dev/null +++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-e673cacf03d84561.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,15940))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),r=s(99376),i=s(20831),n=s(94789),o=s(12514),d=s(49804),c=s(67101),m=s(84264),u=s(26637),h=s(96761),x=s(84566),p=s(19250),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,r.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,_]=(0,a.useState)(null),[y,v]=(0,a.useState)(""),[b,w]=(0,a.useState)(""),[N,S]=(0,a.useState)(null),[k,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),S(t.user_id)})},[s]),(0,t.jsx)("div",{className:"mx-auto w-full max-w-md mt-10",children:(0,t.jsxs)(o.Z,{children:[(0,t.jsx)(h.Z,{className:"text-sm mb-5 text-center",children:"\uD83D\uDE85 LiteLLM"}),(0,t.jsx)(h.Z,{className:"text-xl",children:"Sign up"}),(0,t.jsx)(m.Z,{children:"Claim your user account to login to Admin UI."}),(0,t.jsx)(n.Z,{className:"mt-4",title:"SSO",icon:x.GH$,color:"sky",children:(0,t.jsxs)(c.Z,{numItems:2,className:"flex justify-between items-center",children:[(0,t.jsx)(d.Z,{children:"SSO is under the Enterprise Tirer."}),(0,t.jsx)(d.Z,{children:(0,t.jsx)(i.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=b,N&&s&&(0,p.m_)(Z,s,N,e.password).then(e=>{var l;let s="/ui/";s+="?userID="+((null===(l=e.data)||void 0===l?void 0:l.user_id)||e.user_id),document.cookie="token="+C,console.log("redirecting to:",s),window.location.href=s}))},children:[(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:b,defaultValue:b,className:"max-w-md"})}),(0,t.jsx)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},15940:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sM}});var t,a,r=s(57437),i=s(2265),n=s(99376),o=s(14474),d=s(90946),c=s(29827),m=s(27648),u=s(80795),h=e=>{let{userID:l,userRole:s,premiumUser:t,proxySettings:a}=e,i=(null==a?void 0:a.PROXY_LOGOUT_URL)||"",n=[{key:"1",label:(0,r.jsxs)("div",{className:"px-1 py-1",children:[(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Role: ",s]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["ID: ",l]}),(0,r.jsxs)("p",{className:"text-sm text-gray-600",children:["Premium User: ",String(t)]})]})},{key:"2",label:(0,r.jsx)("p",{className:"text-sm hover:text-gray-900",onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=i},children:"Logout"})}];return(0,r.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,r.jsx)("div",{className:"w-full",children:(0,r.jsxs)("div",{className:"flex items-center h-12 px-4",children:[(0,r.jsx)("div",{className:"flex items-center flex-shrink-0",children:(0,r.jsx)(m.default,{href:"/",className:"flex items-center",children:(0,r.jsx)("img",{src:"/get_image",alt:"LiteLLM Brand",className:"h-8 w-auto"})})}),(0,r.jsxs)("div",{className:"flex items-center space-x-5 ml-auto",children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:"Docs"}),(0,r.jsx)(u.Z,{menu:{items:n,style:{padding:"4px",marginTop:"4px"}},children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:["User",(0,r.jsx)("svg",{className:"ml-1 w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})},x=s(19250);let p=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,x.It)(e,(null==t?void 0:t.organization_id)||null,l):await (0,x.It)(e,(null==t?void 0:t.organization_id)||null),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),g=s(67101),f=s(20831),Z=s(26637),_=s(87452),y=s(88829),v=s(72208),b=s(84264),w=s(96761),N=s(29233),S=s(52787),k=s(13634),I=s(41021),C=s(51369),A=s(29967),P=s(20577),E=s(56632),O=s(73002);let T=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,x.So)(s,e,l,!0)).data.map(e=>e.id),a=[],r=[];return t.forEach(e=>{e.endsWith("/*")?a.push(e):r.push(e)}),[...a,...r]}}catch(e){console.error("Error fetching user models:",e)}},M=e=>{if(e.endsWith("/*")){let l=e.replace("/*","");return"All ".concat(l," models")}return e},D=(e,l)=>{let s=[],t=[];return console.log("teamModels",e),console.log("allModels",l),e.forEach(e=>{if(e.endsWith("/*")){let a=e.replace("/*",""),r=l.filter(e=>e.startsWith(a+"/"));t.push(...r),s.push(e)}else t.push(e)}),[...s,...t].filter((e,l,s)=>s.indexOf(e)===l)};var L=e=>{let{teams:l,value:s,onChange:t}=e;return(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",value:s,onChange:t,filterOption:(e,l)=>{var s,t,a;return!!l&&((null===(a=l.children)||void 0===a?void 0:null===(t=a[0])||void 0===t?void 0:null===(s=t.props)||void 0===s?void 0:s.children)||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==l?void 0:l.map(e=>(0,r.jsxs)(S.default.Option,{value:e.team_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.team_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.team_id,")"]})]},e.team_id))})},F=s(15424),R=s(75957);let{Option:z}=S.default,U=e=>{let l=[];if(console.log("data:",JSON.stringify(e)),e)for(let s of e)s.metadata&&s.metadata.tags&&l.push(...s.metadata.tags);let s=Array.from(new Set(l)).map(e=>({value:e,label:e}));return console.log("uniqueTags:",s),s},V=(e,l)=>D(e&&e.models.length>0?e.models.includes("all-proxy-models")?l:e.models:l,l),q=async(e,l,s,t)=>{try{if(null===e||null===l)return;if(null!==s){let a=(await (0,x.So)(s,e,l)).data.map(e=>e.id);console.log("available_model_names:",a),t(a)}}catch(e){console.error("Error fetching user models:",e)}};var B=e=>{let{userID:l,team:s,teams:t,userRole:a,accessToken:n,data:o,setData:d}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[T,D]=(0,i.useState)(null),[B,K]=(0,i.useState)([]),[W,H]=(0,i.useState)([]),[G,Y]=(0,i.useState)("you"),[J,$]=(0,i.useState)(U(o)),[X,Q]=(0,i.useState)([]),[ee,el]=(0,i.useState)(s),es=()=>{u(!1),c.resetFields()},et=()=>{u(!1),p(null),c.resetFields()};(0,i.useEffect)(()=>{l&&a&&n&&q(l,a,n,K)},[n,l,a]),(0,i.useEffect)(()=>{(async()=>{try{let e=(await (0,x.t3)(n)).guardrails.map(e=>e.guardrail_name);Q(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[n]);let ea=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",i=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===i).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(i,", please provide another key alias"));if(I.ZP.info("Making API Call"),u(!0),"you"===G&&(e.user_id=l),"service_account"===G){let l={};try{l=JSON.parse(e.metadata||"{}")}catch(e){console.error("Error parsing metadata:",e)}l.service_account_id=e.key_alias,e.metadata=JSON.stringify(l)}let m=await (0,x.wX)(n,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),p(m.key),D(m.soft_budget),I.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),I.ZP.error("Error creating the key: ".concat(e))}};return(0,i.useEffect)(()=>{H(V(ee,B)),c.setFieldValue("models",[])},[ee,B]),(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(C.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:es,onCancel:et,children:(0,r.jsxs)(k.Z,{form:c,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(A.ZP.Group,{onChange:e=>Y(e.target.value),value:G,children:[(0,r.jsx)(A.ZP,{value:"you",children:"You"}),(0,r.jsx)(A.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(A.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==G,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===G,message:"Please input the user ID of the user you are assigning the key to"}],help:"Get User ID - Click on the 'Users' tab in the sidebar.",children:(0,r.jsx)(Z.Z,{placeholder:"User ID",onChange:e=>c.setFieldValue("user_id",e.target.value)})}),(0,r.jsx)(k.Z.Item,{label:"you"===G||"another_user"===G?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===G?"key name":"service account ID")}],help:"you"===G?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(L,{teams:t,onChange:e=>{el((null==t?void 0:t.find(l=>l.team_id===e))||null)}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected team has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,r.jsx)(z,{value:"all-team-models",children:"All Team Models"},"all-team-models"),W.map(e=>(0,r.jsx)(z,{value:e,children:M(e)},e))]})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:X.map(e=>({value:e,label:e}))})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)(k.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:J})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(C.Z,{visible:m,onOk:es,onCancel:et,footer:null,children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Save your Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:null!=h?(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:h})}),(0,r.jsx)(N.CopyToClipboard,{text:h,onCopy:()=>{I.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(b.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,n]=(0,i.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,i.useState)(!0),[c,m]=(0,i.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!t){console.log("accessToken",t);return}d(!0);let a=await (0,x.OD)(t,(null==s?void 0:s.organization_id)||null,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),n(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,i.useEffect)(()=>{u(),console.log("selectedTeam",l,"currentOrg",s,"accessToken",t)},[l,s,t]),{keys:r.keys,isLoading:o,error:c,pagination:{currentPage:r.current_page,totalPages:r.total_pages,totalCount:r.total_count},refresh:u}},H=s(71594),G=s(24525),Y=s(21626),J=s(97214),$=s(28241),X=s(58834),Q=s(69552),ee=s(71876);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:n=!1}=e,o=(0,H.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,G.sC)(),getExpandedRowModel:(0,G.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(Y.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(X.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)(ee.Z,{children:e.headers.map(e=>(0,r.jsx)(Q.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,H.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(J.Z,{children:n?(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"\uD83D\uDE85 Loading logs..."})})})}):o.getRowModel().rows.length>0?o.getRowModel().rows.map(e=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)(ee.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)($.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,H.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:s.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"No logs found"})})})})})]})})}var es=s(27281),et=s(57365),ea=s(41649),er=s(12514),ei=s(12485),en=s(18135),eo=s(35242),ed=s(29706),ec=s(77991),em=s(10900),eu=s(23628),eh=s(74998);function ex(e){var l,s;let{keyData:t,onCancel:a,onSubmit:n,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=k.Z.useForm(),[h,p]=(0,i.useState)([]),j=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,i.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,x.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let g={...t,budget_duration:(s=t.budget_duration)&&({"24h":"daily","7d":"weekly","30d":"monthly"})[s]||null,metadata:t.metadata?JSON.stringify(t.metadata,null,2):"",guardrails:(null===(l=t.metadata)||void 0===l?void 0:l.guardrails)||[]};return(0,r.jsxs)(k.Z,{form:u,onFinish:n,initialValues:g,layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[j.length>0&&(0,r.jsx)(S.default.Option,{value:"all-team-models",children:"All Team Models"}),j.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(S.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(S.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(k.Z.Item,{name:"token",hidden:!0,children:(0,r.jsx)(E.Z,{})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(f.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,_]=(0,i.useState)(!1);(0,i.useEffect)(()=>{s&&l&&n.setFieldsValue({key_alias:l.key_alias,max_budget:l.max_budget,tpm_limit:l.tpm_limit,rpm_limit:l.rpm_limit,duration:l.duration||""})},[s,l,n]),(0,i.useEffect)(()=>{s||(d(null),_(!1),n.resetFields())},[s,n]),(0,i.useEffect)(()=>{(null==c?void 0:c.duration)?h((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString()}catch(e){return null}})(c.duration)):h(null)},[null==c?void 0:c.duration]);let y=async()=>{if(l&&a){_(!0);try{let e=await n.validateFields(),s=await (0,x.s0)(a,l.token,e);d(s.key),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key"),_(!1)}}},v=()=>{d(null),_(!1),n.resetFields(),t()};return(0,r.jsx)(C.Z,{title:"Regenerate API Key",open:s,onCancel:v,footer:o?[(0,r.jsx)(f.Z,{onClick:v,children:"Close"},"close")]:[(0,r.jsx)(f.Z,{onClick:v,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:y,disabled:p,children:p?"Regenerating...":"Regenerate"},"regenerate")],children:o?(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:(null==l?void 0:l.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{className:"bg-gray-100 p-2 rounded mb-2",children:(0,r.jsx)("pre",{className:"break-words whitespace-normal",children:o})}),(0,r.jsx)(N.CopyToClipboard,{text:o,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(k.Z,{form:n,layout:"vertical",onValuesChange:e=>{"duration"in e&&m(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==l?void 0:l.expires)?new Date(l.expires).toLocaleString():"Never"]}),u&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",u]})]})})}function ej(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:n,userRole:o,teams:d}=e,[c,m]=(0,i.useState)(!1),[u]=k.Z.useForm(),[h,p]=(0,i.useState)(!1),[j,Z]=(0,i.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(b.Z,{children:"Key not found"})]});let _=async e=>{try{var l,s;if(!a)return;let t=e.token;if(e.key=t,e.metadata&&"string"==typeof e.metadata)try{let s=JSON.parse(e.metadata);e.metadata={...s,...(null===(l=e.guardrails)||void 0===l?void 0:l.length)>0?{guardrails:e.guardrails}:{}}}catch(e){console.error("Error parsing metadata JSON:",e),I.ZP.error("Invalid metadata JSON");return}else e.metadata={...e.metadata||{},...(null===(s=e.guardrails)||void 0===s?void 0:s.length)>0?{guardrails:e.guardrails}:{}};e.budget_duration&&(e.budget_duration=({daily:"24h",weekly:"7d",monthly:"30d"})[e.budget_duration]),await (0,x.Nc)(a,e),I.ZP.success("Key updated successfully"),m(!1)}catch(e){I.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},y=async()=>{try{if(!a)return;await (0,x.I1)(a,t.token),I.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),I.ZP.error("Failed to delete key")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(f.Z,{icon:eu.Z,variant:"secondary",onClick:()=>Z(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>p(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:j,onClose:()=>Z(!1),accessToken:a}),h&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:y,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>p(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(b.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:_,teams:d,accessToken:a,userID:n,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(b.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(b.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(b.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(b.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(b.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(b.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(b.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(b.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:t.models&&t.models.length>0?t.models.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):(0,r.jsx)(b.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(b.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Metadata"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(t.metadata,null,2)})]})]})]})})]})]})]})}var eg=s(82422),ef=s(2356),eZ=s(44633),e_=s(86462),ey=s(3837),ev=e=>{var l;let{options:s,onApplyFilters:t,onResetFilters:a,initialValues:n={},buttonLabel:o="Filter"}=e,[d,c]=(0,i.useState)(!1),[m,h]=(0,i.useState)((null===(l=s[0])||void 0===l?void 0:l.name)||""),[x,p]=(0,i.useState)(n),[j,g]=(0,i.useState)(n),[Z,_]=(0,i.useState)(!1),y=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=e=>{let l=e.target;!y.current||y.current.contains(l)||l.closest(".ant-dropdown")||c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let v=e=>{g(l=>({...l,[m]:e}))},b=()=>{let e={};s.forEach(l=>{e[l.name]=""}),g(e)},w=s.map(e=>({key:e.name,label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[m===e.name&&(0,r.jsx)(eg.Z,{className:"h-4 w-4 text-blue-600"}),e.label||e.name]})}));return(0,r.jsxs)("div",{className:"relative",ref:y,children:[(0,r.jsx)(f.Z,{icon:ef.Z,onClick:()=>c(!d),variant:"secondary",size:"xs",className:"flex items-center pr-2",children:o}),d&&(0,r.jsx)(er.Z,{className:"absolute left-0 mt-2 w-96 z-50 border border-gray-200 shadow-lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsx)(u.Z,{menu:{items:w,onClick:e=>{let{key:l}=e;h(l),_(!1)}},onOpenChange:_,open:Z,trigger:["click"],children:(0,r.jsxs)(O.ZP,{className:"min-w-32 text-left flex justify-between items-center",children:[m,Z?(0,r.jsx)(eZ.Z,{className:"h-4 w-4"}):(0,r.jsx)(e_.Z,{className:"h-4 w-4"})]})}),(0,r.jsx)(E.Z,{placeholder:"Enter value...",value:j[m]||"",onChange:e=>v(e.target.value),className:"px-3 py-1.5 border rounded-md text-sm flex-1 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",suffix:j[m]?(0,r.jsx)(ey.Z,{className:"h-4 w-4 cursor-pointer text-gray-400 hover:text-gray-500",onClick:e=>{e.stopPropagation(),v("")}}):null})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(O.ZP,{onClick:()=>{b();let e={};s.forEach(l=>{e[l.name]=""}),a(),c(!1)},children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"primary",onClick:()=>{p(j),t(j),c(!1)},children:"Apply Filters"})]})]})})]})};function eb(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:n=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h,organizations:x,setCurrentOrg:p}=e,[j,g]=(0,i.useState)(null),[Z,_]=(0,i.useState)({"Team ID":"","Organization ID":""}),y=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):null}},{header:"Key ID",accessorKey:"token",cell:e=>(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.getValue(),children:(0,r.jsx)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>g(e.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{header:"Team ID",accessorKey:"team_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Key Alias",accessorKey:"key_alias",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Organization ID",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{header:"Created",accessorKey:"created_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"-"}},{header:"Expires",accessorKey:"expires",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleDateString():"Never"}},{header:"Spend (USD)",accessorKey:"spend",cell:e=>Number(e.getValue()).toFixed(4)},{header:"Budget (USD)",accessorKey:"max_budget",cell:e=>null!==e.getValue()&&void 0!==e.getValue()?e.getValue():"Unlimited"},{header:"Budget Reset",accessorKey:"budget_reset_at",cell:e=>{let l=e.getValue();return l?new Date(l).toLocaleString():"Never"}},{header:"Models",accessorKey:"models",cell:e=>{let l=e.getValue();return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:l&&l.length>0?l.map((e,l)=>(0,r.jsx)("span",{className:"px-2 py-1 bg-blue-100 rounded text-xs",children:e},l)):"-"})}},{header:"Rate Limits",cell:e=>{let{row:l}=e,s=l.original;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{children:["TPM: ",null!==s.tpm_limit?s.tpm_limit:"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",null!==s.rpm_limit?s.rpm_limit:"Unlimited"]})]})}}];return(0,r.jsx)("div",{className:"w-full h-full overflow-hidden",children:j?(0,r.jsx)(ej,{keyId:j,onClose:()=>g(null),keyData:l.find(e=>e.token===j),accessToken:m,userID:u,userRole:h,teams:o}):(0,r.jsxs)("div",{className:"border-b py-4 flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between w-full mb-2",children:[(0,r.jsx)(ev,{options:[{name:"Team ID",label:"Team ID"},{name:"Organization ID",label:"Organization ID"}],onApplyFilters:e=>{if(_({"Team ID":e["Team ID"]||"","Organization ID":e["Organization ID"]||""}),e["Team ID"]){let l=null==o?void 0:o.find(l=>l.team_id===e["Team ID"]);l&&c(l)}if(e["Organization ID"]){let l=null==x?void 0:x.find(l=>l.organization_id===e["Organization ID"]);l&&p(l)}},initialValues:Z,onResetFilters:()=>{_({"Team ID":"","Organization ID":""}),c(null),p(null)}}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsxs)("span",{className:"inline-flex text-sm text-gray-700",children:["Showing ",s?"...":"".concat((t.currentPage-1)*n+1," - ").concat(Math.min(t.currentPage*n,t.totalCount))," of ",s?"...":t.totalCount," results"]}),(0,r.jsxs)("div",{className:"inline-flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",s?"...":t.currentPage," of ",s?"...":t.totalPages]}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage-1),disabled:s||1===t.currentPage,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>a(t.currentPage+1),disabled:s||t.currentPage===t.totalPages,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]}),(0,r.jsx)("div",{className:"h-[32rem] overflow-auto",children:(0,r.jsx)(el,{columns:y.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ew=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:n,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u,organizations:h,setCurrentOrg:p}=e,[_,y]=(0,i.useState)(!1),[v,S]=(0,i.useState)(!1),[A,E]=(0,i.useState)(null),[O,M]=(0,i.useState)(null),[D,L]=(0,i.useState)(null),[F,R]=(0,i.useState)((null==a?void 0:a.team_id)||""),[z,U]=(0,i.useState)("");(0,i.useEffect)(()=>{R((null==a?void 0:a.team_id)||"")},[a]);let{keys:V,isLoading:q,error:B,pagination:H,refresh:G}=W({selectedTeam:a,currentOrg:u,accessToken:t}),[Y,J]=(0,i.useState)(!1),[$,X]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(null),[el,es]=(0,i.useState)([]),et=new Set,[ea,er]=(0,i.useState)(!1),[ei,en]=(0,i.useState)(!1),[eo,ed]=(0,i.useState)(null),[ec,em]=(0,i.useState)(null),[eu]=k.Z.useForm(),[eh,ex]=(0,i.useState)(null),[ep,ej]=(0,i.useState)(et),[eg,ef]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",Q),(null==ec?void 0:ec.duration)?ex((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,K.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,K.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,K.Z)(s,{days:parseInt(e)});else throw Error("Invalid duration format");return l.toLocaleString("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0})}catch(e){return null}})(ec.duration)):ex(null),console.log("calculateNewExpiryTime:",eh)},[Q,null==ec?void 0:ec.duration]),(0,i.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await T(l,s,t);e&&es(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,i.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ej(e)}},[c]);let eZ=async()=>{if(null!=A&&null!=o){try{await (0,x.I1)(t,A);let e=o.filter(e=>e.token!==A);d(e)}catch(e){console.error("Error deleting the key:",e)}S(!1),E(null)}},e_=(e,l)=>{em(s=>({...s,[e]:l}))},ey=async()=>{if(!m){I.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=Q)try{let e=await eu.validateFields(),l=await (0,x.s0)(t,Q.token,e);if(ed(l.key),o){let s=o.map(s=>s.token===(null==Q?void 0:Q.token)?{...s,key_name:l.key_name,...e}:s);d(s)}en(!1),eu.resetFields(),I.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),I.ZP.error("Failed to regenerate API Key")}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eb,{keys:V,isLoading:q,pagination:H,onPageChange:e=>{G({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:n,accessToken:t,userID:l,userRole:s,organizations:h,setCurrentOrg:p}),v&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eZ,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{S(!1),E(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(C.Z,{title:"Regenerate API Key",visible:ei,onCancel:()=>{en(!1),eu.resetFields()},footer:[(0,r.jsx)(f.Z,{onClick:()=>{en(!1),eu.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(f.Z,{onClick:ey,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(k.Z,{form:eu,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&e_("duration",e.duration)},children:[(0,r.jsx)(k.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(k.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(P.Z,{style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry:"," ",(null==Q?void 0:Q.expires)!=null?new Date(Q.expires).toLocaleString():"Never"]}),eh&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eh]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),eo&&(0,r.jsx)(C.Z,{visible:!!eo,onCancel:()=>ed(null),footer:[(0,r.jsx)(f.Z,{onClick:()=>ed(null),children:"Close"},"close")],children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Regenerated Key"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,r.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(b.Z,{className:"mt-3",children:"Key Alias:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==Q?void 0:Q.key_alias)||"No alias set"})}),(0,r.jsx)(b.Z,{className:"mt-3",children:"New API Key:"}),(0,r.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,r.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:eo})}),(0,r.jsx)(N.CopyToClipboard,{text:eo,onCopy:()=>I.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(f.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eN=s(12011),eS=s(93192);console.log=function(){},console.log("isLocal:",!1);var ek=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,premiumUser:f,organizations:Z}=e,[_,y]=(0,i.useState)(null),[v,b]=(0,i.useState)(null),w=(0,n.useSearchParams)(),N=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),S=w.get("invitation_id"),[k,I]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),[P,E]=(0,i.useState)([]),[O,T]=(0,i.useState)(null),[M,D]=(0,i.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,i.useEffect)(()=>{if(N){let e=(0,o.o)(N);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),d(l)}else console.log("User role not defined");e.user_email?m(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&k&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);e?E(JSON.parse(e)):(console.log("currentOrg: ".concat(JSON.stringify(v))),(async()=>{try{let e=await (0,x.g)(k);T(e);let t=await (0,x.Br)(k,l,s,!1,null,null);y(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(_))),(null==t?void 0:t.teams[0].keys)?h(t.keys.concat(t.teams.filter(e=>"Admin"===s||e.user_id===l).flatMap(e=>e.keys))):h(t.keys),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,x.So)(k,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),E(a),console.log("userModels:",P),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),p(k,l,s,v,u))}},[l,N,k,a,s]),(0,i.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(v),", accessToken: ").concat(k,", userID: ").concat(l,", userRole: ").concat(s)),k&&(console.log("fetching teams"),p(k,l,s,v,u))},[v]),(0,i.useEffect)(()=>{if(null!==a&&null!=M&&null!==M.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))M.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===M.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),A(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;A(e)}},[M]),null!=S)return(0,r.jsx)(eN.default,{});if(null==l||null==N){let e="/sso/key/generate";return document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",console.log("Full URL:",e),window.location.href=e,null}if(null==k)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",M),(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(j.Z,{numColSpan:1,className:"flex flex-col gap-2",children:[(0,r.jsx)(B,{userID:l,team:M,teams:t,userRole:s,accessToken:k,data:a,setData:h},M?M.team_id:null),(0,r.jsx)(ew,{userID:l,userRole:s,accessToken:k,selectedTeam:M||null,setSelectedTeam:D,data:a,setData:h,premiumUser:f,teams:t,currentOrg:v,setCurrentOrg:b,organizations:Z})]})})})},eI=s(97765);(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.Groq="Groq",t.MistralAI="Mistral AI",t.Deepseek="Deepseek",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI",t.AssemblyAI="AssemblyAI";let eC={OpenAI:"openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",Groq:"groq",MistralAI:"mistral",Cohere:"cohere_chat",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",xAI:"xai",Deepseek:"deepseek",Ollama:"ollama",AssemblyAI:"assemblyai"},eA={OpenAI:"https://artificialanalysis.ai/img/logos/openai_small.svg",Azure:"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg","Azure AI Studio":"https://upload.wikimedia.org/wikipedia/commons/a/a8/Microsoft_Azure_Logo.svg",Anthropic:"https://artificialanalysis.ai/img/logos/anthropic_small.svg","Google AI Studio":"https://artificialanalysis.ai/img/logos/google_small.svg","Amazon Bedrock":"https://artificialanalysis.ai/img/logos/aws_small.png",Groq:"https://artificialanalysis.ai/img/logos/groq_small.png","Mistral AI":"https://artificialanalysis.ai/img/logos/mistral_small.png",Cohere:"https://artificialanalysis.ai/img/logos/cohere_small.png","OpenAI-Compatible Endpoints (Together AI, etc.)":"https://upload.wikimedia.org/wikipedia/commons/4/4e/OpenAI_Logo.svg","Vertex AI (Anthropic, Gemini, etc.)":"https://artificialanalysis.ai/img/logos/google_small.svg",Databricks:"https://artificialanalysis.ai/img/logos/databricks_small.png",Ollama:"https://artificialanalysis.ai/img/logos/ollama_small.svg",xAI:"https://artificialanalysis.ai/img/logos/xai_small.svg",Deepseek:"https://artificialanalysis.ai/img/logos/deepseek_small.jpg",AssemblyAI:"https://artificialanalysis.ai/img/logos/assemblyai_small.png"},eP=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(eC).find(l=>eC[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eA[s],displayName:s}},eE=e=>"Vertex AI (Anthropic, Gemini, etc.)"===e?"gemini-pro":"Anthropic"==e||"Amazon Bedrock"==e?"claude-3-opus":"Google AI Studio"==e?"gemini-pro":"Azure AI Studio"==e?"azure_ai/command-r-plus":"Azure"==e?"azure/my-deployment":"gpt-3.5-turbo",eO=(e,l)=>{console.log("Provider key: ".concat(e));let s=eC[e];console.log("Provider mapped to: ".concat(s));let t=[];return e&&"object"==typeof l&&(Object.entries(l).forEach(e=>{let[l,a]=e;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===s||a.litellm_provider.includes(s))&&t.push(l)}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(l).forEach(e=>{let[l,s]=e;null!==s&&"object"==typeof s&&"litellm_provider"in s&&"cohere"===s.litellm_provider&&t.push(l)}))),t},eT=async(e,l,s,t)=>{try{console.log("handling submit for formValues:",e);let a=e.model_mappings||[];if("model_mappings"in e&&delete e.model_mappings,e.model&&e.model.includes("all-wildcard")){let l=eC[e.custom_llm_provider]+"/*";e.model_name=l,a.push({public_name:l,litellm_model:l}),e.model=l}for(let s of a){let t={},a={},r=s.public_name;for(let[l,r]of(t.model=s.litellm_model,e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),t.model=s.litellm_model,console.log("formValues add deployment:",e),Object.entries(e)))if(""!==r&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)t.model=r;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",r);let e=eC[r];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=r;else if("team_id"===l)a.team_id=r;else if("custom_model_name"===l)t.model=r;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw I.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))a[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){r&&(t[l]=Number(r));continue}else t[l]=r}let i={model_name:r,litellm_params:t,model_info:a},n=await (0,x.kK)(l,i);console.log("response for model create call: ".concat(n.data))}t&&t(),s.resetFields()}catch(e){I.ZP.error("Failed to create model: "+e,10)}},eM=e=>{var l;return(null==e?void 0:null===(l=e.model_info)||void 0===l?void 0:l.team_public_model_name)?e.model_info.team_public_model_name:(null==e?void 0:e.model_name)||"-"},eD=async(e,l,s,t)=>{if(console.log("handleEditSubmit:",e),null==l)return;let a={},r=null;for(let[l,s]of(e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),Object.entries(e)))"model_id"!==l?a[l]=""===s?null:s:r=""===s?null:s;let i={litellm_params:Object.keys(a).length>0?a:void 0,model_info:void 0!==r?{id:r}:void 0};console.log("handleEditSubmit payload:",i);try{await (0,x.um)(l,i),I.ZP.success("Model updated successfully, restart server to see updates"),s(!1),t(null)}catch(e){console.log("Error occurred")}};var eL=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[i]=k.Z.useForm(),n={},o="",d="";if(t){var c,m;n={...t.litellm_params,input_cost_per_token:(null===(c=t.litellm_params)||void 0===c?void 0:c.input_cost_per_token)?1e6*t.litellm_params.input_cost_per_token:void 0,output_cost_per_token:(null===(m=t.litellm_params)||void 0===m?void 0:m.output_cost_per_token)?1e6*t.litellm_params.output_cost_per_token:void 0},o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),n.model_id=d)}return(0,r.jsx)(C.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{a({...e,input_cost_per_token:e.input_cost_per_token?Number(e.input_cost_per_token)/1e6:void 0,output_cost_per_token:e.output_cost_per_token?Number(e.output_cost_per_token)/1e6:void 0}),i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(k.Z,{form:i,onFinish:a,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},eF=s(53003),eR=s(47323),ez=s(75105),eU=s(40278),eV=s(69410),eq=s(14301),eB=s(53410),eK=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,n]=(0,i.useState)(!1),o=async()=>{try{I.ZP.info("Making API Call"),n(!0);let e=await (0,x.Og)(s,l);console.log("model delete Response:",e),I.ZP.success("Model ".concat(l," deleted successfully")),n(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eR.Z,{onClick:()=>n(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(C.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>n(!1),children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(w.Z,{children:"Delete Model"}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)("p",{children:["Model ID: ",(0,r.jsx)("b",{children:l})]})})]})})]})},eW=s(94789),eH=s(59664),eG=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eH.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,r.jsxs)("div",{children:[(0,r.jsx)(eW.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,r.jsx)(f.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eY=e=>{var l,s,t;let{visible:a,onCancel:n,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=k.Z.useForm();console.log("Initial Data:",d),(0,i.useEffect)(()=>{if(a){if("edit"===c&&d)u.setFieldsValue({...d,role:d.role||m.defaultRole});else{var e;u.resetFields(),u.setFieldsValue({role:m.defaultRole||(null===(e=m.roleOptions[0])||void 0===e?void 0:e.value)})}}},[a,d,c,u,m.defaultRole,m.roleOptions]);let h=async e=>{try{let l=Object.entries(e).reduce((e,l)=>{let[s,t]=l;return{...e,[s]:"string"==typeof t?t.trim():t}},{});o(l),u.resetFields(),I.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){I.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}},x=e=>{switch(e.type){case"input":return(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",onChange:e=>{e.target.value=e.target.value.trim()}});case"select":var l;return(0,r.jsx)(S.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(C.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:n,children:(0,r.jsxs)(k.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),m.showEmail&&m.showUserId&&(0,r.jsx)("div",{className:"text-center mb-4",children:(0,r.jsx)(b.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(E.Z,{className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{children:"Role"}),"edit"===c&&d&&(0,r.jsxs)("span",{className:"text-gray-500 text-sm",children:["(Current: ",(s=d.role,(null===(t=m.roleOptions.find(e=>e.value===s))||void 0===t?void 0:t.label)||s),")"]})]}),name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,r.jsx)(S.default,{children:"edit"===c&&d?[...m.roleOptions.filter(e=>e.value===d.role),...m.roleOptions.filter(e=>e.value!==d.role)].map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:e.label},e.value))})}),null===(l=m.additionalFields)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.Z.Item,{label:e.label,name:e.name,className:"mb-4",rules:e.rules,children:x(e)},e.name)),(0,r.jsxs)("div",{className:"text-right mt-6",children:[(0,r.jsx)(O.ZP,{onClick:n,className:"mr-2",children:"Cancel"}),(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},eJ=s(7310),e$=s.n(eJ),eX=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:n="Add Team Member",roles:o=[{label:"admin",value:"admin",description:"Admin role. Can create team keys, add members, and manage settings."},{label:"user",value:"user",description:"User role. Can view team info, but not manage it."}],defaultRole:d="user"}=e,[c]=k.Z.useForm(),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}p(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,x.u5)(a,s)).map(e=>({label:"user_email"===l?"".concat(e.user_email):"".concat(e.user_id),value:"user_email"===l?e.user_email:e.user_id,user:e}));u(t)}catch(e){console.error("Error fetching users:",e)}finally{p(!1)}},Z=(0,i.useCallback)(e$()((e,l)=>f(e,l),300),[]),_=(e,l)=>{g(l),Z(e,l)},y=(e,l)=>{let s=l.user;c.setFieldsValue({user_email:s.user_email,user_id:s.user_id,role:c.getFieldValue("role")})};return(0,r.jsx)(C.Z,{title:n,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(k.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(k.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>_(e,"user_email"),onSelect:(e,l)=>y(e,l),options:"user_email"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(k.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(S.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>_(e,"user_id"),onSelect:(e,l)=>y(e,l),options:"user_id"===j?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(k.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(S.default.Option,{value:e.value,children:(0,r.jsxs)(R.Z,{title:e.description,children:[(0,r.jsx)("span",{className:"font-medium",children:e.label}),(0,r.jsxs)("span",{className:"ml-2 text-gray-500 text-sm",children:["- ",e.description]})]})},e.value))})}),(0,r.jsx)("div",{className:"text-right mt-4",children:(0,r.jsx)(O.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},eQ=e=>{var l;let{teamId:s,onClose:t,accessToken:a,is_team_admin:n,is_proxy_admin:o,userModels:d,editTeam:c}=e,[m,u]=(0,i.useState)(null),[h,p]=(0,i.useState)(!0),[j,Z]=(0,i.useState)(!1),[_]=k.Z.useForm(),[y,v]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null),[A,T]=(0,i.useState)(!1);console.log("userModels in team info",d);let D=n||o,L=async()=>{try{if(p(!0),!a)return;let e=await (0,x.Xm)(a,s);u(e)}catch(e){I.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{p(!1)}};(0,i.useEffect)(()=>{L()},[s,a]);let z=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.cu)(a,s,l),I.ZP.success("Team member added successfully"),Z(!1),_.resetFields(),L()}catch(e){I.ZP.error("Failed to add team member"),console.error("Error adding team member:",e)}},U=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.sN)(a,s,l),I.ZP.success("Team member updated successfully"),v(!1),L()}catch(e){I.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},V=async e=>{try{if(null==a)return;await (0,x.Lp)(a,s,e),I.ZP.success("Team member removed successfully"),L()}catch(e){I.ZP.error("Failed to remove team member"),console.error("Error removing team member:",e)}},q=async e=>{try{var l;if(!a)return;let t={team_id:s,team_alias:e.team_alias,models:e.models,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration,metadata:{...null==m?void 0:null===(l=m.team_info)||void 0===l?void 0:l.metadata,guardrails:e.guardrails||[]}};await (0,x.Gh)(a,t),I.ZP.success("Team settings updated successfully"),T(!1),L()}catch(e){I.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(h)return(0,r.jsx)("div",{className:"p-4",children:"Loading..."});if(!(null==m?void 0:m.team_info))return(0,r.jsx)("div",{className:"p-4",children:"Team not found"});let{team_info:B}=m;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:B.team_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:B.team_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",B.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===B.max_budget?"Unlimited":"$".concat(B.max_budget)]}),B.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",B.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",B.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",B.rpm_limit||"Unlimited"]}),B.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",B.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:B.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:m.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)($.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{C(e),v(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>V(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(f.Z,{onClick:()=>Z(!0),children:"Add Member"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Team Settings"}),D&&!A&&(0,r.jsx)(f.Z,{onClick:()=>T(!0),children:"Edit Settings"})]}),A?(0,r.jsxs)(k.Z,{form:_,onFinish:q,initialValues:{...B,team_alias:B.team_alias,models:B.models,tpm_limit:B.tpm_limit,rpm_limit:B.rpm_limit,max_budget:B.max_budget,budget_duration:B.budget_duration,guardrails:(null===(l=B.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(E.Z,{type:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>T(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:B.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:B.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(B.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:B.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",B.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",B.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==B.max_budget?"$".concat(B.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",B.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:B.blocked?"red":"green",children:B.blocked?"Blocked":"Active"})]})]})]})})]})]}),(0,r.jsx)(eY,{visible:y,onCancel:()=>v(!1),onSubmit:U,initialData:N,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Admin",value:"admin"},{label:"User",value:"user"}]}}),(0,r.jsx)(eX,{isVisible:j,onCancel:()=>Z(!1),onSubmit:z,accessToken:a})]})};function e0(e){var l,s,t,a,n,o,d,c,m,u,h;let{modelId:p,onClose:j,modelData:Z,accessToken:_,userID:y,userRole:v,editModel:N,setEditModalVisible:S,setSelectedModel:C}=e,[A,P]=(0,i.useState)(!1),[E]=k.Z.useForm(),[T,M]=(0,i.useState)(!1),D="Admin"===v;if(!Z)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsx)(b.Z,{children:"Model not found"})]});let L=async()=>{try{if(!_)return;await (0,x.Og)(_,p),I.ZP.success("Model deleted successfully"),j()}catch(e){console.error("Error deleting the model:",e),I.ZP.error("Failed to delete model")}};return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(em.Z,{}),onClick:j,className:"mb-4",children:"Back to Models"}),(0,r.jsxs)(w.Z,{children:["Public Model Name: ",eM(Z)]}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:Z.model_info.id})]}),D&&(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsx)(f.Z,{icon:eh.Z,variant:"secondary",onClick:()=>M(!0),className:"flex items-center",children:"Delete Model"})})]}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-6",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Raw JSON"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6 mb-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Provider"}),(0,r.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[Z.provider&&(0,r.jsx)("img",{src:eP(Z.provider).logo,alt:"".concat(Z.provider," logo"),className:"w-4 h-4",onError:e=>{let l=e.target,s=l.parentElement;if(s){var t;let e=document.createElement("div");e.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=(null===(t=Z.provider)||void 0===t?void 0:t.charAt(0))||"-",s.replaceChild(e,l)}}}),(0,r.jsx)(w.Z,{children:Z.provider||"Not Set"})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"LiteLLM Model"}),(0,r.jsx)("pre",{children:(0,r.jsx)(w.Z,{children:Z.litellm_model_name||"Not Set"})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Pricing"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Input: $",Z.input_cost,"/1M tokens"]}),(0,r.jsxs)(b.Z,{children:["Output: $",Z.output_cost,"/1M tokens"]})]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Model Settings"}),D&&!A&&(0,r.jsx)(f.Z,{variant:"light",onClick:()=>P(!0),children:"Edit Settings"})]}),A?(0,r.jsx)(eL,{visible:A,onCancel:()=>P(!1),model:Z,onSubmit:e=>eD(e,_,S,C)}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model ID"}),(0,r.jsx)("div",{className:"font-mono",children:Z.model_info.id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Public Model Name"}),(0,r.jsx)("div",{children:eM(Z)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Model Name"}),(0,r.jsx)("div",{children:Z.litellm_model_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Input Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(l=Z.litellm_params)||void 0===l?void 0:l.input_cost_per_token)?(1e6*Z.litellm_params.input_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Output Cost (per 1M tokens)"}),(0,r.jsx)("div",{children:(null===(s=Z.litellm_params)||void 0===s?void 0:s.output_cost_per_token)?(1e6*Z.litellm_params.output_cost_per_token).toFixed(4):"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"API Base"}),(0,r.jsx)("div",{children:(null===(t=Z.litellm_params)||void 0===t?void 0:t.api_base)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Custom LLM Provider"}),(0,r.jsx)("div",{children:(null===(a=Z.litellm_params)||void 0===a?void 0:a.custom_llm_provider)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Model"}),(0,r.jsx)("div",{children:(null===(n=Z.litellm_params)||void 0===n?void 0:n.model)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)("div",{children:(null===(o=Z.litellm_params)||void 0===o?void 0:o.organization)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"TPM (Tokens per Minute)"}),(0,r.jsx)("div",{children:(null===(d=Z.litellm_params)||void 0===d?void 0:d.tpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"RPM (Requests per Minute)"}),(0,r.jsx)("div",{children:(null===(c=Z.litellm_params)||void 0===c?void 0:c.rpm)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Max Retries"}),(0,r.jsx)("div",{children:(null===(m=Z.litellm_params)||void 0===m?void 0:m.max_retries)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(u=Z.litellm_params)||void 0===u?void 0:u.timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Stream Timeout (seconds)"}),(0,r.jsx)("div",{children:(null===(h=Z.litellm_params)||void 0===h?void 0:h.stream_timeout)||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{children:Z.model_info.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:Z.model_info.created_at?new Date(Z.model_info.created_at).toLocaleString():"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created By"}),(0,r.jsx)("div",{children:Z.model_info.created_by||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"LiteLLM Parameters"}),(0,r.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(Z.cleanedLitellmParams,null,2)})]})]})]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsx)("pre",{className:"bg-gray-100 p-4 rounded text-xs overflow-auto",children:JSON.stringify(Z,null,2)})})})]})]}),T&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Model"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this model?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(O.ZP,{onClick:L,className:"ml-2",danger:!0,children:"Delete"}),(0,r.jsx)(O.ZP,{onClick:()=>M(!1),children:"Cancel"})]})]})]})})]})}var e1=s(67960),e2=s(47451),e4=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,i=k.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,r.jsx)(k.Z.Item,{name:"model",rules:[{required:!0,message:"Please select at least one model."}],noStyle:!0,children:l===a.Azure||l===a.OpenAI_Compatible||l===a.Ollama?(0,r.jsx)(Z.Z,{placeholder:t(l)}):s.length>0?(0,r.jsx)(S.default,{mode:"multiple",allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{let l=Array.isArray(e)?e:[e];if(l.includes("all-wildcard"))i.setFieldsValue({model_name:void 0,model_mappings:[]});else{let e=l.map(e=>({public_name:e,litellm_model:e}));i.setFieldsValue({model_mappings:e})}},optionFilterProp:"children",filterOption:(e,l)=>{var s;return(null!==(s=null==l?void 0:l.label)&&void 0!==s?s:"").toLowerCase().includes(e.toLowerCase())},options:[{label:"All ".concat(l," Models (Wildcard)"),value:"all-wildcard"},...s.map(e=>({label:e,value:e})),{label:"Custom Model Name (Enter below)",value:"custom"}],style:{width:"100%"}}):(0,r.jsx)(Z.Z,{placeholder:t(l)})}),(0,r.jsx)(k.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,r.jsx)(k.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name."}],className:"mt-2",children:(0,r.jsx)(Z.Z,{placeholder:"Enter custom model name"})})}})]}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},e5=s(48379),e3=()=>{let e=k.Z.useFormInstance(),l=k.Z.useWatch("model",e)||[],s=!l.includes("all-wildcard");if((0,i.useEffect)(()=>{if(l.length>0&&!l.includes("all-wildcard")){let s=l.map(e=>({public_name:e,litellm_model:e}));e.setFieldValue("model_mappings",s)}},[l,e]),!s)return null;let t=[{title:"Public Name",dataIndex:"public_name",key:"public_name",render:(l,s,t)=>(0,r.jsx)(Z.Z,{defaultValue:l,onChange:l=>{let s=[...e.getFieldValue("model_mappings")];s[t].public_name=l.target.value,e.setFieldValue("model_mappings",s)}})},{title:"LiteLLM Model",dataIndex:"litellm_model",key:"litellm_model"}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Model Mappings",name:"model_mappings",tooltip:"Map public model names to LiteLLM model names for load balancing",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!0,children:(0,r.jsx)(e5.Z,{dataSource:e.getFieldValue("model_mappings"),columns:t,pagination:!1,size:"small"})}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})},e8=s(87024),e6=s(3632);let{Link:e7}=eS.default;var e9=e=>{let{selectedProvider:l,uploadProps:s}=e;console.log("Selected provider: ".concat(l)),console.log("type of selectedProvider: ".concat(typeof l));let t=a[l];return console.log("selectedProviderEnum: ".concat(t)),console.log("type of selectedProviderEnum: ".concat(typeof t)),(0,r.jsxs)(r.Fragment,{children:[t===a.OpenAI&&(0,r.jsx)(k.Z.Item,{label:"OpenAI Organization ID",name:"organization",children:(0,r.jsx)(Z.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),t===a.Vertex_AI&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,r.jsx)(Z.Z,{placeholder:"adroit-cadet-1234.."})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(e8.Z,{...s,children:(0,r.jsx)(O.ZP,{icon:(0,r.jsx)(e6.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsx)(b.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]})]}),t===a.AssemblyAI&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(S.default,{placeholder:"Select API Base",children:[(0,r.jsx)(S.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(S.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsx)(Z.Z,{placeholder:"https://..."})}),t===a.Azure&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"API Version",name:"api_version",tooltip:"By default litellm will use the latest version. If you want to use a different version, you can specify it here",children:(0,r.jsx)(Z.Z,{placeholder:"2023-07-01-preview"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(k.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,r.jsx)(Z.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,r.jsxs)(e2.Z,{children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(e7,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]})]}),t===a.Bedrock&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,r.jsx)(Z.Z,{placeholder:"us-east-1"})})]}),t!=a.Bedrock&&t!=a.Vertex_AI&&t!=a.Ollama&&(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",tooltip:"LLM API Credentials",children:(0,r.jsx)(Z.Z,{placeholder:"sk-",type:"password"})})]})},le=s(63709),ll=s(90464);let{Link:ls}=eS.default;var lt=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s,teams:t}=e,[a]=k.Z.useForm(),[n,o]=i.useState(!1),[d,c]=i.useState("per_token"),m=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),u=(e,l)=>{if(!l)return Promise.resolve();try{return JSON.parse(l),Promise.resolve()}catch(e){return Promise.reject("Please enter valid JSON")}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(_.Z,{className:"mt-2 mb-4",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Advanced Settings"})}),(0,r.jsx)(y.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(k.Z.Item,{label:"Team",name:"team_id",className:"mb-4",children:(0,r.jsx)(L,{teams:t})}),(0,r.jsx)(k.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(le.Z,{onChange:e=>{o(e),e||a.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),n&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(k.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(S.default,{defaultValue:"per_token",onChange:e=>c(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(k.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:m}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(k.Z.Item,{label:"Use in pass through routes",name:"use_in_pass_through",valuePropName:"checked",className:"mb-4 mt-4",tooltip:(0,r.jsxs)("span",{children:["Allow using these credentials in pass through routes."," ",(0,r.jsx)(ls,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(le.Z,{onChange:e=>{let l=a.getFieldValue("litellm_extra_params");try{let s=l?JSON.parse(l):{};e?s.use_in_pass_through=!0:delete s.use_in_pass_through,Object.keys(s).length>0?a.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):a.setFieldValue("litellm_extra_params","")}catch(l){e?a.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):a.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(k.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-4 mt-4",rules:[{validator:u}],children:(0,r.jsx)(ll.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(e2.Z,{className:"mb-4",children:[(0,r.jsx)(eV.Z,{span:10}),(0,r.jsx)(eV.Z,{span:10,children:(0,r.jsxs)(b.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(ls,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(k.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",rules:[{validator:u}],children:(0,r.jsx)(ll.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})};let{Title:la,Link:lr}=eS.default;var li=e=>{let{form:l,handleOk:s,selectedProvider:t,setSelectedProvider:i,providerModels:n,setProviderModelsFn:o,getPlaceholder:d,uploadProps:c,showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(la,{level:2,children:"Add new model"}),(0,r.jsx)(e1.Z,{children:(0,r.jsx)(k.Z,{form:l,onFinish:s,labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,r.jsx)(S.default,{showSearch:!0,value:t,onChange:e=>{i(e),o(e),l.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(S.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eA[s],alt:"".concat(l," logo"),className:"w-5 h-5",onError:e=>{let l=e.target,t=l.parentElement;if(t){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=s.charAt(0),t.replaceChild(e,l)}}}),(0,r.jsx)("span",{children:s})]})},l)})})}),(0,r.jsx)(e4,{selectedProvider:t,providerModels:n,getPlaceholder:d}),(0,r.jsx)(e3,{}),(0,r.jsx)(e9,{selectedProvider:t,uploadProps:c}),(0,r.jsx)(lt,{showAdvancedSettings:m,setShowAdvancedSettings:u,teams:h}),(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(R.Z,{title:"Get help on our github",children:(0,r.jsx)(eS.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]})};let{Title:ln,Link:lo}=eS.default,ld={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var lc=e=>{let{accessToken:l,token:s,userRole:t,userID:n,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m,teams:u}=e,[h,p]=(0,i.useState)([]),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(""),[N,S]=(0,i.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[C,A]=(0,i.useState)([]),[E,O]=(0,i.useState)(a.OpenAI),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(!1),[F,z]=(0,i.useState)(null),[U,V]=(0,i.useState)([]),[q,B]=(0,i.useState)([]),[K,W]=(0,i.useState)(null),[H,G]=(0,i.useState)([]),[el,em]=(0,i.useState)([]),[eh,ex]=(0,i.useState)([]),[ep,ej]=(0,i.useState)([]),[eg,eZ]=(0,i.useState)([]),[e_,ey]=(0,i.useState)([]),[ev,eb]=(0,i.useState)([]),[ew,eN]=(0,i.useState)([]),[ek,eA]=(0,i.useState)([]),[eW,eH]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eY,eJ]=(0,i.useState)(null),[e$,eX]=(0,i.useState)(0),[e1,e2]=(0,i.useState)({}),[e4,e5]=(0,i.useState)([]),[e3,e8]=(0,i.useState)(!1),[e6,e7]=(0,i.useState)(null),[e9,le]=(0,i.useState)(null),[ll,ls]=(0,i.useState)([]),[lt,la]=(0,i.useState)(!1),[lr,ln]=(0,i.useState)(null),[lo,lc]=(0,i.useState)(!1),[lm,lu]=(0,i.useState)(null),lh=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!n||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),W(e);let r=null==e6?void 0:e6.token;void 0===r&&(r=null);let i=e9;void 0===i&&(i=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,x.o6)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model metrics response:",o),em(o.data),ex(o.all_api_bases);let d=await (0,x.Rg)(l,e,s.toISOString(),a.toISOString());ej(d.data),eZ(d.all_api_bases);let c=await (0,x.N8)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);console.log("Model exceptions response:",c),ey(c.data),eb(c.exception_types);let m=await (0,x.fP)(l,n,t,e,s.toISOString(),a.toISOString(),r,i);if(console.log("slowResponses:",m),eA(m),e){let t=await (0,x.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e2(t);let r=await (0,x.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);e5(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,i.useEffect)(()=>{lh(K,eW.from,eW.to)},[e6,e9]);let lx=e=>{z(e),L(!0)},lp=()=>{v(new Date().toLocaleString())},lj=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eY);try{await (0,x.K_)(l,{router_settings:{model_group_retry_policy:eY}}),I.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),I.ZP.error("Failed to save retry settings")}};if((0,i.useEffect)(()=>{if(!l||!s||!t||!n)return;let e=async()=>{try{var e,s,a,r,i,o,d,m,u,h,p,j;let g=await (0,x.hy)(l);A(g);let f=await (0,x.AZ)(l,n,t);console.log("Model data response:",f.data),c(f);let Z=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",K);let v=await (0,x.o6)(l,n,t,y,null===(e=eW.from)||void 0===e?void 0:e.toISOString(),null===(s=eW.to)||void 0===s?void 0:s.toISOString(),null==e6?void 0:e6.token,e9);console.log("Model metrics response:",v),em(v.data),ex(v.all_api_bases);let b=await (0,x.Rg)(l,y,null===(a=eW.from)||void 0===a?void 0:a.toISOString(),null===(r=eW.to)||void 0===r?void 0:r.toISOString());ej(b.data),eZ(b.all_api_bases);let w=await (0,x.N8)(l,n,t,y,null===(i=eW.from)||void 0===i?void 0:i.toISOString(),null===(o=eW.to)||void 0===o?void 0:o.toISOString(),null==e6?void 0:e6.token,e9);console.log("Model exceptions response:",w),ey(w.data),eb(w.exception_types);let N=await (0,x.fP)(l,n,t,y,null===(d=eW.from)||void 0===d?void 0:d.toISOString(),null===(m=eW.to)||void 0===m?void 0:m.toISOString(),null==e6?void 0:e6.token,e9),S=await (0,x.n$)(l,null===(u=eW.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=eW.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);e2(S);let k=await (0,x.v9)(l,null===(p=eW.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=eW.to)||void 0===j?void 0:j.toISOString().split("T")[0],y);e5(k),console.log("dailyExceptions:",S),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",N),eA(N);let I=await (0,x.j2)(l);ls(null==I?void 0:I.end_users);let C=(await (0,x.BL)(l,n,t)).router_settings;console.log("routerSettingsInfo:",C);let P=C.model_group_retry_policy,E=C.num_retries;console.log("model_group_retry_policy:",P),console.log("default_retries:",E),eJ(P),eX(E)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&n&&e();let a=async()=>{let e=await (0,x.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),_(e)};null==Z&&a(),lp()},[l,s,t,n,Z,y]),!o||!l||!s||!t||!n)return(0,r.jsx)("div",{children:"Loading..."});let lg=[],lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(Z)),null!=Z&&"object"==typeof Z&&e in Z)?Z[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(r=t)||(r=1===e.length?u(s):l)}else r="-";a&&(i=null==a?void 0:a.input_cost_per_token,n=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==l?void 0:l.litellm_params)&&(m=Object.fromEntries(Object.entries(null==l?void 0:l.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),o.data[e].provider=r,o.data[e].input_cost=i,o.data[e].output_cost=n,o.data[e].litellm_model_name=s,lf.push(r),o.data[e].input_cost&&(o.data[e].input_cost=(1e6*Number(o.data[e].input_cost)).toFixed(2)),o.data[e].output_cost&&(o.data[e].output_cost=(1e6*Number(o.data[e].output_cost)).toFixed(2)),o.data[e].max_tokens=d,o.data[e].max_input_tokens=c,o.data[e].api_base=null==l?void 0:null===(ly=l.litellm_params)||void 0===ly?void 0:ly.api_base,o.data[e].cleanedLitellmParams=m,lg.push(l.model_name),console.log(o.data[e])}if(o.data&&o.data.length>0&&o.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lv=async()=>{try{I.ZP.info("Running health check..."),M("");let e=await (0,x.EY)(l);M(e)}catch(e){console.error("Error running health check:",e),M("Error running health check")}},lb=(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Select API Key Name"}),m?(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{e7(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{le(e)},children:e},l))]})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{e7(null)},children:"All Keys"},"all-keys"),null==d?void 0:d.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsxs)(et.Z,{value:String(l),disabled:!0,onClick:()=>{e7(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(b.Z,{className:"mt-1",children:"Select Customer Name"}),(0,r.jsxs)(es.Z,{defaultValue:"all-customers",children:[(0,r.jsx)(et.Z,{value:"all-customers",onClick:()=>{le(null)},children:"All Customers"},"all-customers"),null==ll?void 0:ll.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{le(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lw=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let i=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,n=t.sort((e,l)=>l.value-e.value);if(n.length>5){let e=n.length-5;(n=n.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,r.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[i&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",i]}),n.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,r.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,r.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})};console.log("selectedProvider: ".concat(E)),console.log("providerModels.length: ".concat(N.length));let lN=Object.keys(a).find(e=>a[e]===E);return(lN&&C.find(e=>e.name===eC[lN]),lm)?(0,r.jsx)("div",{className:"w-full h-full",children:(0,r.jsx)(eQ,{teamId:lm,onClose:()=>lu(null),accessToken:l,is_team_admin:"Admin"===t,is_proxy_admin:"Proxy Admin"===t,userModels:lg,editTeam:!1})}):(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:lr?(0,r.jsx)(e0,{modelId:lr,editModel:!0,onClose:()=>{ln(null),lc(!1)},modelData:o.data.find(e=>e.model_info.id===lr),accessToken:l,userID:n,userRole:t,setEditModalVisible:L,setSelectedModel:z}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"All Models"}),(0,r.jsx)(ei.Z,{children:"Add Model"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(ei.Z,{children:"Model Analytics"}),(0,r.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[y&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",y]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lp})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||void 0,onValueChange:e=>W("all"===e?"all":e),value:K||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Model ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(Q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsxs)(Q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,r.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created At":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:m?"Created By":(0,r.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,r.jsx)(Q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Team ID"}),(0,r.jsx)(Q.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:o.data.filter(e=>"all"===K||e.model_name===K||null==K||""===K).map((e,s)=>{var a;return(0,r.jsxs)(ee.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.model_info.id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>ln(e.model_info.id),children:[e.model_info.id.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:eM(e)||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[e.provider&&(0,r.jsx)("img",{src:eP(e.provider).logo,alt:"".concat(e.provider," logo"),className:"w-4 h-4",onError:l=>{let s=l.target,t=s.parentElement;if(t){var a;let l=document.createElement("div");l.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",l.textContent=(null===(a=e.provider)||void 0===a?void 0:a.charAt(0))||"-",t.replaceChild(l,s)}}}),(0,r.jsx)("p",{className:"text-xs",children:e.provider||"-"})]})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.litellm_model_name,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.litellm_model_name?e.litellm_model_name:"",children:e&&e.litellm_model_name?e.litellm_model_name.slice(0,20)+(e.litellm_model_name.length>20?"...":""):"-"})})}),"Admin"===t&&(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)(R.Z,{title:e&&e.api_base,children:(0,r.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:null!=e.litellm_params.input_cost_per_token&&void 0!=e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&((a=e.model_info.created_at)?new Date(a).toLocaleDateString("en-US"):null)||"-"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("div",{className:"overflow-hidden",children:e.model_info.team_id?(0,r.jsx)(R.Z,{title:e.model_info.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-purple-500 bg-purple-50 hover:bg-purple-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{lu(e.model_info.team_id)},children:[e.model_info.team_id.slice(0,7),"..."]})}):"-"})}),(0,r.jsx)($.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,r.jsx)(ea.Z,{size:"xs",className:"text-white",children:(0,r.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,r.jsx)(ea.Z,{size:"xs",className:"text-black",children:(0,r.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,r.jsx)($.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>lx(e)})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eK,{modelID:e.model_info.id,accessToken:l,callback:lp})})]})})]},s)})})]})})]}),(0,r.jsx)(eL,{visible:D,onCancel:()=>{L(!1),z(null)},model:F,onSubmit:e=>eD(e,l,L,z)})]}),(0,r.jsx)(ed.Z,{className:"h-full",children:(0,r.jsx)(li,{form:j,handleOk:()=>{j.validateFields().then(e=>{eT(e,l,j,lp)}).catch(e=>{console.error("Validation failed:",e)})},selectedProvider:E,setSelectedProvider:O,providerModels:N,setProviderModelsFn:e=>{let l=eO(e,Z);S(l),console.log("providerModels: ".concat(l))},getPlaceholder:eE,uploadProps:{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;j.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?I.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&I.ZP.error("".concat(e.file.name," file upload failed."))}},showAdvancedSettings:lt,setShowAdvancedSettings:la,teams:u})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(f.Z,{onClick:lv,children:"Run `/health`"}),T&&(0,r.jsx)("pre",{children:JSON.stringify(T,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:eW,className:"mr-2",onValueChange:e=>{eH(e),lh(K,e.from,e.to)}})]}),(0,r.jsxs)(eV.Z,{className:"ml-2",children:[(0,r.jsx)(b.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:K||U[0],value:K||U[0],children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lh(e,eW.from,eW.to),children:e},l))})]}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(eq.Z,{trigger:"click",content:lb,overlayStyle:{width:"20vw"},children:(0,r.jsx)(f.Z,{icon:ef.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>e8(!0)})})})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,r.jsx)(b.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),el&&eh&&(0,r.jsx)(ez.Z,{title:"Model Latency",className:"h-72",data:el,showLegend:!1,index:"date",categories:eh,connectNulls:!0,customTooltip:lw})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(eG,{modelMetrics:ep,modelMetricsCategories:eg,customTooltip:lw,premiumUser:m})})]})]})})}),(0,r.jsx)(eV.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Deployment"}),(0,r.jsx)(Q.Z,{children:"Success Responses"}),(0,r.jsxs)(Q.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(J.Z,{children:ek.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.api_base}),(0,r.jsx)($.Z,{children:e.total_count}),(0,r.jsx)($.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Exceptions for ",K]}),(0,r.jsx)(eU.Z,{className:"h-60",data:e_,index:"model",categories:ev,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.Z,{children:["All Up Rate Limit Errors (429) for ",K]}),(0,r.jsxs)(g.Z,{numItems:1,children:[(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e1.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e1.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eV.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:e4.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,r.jsx)(r.Fragment,{children:e4&&e4.length>0&&e4.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,r.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,r.jsx)(f.Z,{variant:"primary",className:"mb-2",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.api_base}),(0,r.jsx)(g.Z,{numItems:1,children:(0,r.jsxs)(eV.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:K||U[0],value:K||U[0],onValueChange:e=>W(e),children:U.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>W(e),children:e},l))})]}),(0,r.jsxs)(w.Z,{children:["Retry Policy for ",K]}),(0,r.jsx)(b.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),ld&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(ld).map((e,l)=>{var s;let[t,a]=e,i=null==eY?void 0:null===(s=eY[K])||void 0===s?void 0:s[a];return null==i&&(i=e$),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(P.Z,{className:"ml-5",value:i,min:0,step:1,onChange:e=>{eJ(l=>{var s;let t=null!==(s=null==l?void 0:l[K])&&void 0!==s?s:{};return{...null!=l?l:{},[K]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(f.Z,{className:"mt-6 mr-8",onClick:lj,children:"Save"})]})]})]})})};function lm(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:i,Paragraph:n}=eS.default,o=()=>(null==a?void 0:a.has_user_setup_sso)?new URL("/ui",t).toString():new URL("/ui?invitation_id=".concat(null==a?void 0:a.id),t).toString();return(0,r.jsxs)(C.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(n,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(b.Z,{children:null==a?void 0:a.user_id})]}),(0,r.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,r.jsx)(b.Z,{children:"Invitation Link"}),(0,r.jsx)(b.Z,{children:(0,r.jsx)(b.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>I.ZP.success("Copied!"),children:(0,r.jsx)(f.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:lu}=S.default;var lh=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,i.useState)(null),[c]=k.Z.useForm(),[m,u]=(0,i.useState)(!1),[h,p]=(0,i.useState)(null),[j,g]=(0,i.useState)([]),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(null),N=(0,n.useRouter)(),[A,P]=(0,i.useState)("http://localhost:4000");(0,i.useEffect)(()=>{(async()=>{try{let e=await (0,x.So)(s,l,"any"),t=[];for(let l=0;l{N&&P(new URL("/",window.location.href).toString())},[N]);let T=async e=>{try{var t;I.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,x.Ov)(s,null,e);console.log("user create Response:",a),p(a.key);let r=(null===(t=a.data)||void 0===t?void 0:t.user_id)||a.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:r,is_accepted:!1,accepted_at:null,expires_at:new Date(Date.now()+6048e5),created_at:new Date,created_by:l,updated_at:new Date,updated_by:l,has_user_setup_sso:!0};w(e),y(!0)}else(0,x.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,w(e),y(!0)});I.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(C.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),p(null),c.resetFields()},children:[(0,r.jsx)(b.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(k.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(S.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(lu,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(lu,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(k.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(lm,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:y,baseUrl:A,invitationLinkData:v})]})},lx=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:n}=e,[o,d]=(0,i.useState)(a),[c]=k.Z.useForm();(0,i.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{n(e),c.resetFields(),t()};return a?(0,r.jsx)(C.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(k.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(S.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,r.jsx)(et.Z,{value:l,title:s,children:(0,r.jsxs)("div",{className:"flex",children:[s," ",(0,r.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,r.jsx)(k.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",help:"Across all keys (including keys with team_id).",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)(k.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",help:"Ignored if the key has a team_id; team budget applies there.",children:(0,r.jsx)(P.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var lp=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:n,teams:o,setKeys:d}=e,[c,m]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(1),[y,v]=i.useState(null),[b,w]=(0,i.useState)(null),[N,S]=(0,i.useState)(!1),[k,C]=(0,i.useState)(null),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(null),[T,M]=(0,i.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let D=e=>{O(e),P(!0)},L=async()=>{if(E&&l)try{if(await (0,x.Eb)(l,[E]),I.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==E);h(e)}}catch(e){console.error("Error deleting user:",e),I.ZP.error("Failed to delete user")}P(!1),O(null)},F=async()=>{C(null),S(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&n){try{await (0,x.pf)(l,e,null),I.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}u&&h(u.map(l=>l.user_id===e.user_id?e:l)),C(null),S(!1)}};return((0,i.useEffect)(()=>{if(!l||!s||!a||!n)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,x.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)M(JSON.parse(s));else{let e=await (0,x.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),M(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&n&&e()},[l,s,a,n,Z]),u&&l&&s&&a&&n)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(g.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(lh,{userID:n,accessToken:l,teams:o,possibleUIRoles:T}),(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,r.jsx)("div",{className:"mb-4 mt-1"}),(0,r.jsx)(en.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(Y.Z,{className:"mt-5",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"User Email"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(Q.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(Q.Z,{children:"API Keys"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.user_id||"-"}),(0,r.jsx)($.Z,{children:e.user_email||"-"}),(0,r.jsx)($.Z,{children:(null==T?void 0:null===(l=T[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,r.jsx)($.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)($.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)($.Z,{children:(0,r.jsx)(g.Z,{numItems:2,children:e.key_count>0?(0,r.jsxs)(ea.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,r.jsx)(ea.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,onClick:()=>{C(e),S(!0)},children:"View Keys"}),(0,r.jsx)(eR.Z,{icon:eh.Z,onClick:()=>D(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,r.jsx)(lx,{visible:N,possibleUIRoles:T,onCancel:F,user:k,onSubmit:R}),A&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,r.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),_(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,r.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},lj=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,i.useState)([]);(0,i.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,x.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let n=async e=>{if(l&&s)try{await (0,x.cu)(l,e,{user_id:s,role:"user"}),I.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),I.ZP.error("Failed to join team")}};return(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Description"}),(0,r.jsx)(Q.Z,{children:"Members"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsxs)(J.Z,{children:[t.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.team_alias})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.description||"No description available"})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"flex flex-col",children:e.models&&0!==e.models.length?e.models.map((e,l)=>(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,r.jsx)(ea.Z,{size:"xs",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{size:"xs",variant:"secondary",onClick:()=>n(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(b.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};let lg=(e,l)=>{let s=[];return e&&e.models.length>0?(console.log("organization.models: ".concat(e.models)),s=e.models):s=l,D(s,l)};var lf=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:n,userRole:o,organizations:d}=e,[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(null),[w,N]=(0,i.useState)(null);(0,i.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&p(t,n,o,u,a),eO()},[c]);let[A]=k.Z.useForm(),[E]=k.Z.useForm(),{Title:D,Paragraph:L}=eS.default,[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(!1),[es,et]=(0,i.useState)(!1),[em,ex]=(0,i.useState)(!1),[ep,ej]=(0,i.useState)(!1),[eg,ef]=(0,i.useState)([]),[eZ,e_]=(0,i.useState)(!1),[ey,ev]=(0,i.useState)(null),[eb,ew]=(0,i.useState)([]),[eN,ek]=(0,i.useState)({}),[eI,eC]=(0,i.useState)([]);(0,i.useEffect)(()=>{console.log("currentOrgForCreateTeam: ".concat(w));let e=lg(w,eg);console.log("models: ".concat(e)),ew(e),A.setFieldValue("models",[])},[w,eg]),(0,i.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,x.t3)(t)).guardrails.map(e=>e.guardrail_name);eC(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let eA=async e=>{ev(e),e_(!0)},eP=async()=>{if(null!=ey&&null!=l&&null!=t){try{await (0,x.rs)(t,ey),p(t,n,o,u,a)}catch(e){console.error("Error deleting the team:",e)}e_(!1),ev(null)}};(0,i.useEffect)(()=>{(async()=>{try{if(null===n||null===o||null===t)return;let e=await T(n,o,t);e&&ef(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,n,o,l]);let eE=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,i=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],n=(null==e?void 0:e.organization_id)||(null==u?void 0:u.organization_id);if(""===n||"string"!=typeof n?e.organization_id=null:e.organization_id=n.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,i.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));I.ZP.info("Creating Team");let o=await (0,x.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),I.ZP.success("Team created"),et(!1)}}catch(e){console.error("Error creating the team:",e),I.ZP.error("Error creating the team: "+e,20)}},eO=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:W?(0,r.jsx)(eQ,{teamId:W,onClose:()=>{H(null),el(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===W)),is_proxy_admin:"Admin"==o,userModels:eg,editTeam:G}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Your Teams"}),(0,r.jsx)(ei.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:eO})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(b.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-hidden overflow-y-auto max-h-[50vh]",children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Team Name"}),(0,r.jsx)(Q.Z,{children:"Team ID"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"Organization"}),(0,r.jsx)(Q.Z,{children:"Info"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.filter(e=>!u||e.organization_id===u.organization_id).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{H(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)($.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!==e.max_budget&&void 0!==e.max_budget?e.max_budget:"No limit"}),(0,r.jsx)($.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:(0,r.jsx)(b.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(b.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)($.Z,{children:e.organization_id}),(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].keys&&eN[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(b.Z,{children:[eN&&e.team_id&&eN[e.team_id]&&eN[e.team_id].members_with_roles&&eN[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)($.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{H(e.team_id),el(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>eA(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),eZ&&(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:eP,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{e_(!1),ev(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>et(!0),children:"+ Create New Team"}),(0,r.jsx)(C.Z,{title:"Create Team",visible:es,width:800,footer:null,onOk:()=>{et(!1),A.resetFields()},onCancel:()=>{et(!1),A.resetFields()},children:(0,r.jsxs)(k.Z,{form:A,onFinish:eE,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Organization",name:"organization_id",initialValue:u?u.organization_id:null,className:"mt-8",children:(0,r.jsx)(S.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{A.setFieldValue("organization_id",e),N((null==d?void 0:d.find(l=>l.organization_id===e))||null)},filterOption:(e,l)=>{var s;return!!l&&((null===(s=l.children)||void 0===s?void 0:s.toString())||"").toLowerCase().includes(e.toLowerCase())},optionFilterProp:"children",children:null==d?void 0:d.map(e=>(0,r.jsxs)(S.default.Option,{value:e.organization_id,children:[(0,r.jsx)("span",{className:"font-medium",children:e.organization_alias})," ",(0,r.jsxs)("span",{className:"text-gray-500",children:["(",e.organization_id,")"]})]},e.organization_id))})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Models"," ",(0,r.jsx)(R.Z,{title:"These are the models that your selected organization has access to",children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})]}),name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),eb.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Additional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Team ID",name:"team_id",help:"ID of the team you want to create. If not provided, it will be generated automatically.",children:(0,r.jsx)(Z.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(k.Z.Item,{label:(0,r.jsxs)("span",{children:["Guardrails"," ",(0,r.jsx)(R.Z,{title:"Setup your first guardrail",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(F.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,r.jsx)(S.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eI.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lj,{accessToken:t,userID:n})})]})]})})},lZ=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:n,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,i.useState)(null),[h,p]=(0,i.useState)(!0),[j]=k.Z.useForm(),[Z,_]=(0,i.useState)(!1),[y,v]=(0,i.useState)(!1),[N,C]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),D=n||o,L=async()=>{try{if(p(!0),!a)return;let e=await (0,x.t$)(a,s);u(e)}catch(e){I.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{p(!1)}};(0,i.useEffect)(()=>{L()},[s,a]);let F=async e=>{try{if(null==a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.vh)(a,s,l),I.ZP.success("Organization member added successfully"),v(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to add organization member"),console.error("Error adding organization member:",e)}},R=async e=>{try{if(!a)return;let l={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,x.LY)(a,s,l),I.ZP.success("Organization member updated successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,x.Sb)(a,s,e.user_id),I.ZP.success("Organization member deleted successfully"),C(!1),j.resetFields(),L()}catch(e){I.ZP.error("Failed to delete organization member"),console.error("Error deleting organization member:",e)}},U=async e=>{try{if(!a)return;let l={organization_id:s,organization_alias:e.organization_alias,models:e.models,litellm_budget_table:{tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,max_budget:e.max_budget,budget_duration:e.budget_duration}};if(!(await fetch("/organization/update",{method:"POST",headers:{Authorization:"Bearer ".concat(a),"Content-Type":"application/json"},body:JSON.stringify(l)})).ok)throw Error("Failed to update organization");I.ZP.success("Organization settings updated successfully"),_(!1),L()}catch(e){I.ZP.error("Failed to update organization settings"),console.error("Error updating organization:",e)}};return h?(0,r.jsx)("div",{className:"p-4",children:"Loading..."}):m?(0,r.jsxs)("div",{className:"w-full h-screen p-4 bg-white",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(O.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(w.Z,{children:m.organization_alias}),(0,r.jsx)(b.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(en.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(ei.Z,{children:"Overview"}),(0,r.jsx)(ei.Z,{children:"Members"}),(0,r.jsx)(ei.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(b.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(b.Z,{children:["of ",null===m.litellm_budget_table.max_budget?"Unlimited":"$".concat(m.litellm_budget_table.max_budget)]}),m.litellm_budget_table.budget_duration&&(0,r.jsxs)(b.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(b.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(b.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(b.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[75vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"User ID"}),(0,r.jsx)(Q.Z,{children:"Role"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Created At"}),(0,r.jsx)(Q.Z,{})]})}),(0,r.jsx)(J.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)($.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{T({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),C(!0)}}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(f.Z,{onClick:()=>{v(!0)},children:"Add Member"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(w.Z,{children:"Organization Settings"}),D&&!Z&&(0,r.jsx)(f.Z,{onClick:()=>_(!0),children:"Edit Settings"})]}),Z?(0,r.jsxs)(k.Z,{form:j,onFinish:U,initialValues:{organization_alias:m.organization_alias,models:m.models,tpm_limit:m.litellm_budget_table.tpm_limit,rpm_limit:m.litellm_budget_table.rpm_limit,max_budget:m.litellm_budget_table.max_budget,budget_duration:m.litellm_budget_table.budget_duration},layout:"vertical",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(O.ZP,{onClick:()=>_(!1),children:"Cancel"}),(0,r.jsx)(f.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Organization ID"}),(0,r.jsx)("div",{className:"font-mono",children:m.organization_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(m.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:m.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==m.litellm_budget_table.max_budget?"$".concat(m.litellm_budget_table.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",m.litellm_budget_table.budget_duration||"Never"]})]})]})]})})]})]}),(0,r.jsx)(eX,{isVisible:y,onCancel:()=>v(!1),onSubmit:F,accessToken:a,title:"Add Organization Member",roles:[{label:"org_admin",value:"org_admin",description:"Can add and remove members, and change their roles."},{label:"internal_user",value:"internal_user",description:"Can view/create keys for themselves within organization."},{label:"internal_user_viewer",value:"internal_user_viewer",description:"Can only view their keys within organization."}],defaultRole:"internal_user"}),(0,r.jsx)(eY,{visible:N,onCancel:()=>C(!1),onSubmit:R,initialData:A,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Org Admin",value:"org_admin"},{label:"Internal User",value:"internal_user"},{label:"Internal User Viewer",value:"internal_user_viewer"}]}})]}):(0,r.jsx)("div",{className:"p-4",children:"Organization not found"})};let l_=async(e,l)=>{l(await (0,x.r6)(e))};var ly=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:n,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,p]=(0,i.useState)(null),[_,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(!1),[N,A]=(0,i.useState)(null),[E,O]=(0,i.useState)(!1),[T]=k.Z.useForm();(0,i.useEffect)(()=>{0===l.length&&a&&l_(a,m)},[l,a]);let D=e=>{e&&(A(e),w(!0))},L=async()=>{if(N&&a)try{await (0,x.cq)(a,N),I.ZP.success("Organization deleted successfully"),w(!1),A(null),l_(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,x.H1)(a,e),O(!1),T.resetFields(),l_(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(lZ,{organizationId:h,onClose:()=>{p(null),y(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:_}):(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsx)("div",{className:"flex",children:(0,r.jsx)(ei.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[n&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",n]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:o})]})]}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(b.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Organization ID"}),(0,r.jsx)(Q.Z,{children:"Organization Name"}),(0,r.jsx)(Q.Z,{children:"Created"}),(0,r.jsx)(Q.Z,{children:"Spend (USD)"}),(0,r.jsx)(Q.Z,{children:"Budget (USD)"}),(0,r.jsx)(Q.Z,{children:"Models"}),(0,r.jsx)(Q.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(Q.Z,{children:"Info"}),(0,r.jsx)(Q.Z,{children:"Actions"})]})}),(0,r.jsx)(J.Z,{children:l&&l.length>0?l.sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>{var l,t,a,i,n,o,d,c,m;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(f.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>p(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)($.Z,{children:e.organization_alias}),(0,r.jsx)($.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)($.Z,{children:e.spend}),(0,r.jsx)($.Z,{children:(null===(t=e.litellm_budget_table)||void 0===t?void 0:t.max_budget)!==null&&(null===(a=e.litellm_budget_table)||void 0===a?void 0:a.max_budget)!==void 0?null===(i=e.litellm_budget_table)||void 0===i?void 0:i.max_budget:"No limit"}),(0,r.jsx)($.Z,{children:Array.isArray(e.models)&&(0,r.jsx)("div",{className:"flex flex-col",children:0===e.models.length?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"}):e.models.map((e,l)=>"all-proxy-models"===e?(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"red",children:"All Proxy Models"},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)},l))})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:["TPM: ",(null===(n=e.litellm_budget_table)||void 0===n?void 0:n.tpm_limit)?null===(o=e.litellm_budget_table)||void 0===o?void 0:o.tpm_limit:"Unlimited",(0,r.jsx)("br",{}),"RPM: ",(null===(d=e.litellm_budget_table)||void 0===d?void 0:d.rpm_limit)?null===(c=e.litellm_budget_table)||void 0===c?void 0:c.rpm_limit:"Unlimited"]})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(b.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)($.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{p(e.organization_id),y(!0)}}),(0,r.jsx)(eR.Z,{onClick:()=>D(e.organization_id),icon:eh.Z,size:"sm"})]})})]},e.organization_id)}):null})]})})}),("Admin"===s||"Org Admin"===s)&&(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>O(!0),children:"+ Create New Organization"}),(0,r.jsx)(C.Z,{title:"Create Organization",visible:E,width:800,footer:null,onCancel:()=>{O(!1),T.resetFields()},children:(0,r.jsxs)(k.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(k.Z.Item,{label:"Organization Name",name:"organization_alias",rules:[{required:!0,message:"Please input an organization name"}],children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(S.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(S.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(S.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(k.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)(k.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(P.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(f.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),v?(0,r.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,r.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,r.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,r.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,r.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,r.jsx)("div",{className:"sm:flex sm:items-start",children:(0,r.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,r.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Organization"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this organization?"})})]})})}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,r.jsx)(f.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(f.Z,{onClick:()=>{w(!1),A(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(b.Z,{children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,r.jsx)("a",{href:"https://litellm.ai/pricing",target:"_blank",rel:"noopener noreferrer",children:"here"}),"."]})})};let lv=()=>{let[e,l]=(0,i.useState)("http://localhost:4000");return(0,i.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lb=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=k.Z.useForm(),[d]=k.Z.useForm(),{Title:c,Paragraph:m}=eS.default,[u,h]=(0,i.useState)(""),[p,j]=(0,i.useState)(null),[Z,_]=(0,i.useState)(null),[y,v]=(0,i.useState)(!1),[w,N]=(0,i.useState)(!1),[S,A]=(0,i.useState)(!1),[P,T]=(0,i.useState)(!1),[M,D]=(0,i.useState)(!1),[L,F]=(0,i.useState)(!1),[R,z]=(0,i.useState)(!1),[U,V]=(0,i.useState)(!1),[q,B]=(0,i.useState)(!1),[K,W]=(0,i.useState)([]),[H,G]=(0,i.useState)(null);(0,n.useRouter)();let[el,es]=(0,i.useState)(null);console.log=function(){};let et=lv(),ea="All IP Addresses Allowed",ei=et;ei+="/fallback/login";let en=async()=>{try{if(!0!==a){I.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,x.PT)(s);W(e&&e.length>0?e:[ea])}else W([ea])}catch(e){console.error("Error fetching allowed IPs:",e),I.ZP.error("Failed to fetch allowed IPs ".concat(e)),W([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,x.eH)(s,e.ip);let l=await (0,x.PT)(s);W(l),I.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),I.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{G(e),B(!0)},ec=async()=>{if(H&&s)try{await (0,x.$I)(s,H);let e=await (0,x.PT)(s);W(e.length>0?e:[ea]),I.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),I.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),G(null)}},em=()=>{F(!1)};(0,i.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,x.Xd)(s,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let t=l.users;console.log("proxy viewers response: ".concat(t)),t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(t));let a=(await (0,x.Xd)(s,"proxy_admin")).users;a.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(a)),console.log("combinedList: ".concat(e)),j(e),es(await (0,x.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=p){var l;I.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,x.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,x.XO)(s,a).then(e=>{_(e),v(!0)}),console.log("response for team create call: ".concat(t));let r=p.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===t.user_id));console.log("foundIndex: ".concat(r)),-1==r&&(console.log("updates admin with new user"),p.push(t),j(p)),o.resetFields(),A(!1)}}catch(e){console.error("Error creating the key:",e)}},eh=async e=>{if(null==s)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,x.K_)(s,l)};return console.log("admins: ".concat(null==p?void 0:p.length)),(0,r.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,r.jsx)(c,{level:4,children:"Admin Access "}),(0,r.jsx)(m,{children:"Go to 'Internal Users' page to add other admins."}),(0,r.jsxs)(g.Z,{children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(c,{level:4,children:" ✨ Security Settings"}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:()=>!0===a?D(!0):I.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(f.Z,{onClick:en,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(C.Z,{title:"Add SSO",visible:M,width:800,footer:null,onOk:()=>{D(!1),o.resetFields()},onCancel:()=>{D(!1),o.resetFields()},children:(0,r.jsxs)(k.Z,{form:o,onFinish:e=>{eu(e),eh(e),D(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,r.jsx)(E.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,r.jsx)(E.Z.Password,{})}),(0,r.jsx)(k.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,r.jsx)(E.Z.Password,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(C.Z,{title:"SSO Setup Instructions",visible:L,width:800,footer:null,onOk:em,onCancel:()=>{F(!1)},children:[(0,r.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(b.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(C.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(f.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"IP Address"}),(0,r.jsx)(Q.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(J.Z,{children:K.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e}),(0,r.jsx)($.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(f.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(C.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(k.Z,{onFinish:eo,children:[(0,r.jsx)(k.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,r.jsx)(E.Z,{placeholder:"Enter IP address"})}),(0,r.jsx)(k.Z.Item,{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(C.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(f.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(f.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",H,"?"]})})]}),(0,r.jsxs)(eW.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:ei,target:"_blank",children:[(0,r.jsx)("b",{children:ei})," "]})]})]})]})},lw=s(92858),lN=s(44643),lS=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:i}=e,[n]=k.Z.useForm();return(0,r.jsxs)(k.Z,{form:n,onFinish:()=>{console.log("INSIDE ONFINISH");let e=n.getFieldsValue(),l=Object.entries(e).every(e=>{let[l,s]=e;return"boolean"!=typeof s&&(""===s||null==s)});console.log("formData: ".concat(JSON.stringify(e),", isEmpty: ").concat(l)),l?console.log("Some form fields are empty."):a(e)},labelAlign:"left",children:[l.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{align:"center",children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?i?(0,r.jsx)(k.Z.Item,{name:e.field_name,children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lw.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,r.jsx)(k.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)($.Z,{children:"Integer"===e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lw.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),n.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lN.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lk=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(0,x.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lS,{alertingSettings:t,handleInputChange:(e,l)=>{let s=t.map(s=>s.field_name===e?{...s,field_value:l}:s);console.log("updatedSettings: ".concat(JSON.stringify(s))),a(s)},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);a(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||(console.log("formValues: ".concat(e)),null==e||void 0==e))return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let a={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(a)));let{slack_alerting:r,...i}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(i)));try{(0,x.jA)(l,"alerting_args",i),"boolean"==typeof r&&(!0==r?(0,x.jA)(l,"alerting",["slack"]):(0,x.jA)(l,"alerting",[])),I.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lI=s(86582);let{Title:lC,Paragraph:lA}=eS.default;console.log=function(){};var lP=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[n,o]=(0,i.useState)([]),[d,c]=(0,i.useState)([]),[m,u]=(0,i.useState)(!1),[h]=k.Z.useForm(),[p,j]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,w]=(0,i.useState)(""),[N,A]=(0,i.useState)({}),[P,E]=(0,i.useState)([]),[T,M]=(0,i.useState)(!1),[D,L]=(0,i.useState)([]),[F,R]=(0,i.useState)(null),[z,U]=(0,i.useState)([]),[V,q]=(0,i.useState)(!1),[B,K]=(0,i.useState)(null),W=e=>{P.includes(e)?E(P.filter(l=>l!==e)):E([...P,e])},H={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,i.useEffect)(()=>{l&&s&&t&&(0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),L(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),E(e.active_alerts),w(s),A(e.alerts_to_webhook)}c(l)})},[l,s,t]);let G=e=>P&&P.includes(e),el=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));a&&a.value&&(e[s]=null==a?void 0:a.value)})}),console.log("updatedVariables",e);try{(0,x.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Email settings updated successfully")},es=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,x.K_)(l,{environment_variables:s}),I.ZP.success("Callback added successfully"),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},ea=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,x.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),I.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),j(null)}catch(e){I.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),j(e.litellm_callback_name),console.log("all callbacks",D),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(n)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(lC,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(g.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)(Q.Z,{children:"Callback Name"})})}),(0,r.jsx)(J.Z,{children:n.map((e,s)=>(0,r.jsxs)(ee.Z,{className:"flex justify-between",children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.name})}),(0,r.jsx)($.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>M(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(b.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,r.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{}),(0,r.jsx)(Q.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(H).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lw.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)}):(0,r.jsx)(f.Z,{className:"flex items-center justify-center",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,r.jsx)(lw.Z,{id:"switch",name:"switch",checked:G(s),onChange:()=>W(s)})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:t})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:N&&N[s]?N[s]:v})})]},l)})})]}),(0,r.jsx)(f.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(H).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let r=(null==a?void 0:a.value)||"";console.log("newWebhookValue",r),e[s]=r}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:P}};console.log("payload",s);try{(0,x.K_)(l,s)}catch(e){I.ZP.error("Failed to update alerts: "+e,20)}I.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lk,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(lC,{level:4,children:"Email Settings"}),(0,r.jsxs)(b.Z,{children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,r.jsx)("br",{})]}),(0,r.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,r.jsx)($.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(g.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,r.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,r.jsxs)("div",{children:[(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,r.jsxs)(b.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)(b.Z,{className:"mt-2",children:l}),(0,r.jsx)(Z.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,r.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,r.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,r.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,r.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,r.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(f.Z,{onClick:()=>(0,x.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(C.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>M(!1),footer:null,children:[(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,r.jsx)(k.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lI.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(S.default,{onChange:e=>{let l=D[e];l&&(console.log(l.ui_callback_name),em(l))},children:D&&Object.values(D).map(e=>(0,r.jsx)(et.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),z&&z.map(e=>(0,r.jsx)(lI.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,r.jsx)(Z.Z,{type:"password"})},e)),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(C.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(k.Z,{form:h,onFinish:es,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(r.Fragment,{children:B&&B.variables&&Object.entries(B.variables).map(e=>{let[l,s]=e;return(0,r.jsx)(lI.Z,{label:l,name:l,children:(0,r.jsx)(Z.Z,{type:"password",defaultValue:s})},l)})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lE=s(92414),lO=s(46030);let{Option:lT}=S.default;var lM=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[n]=k.Z.useForm(),[o,d]=(0,i.useState)(!1),[c,m]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(C.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),n.resetFields()},onCancel:()=>{d(!1),n.resetFields()},children:(0,r.jsxs)(k.Z,{form:n,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,i=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:i};console.log(o);try{(0,x.K_)(s,{router_settings:o}),a(o)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully"),d(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,r.jsx)(es.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,r.jsx)(k.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lE.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lO.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lD=s(33619);async function lL(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lD.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});I.ZP.success((0,r.jsxs)("span",{children:["Test model=",(0,r.jsx)("strong",{children:e}),", received model=",(0,r.jsx)("strong",{children:l.model}),". See"," ",(0,r.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lF={ttl:3600,lowest_latency_buffer:0},lR=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,r.jsxs)(_.Z,{children:[(0,r.jsx)(v.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,r.jsx)(y.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)($.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(b.Z,{children:"No specific settings"})})]})};var lz=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)({}),[d,c]=(0,i.useState)({}),[m,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[_]=k.Z.useForm(),[y,v]=(0,i.useState)(null),[N,S]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,i.useEffect)(()=>{l&&s&&t&&((0,x.BL)(l,t,s).then(e=>{console.log("callbacks",e);let l=e.router_settings;"model_group_retry_policy"in l&&delete l.model_group_retry_policy,o(l)}),(0,x.YU)(l).then(e=>{u(e)}))},[l,s,t]);let O=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(n.fallbacks));let s=n.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...n,fallbacks:s};try{await (0,x.K_)(l,{router_settings:t}),o(t),I.ZP.success("Router settings updated successfully")}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}},T=(e,l)=>{u(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},M=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,x.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,x.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(s)}catch(e){}},L=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,x.K_)(l,{router_settings:s})}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(w.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"})]})}),(0,r.jsx)(J.Z,{children:Object.entries(n).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,r.jsx)($.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:S,children:[(0,r.jsx)(et.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,r.jsx)(et.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,r.jsx)(et.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,r.jsx)(lR,{selectedStrategy:N,strategyArgs:n&&n.routing_strategy_args&&Object.keys(n.routing_strategy_args).length>0?n.routing_strategy_args:lF,paramExplanation:E})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(f.Z,{className:"mt-2",onClick:()=>L(n),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Model Name"}),(0,r.jsx)(Q.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(J.Z,{children:n.fallbacks&&n.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:t}),(0,r.jsx)($.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)($.Z,{children:(0,r.jsx)(f.Z,{onClick:()=>lL(t,l),children:"Test Fallback"})}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lM,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:n,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Setting"}),(0,r.jsx)(Q.Z,{children:"Value"}),(0,r.jsx)(Q.Z,{children:"Status"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsxs)($.Z,{children:[(0,r.jsx)(b.Z,{children:e.field_name}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,r.jsx)($.Z,{children:"Integer"==e.field_type?(0,r.jsx)(P.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)($.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lN.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,r.jsx)(ea.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,r.jsxs)($.Z,{children:[(0,r.jsx)(f.Z,{onClick:()=>M(e.field_name,l),children:"Update"}),(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lU=s(93142),lV=s(45246),lq=s(96473),lB=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,i.useState)(Object.entries(l)),n=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let i=[...t];i[e]=[l,r],a(i),null==s||s(Object.fromEntries(i))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lU.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,r.jsx)(Z.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,r.jsx)(Z.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,r.jsx)(lV.Z,{onClick:()=>n(l)})]},l)}),(0,r.jsx)(O.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lq.Z,{}),children:"Add Header"})]})};let{Option:lK}=S.default;var lW=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=k.Z.useForm(),[n,o]=(0,i.useState)(!1),[d,c]=(0,i.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(f.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(C.Z,{title:"Add Pass-Through Endpoint",visible:n,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(k.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,x.Vt)(l,e),s(r)}catch(e){I.ZP.error("Failed to update router settings: "+e,20)}I.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Target",name:"target",rules:[{required:!0,message:"The URL to which requests for this path should be forwarded."}],help:"required",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(k.Z.Item,{label:"Headers",name:"headers",rules:[{required:!0,message:"Key-value pairs of headers to be forwarded with the request. You can set any key value pair here and it will be forwarded to your target endpoint"}],help:"required",children:(0,r.jsx)(lB,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lH=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[n,o]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&s&&t&&(0,x.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,x.EG)(l,e);let s=n.filter(l=>l.path!==e);o(s),I.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Path"}),(0,r.jsx)(Q.Z,{children:"Target"}),(0,r.jsx)(Q.Z,{children:"Headers"}),(0,r.jsx)(Q.Z,{children:"Action"})]})}),(0,r.jsx)(J.Z,{children:n.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:(0,r.jsx)(b.Z,{children:e.path})}),(0,r.jsx)($.Z,{children:e.target}),(0,r.jsx)($.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)($.Z,{children:(0,r.jsx)(eR.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lW,{accessToken:l,setPassThroughItems:o,passThroughItems:n})]})})}):null},lG=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[i]=k.Z.useForm(),n=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call");let l=await (0,x.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),I.ZP.success("API Key Created"),i.resetFields()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),i.resetFields()},onCancel:()=>{t(!1),i.resetFields()},children:(0,r.jsxs)(k.Z,{form:i,onFinish:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lY=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:n,handleUpdateCall:o}=e;console.log("existingBudget",n);let[d]=k.Z.useForm();(0,i.useEffect)(()=>{d.setFieldsValue(n)},[n,d]);let c=async e=>{if(null!=s&&void 0!=s)try{I.ZP.info("Making API Call"),t(!0);let l=await (0,x.qI)(s,e);a(e=>e?[...e,l]:[l]),I.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),I.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(C.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(k.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:n,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(k.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(P.Z,{step:1,precision:2,width:200})}),(0,r.jsxs)(_.Z,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.Z,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(y.Z,{children:[(0,r.jsx)(k.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(P.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(k.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(S.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(S.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(S.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(S.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(O.ZP,{htmlType:"submit",children:"Save"})})]})})},lJ=s(17906),l$=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)(!1),[a,n]=(0,i.useState)(!1),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)([]);(0,i.useEffect)(()=>{l&&(0,x.O3)(l).then(e=>{m(e)})},[l]);let u=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),n(!0))},h=async(e,s)=>{if(null==l)return;I.ZP.info("Request made"),await (0,x.NV)(l,e);let t=[...c];t.splice(s,1),m(t),I.ZP.success("Budget Deleted.")},p=async()=>{null!=l&&(0,x.O3)(l).then(e=>{m(e)})};return(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsx)(f.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lG,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lY,{accessToken:l,isModalVisible:a,setIsModalVisible:n,setBudgetList:m,existingBudget:o,handleUpdateCall:p}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(b.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Budget ID"}),(0,r.jsx)(Q.Z,{children:"Max Budget"}),(0,r.jsx)(Q.Z,{children:"TPM"}),(0,r.jsx)(Q.Z,{children:"RPM"})]})}),(0,r.jsx)(J.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.budget_id}),(0,r.jsx)($.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)($.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)($.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eR.Z,{icon:eB.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eR.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(b.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,r.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="",\n api_key=""\n)\n\ncompletion = client.chat.completions.create(\n model="gpt-3.5-turbo",\n messages=[\n {"role": "system", "content": "You are a helpful assistant."},\n {"role": "user", "content": "Hello!"}\n ],\n user="my-customer-id"\n)\n\nprint(completion.choices[0].message)'})})]})]})]})]})},lX=s(77398),lQ=s.n(lX),l0=s(20016);async function l1(e){try{let l=await fetch("http://ip-api.com/json/".concat(e)),s=await l.json();console.log("ip lookup data",s);let t=s.countryCode?s.countryCode.toUpperCase().split("").map(e=>String.fromCodePoint(e.charCodeAt(0)+127397)).join(""):"";return s.country?"".concat(t," ").concat(s.country):"Unknown"}catch(e){return console.error("Error looking up IP:",e),"Unknown"}}let l2=e=>{let{ipAddress:l}=e,[s,t]=i.useState("-");return i.useEffect(()=>{if(!l)return;let e=!0;return l1(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},l4=e=>{try{return new Date(e).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).replace(",","")}catch(e){return"Error converting time"}},l5=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:l4(l)})},l3=[{id:"expander",header:()=>null,cell:e=>{let{row:l}=e;return l.getCanExpand()?(0,r.jsx)("button",{onClick:l.getToggleExpandedHandler(),style:{cursor:"pointer"},children:l.getIsExpanded()?"▼":"▶"}):"●"}},{header:"Time",accessorKey:"startTime",cell:e=>(0,r.jsx)(l5,{utcTime:e.getValue()})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,r.jsx)(R.Z,{title:String(e.getValue()||""),children:(0,r.jsx)("span",{className:"font-mono text-xs max-w-[100px] truncate block",children:String(e.getValue()||"")})})},{header:"Cost",accessorKey:"spend",cell:e=>(0,r.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Country",accessorKey:"requester_ip_address",cell:e=>(0,r.jsx)(l2,{ipAddress:e.getValue()})},{header:"Team Name",accessorKey:"metadata.user_api_key_team_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Key Hash",accessorKey:"metadata.user_api_key",cell:e=>{let l=String(e.getValue()||"-");return(0,r.jsx)(R.Z,{title:l,children:(0,r.jsxs)("span",{className:"font-mono",children:[l.slice(0,5),"..."]})})}},{header:"Key Name",accessorKey:"metadata.user_api_key_alias",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Model",accessorKey:"model",cell:e=>{let l=e.row.original.custom_llm_provider,s=String(e.getValue()||"");return(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[l&&(0,r.jsx)("img",{src:eP(l).logo,alt:"",className:"w-4 h-4",onError:e=>{e.target.style.display="none"}}),(0,r.jsx)(R.Z,{title:s,children:(0,r.jsx)("span",{className:"max-w-[100px] truncate",children:s})})]})}},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,r.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,r.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"Internal User",accessorKey:"user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"End User",accessorKey:"end_user",cell:e=>(0,r.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();if(!l||0===Object.keys(l).length)return"-";let s=Object.entries(l),t=s[0],a=s.slice(1);return(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:(0,r.jsx)(R.Z,{title:(0,r.jsx)("div",{className:"flex flex-col gap-1",children:s.map(e=>{let[l,s]=e;return(0,r.jsxs)("span",{children:[l,": ",String(s)]},l)})}),children:(0,r.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[t[0],": ",String(t[1]),a.length>0&&" +".concat(a.length)]})})})}}],l8=async(e,l,s,t)=>{console.log("prefetchLogDetails called with",e.length,"logs");let a=e.map(e=>{if(e.request_id)return console.log("Prefetching details for request_id:",e.request_id),t.prefetchQuery({queryKey:["logDetails",e.request_id,l],queryFn:async()=>{console.log("Fetching details for",e.request_id);let t=await (0,x.qk)(s,e.request_id,l);return console.log("Received details for",e.request_id,":",t?"success":"failed"),t},staleTime:6e5,gcTime:6e5})});try{let e=await Promise.all(a);return console.log("All prefetch promises completed:",e.length),e}catch(e){throw console.error("Error in prefetchLogDetails:",e),e}};function l6(e){var l,s,t;let{accessToken:a,token:n,userRole:o,userID:d}=e,[m,u]=(0,i.useState)(""),[h,p]=(0,i.useState)(!1),[j,g]=(0,i.useState)(!1),[f,Z]=(0,i.useState)(1),[_]=(0,i.useState)(50),y=(0,i.useRef)(null),v=(0,i.useRef)(null),b=(0,i.useRef)(null),[w,N]=(0,i.useState)(lQ()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[S,k]=(0,i.useState)(lQ()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,i.useState)(!1),[A,P]=(0,i.useState)(!1),[E,O]=(0,i.useState)(""),[T,M]=(0,i.useState)(""),[D,L]=(0,i.useState)(""),[F,R]=(0,i.useState)(""),[z,U]=(0,i.useState)("Team ID"),V=(0,c.NL)();(0,i.useEffect)(()=>{function e(e){y.current&&!y.current.contains(e.target)&&g(!1),v.current&&!v.current.contains(e.target)&&p(!1),b.current&&!b.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,l0.a)({queryKey:["logs","table",f,_,w,S,D,F],queryFn:async()=>{if(!a||!n||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:_,total_pages:0};let e=lQ()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?lQ()(S).utc().format("YYYY-MM-DD HH:mm:ss"):lQ()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,x.h3)(a,F||void 0,D||void 0,void 0,e,l,f,_);return await l8(s.data,e,a,V),s.data=s.data.map(l=>{let s=V.getQueryData(["logDetails",l.request_id,e]);return(null==s?void 0:s.messages)&&(null==s?void 0:s.response)&&(l.messages=s.messages,l.response=s.response),l}),s},enabled:!!a&&!!n&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!n||!o||!d)return console.log("got None values for one of accessToken, token, userRole, userID"),null;let B=(null===(s=q.data)||void 0===s?void 0:null===(l=s.data)||void 0===l?void 0:l.filter(e=>!m||e.request_id.includes(m)||e.model.includes(m)||e.user&&e.user.includes(m)))||[],K=()=>{if(I)return"".concat(lQ()(w).format("MMM D, h:mm A")," - ").concat(lQ()(S).format("MMM D, h:mm A"));let e=lQ()(),l=lQ()(w),s=e.diff(l,"minutes");if(s<=15)return"Last 15 Minutes";if(s<=60)return"Last Hour";let t=e.diff(l,"hours");return t<=4?"Last 4 Hours":t<=24?"Last 24 Hours":t<=168?"Last 7 Days":"".concat(l.format("MMM D")," - ").concat(e.format("MMM D"))};return(0,r.jsxs)("div",{className:"w-full p-6",children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,r.jsx)("h1",{className:"text-xl font-semibold",children:"Request Logs"})}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"border-b px-6 py-4",children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between space-y-4 md:space-y-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("div",{className:"relative w-64",children:[(0,r.jsx)("input",{type:"text",placeholder:"Search by Request ID",className:"w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:m,onChange:e=>u(e.target.value)}),(0,r.jsx)("svg",{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),(0,r.jsxs)("div",{className:"relative",ref:v,children:[(0,r.jsxs)("button",{className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",onClick:()=>p(!h),children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),"Filter"]}),h&&(0,r.jsx)("div",{className:"absolute left-0 mt-2 w-[500px] bg-white rounded-lg shadow-lg border p-4 z-50",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Where"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>g(!j),className:"px-3 py-1.5 border rounded-md bg-white text-sm min-w-[160px] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-left flex justify-between items-center",children:[z,(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),j&&(0,r.jsx)("div",{className:"absolute left-0 mt-1 w-[160px] bg-white border rounded-md shadow-lg z-50",children:["Team ID","Key Hash"].map(e=>(0,r.jsxs)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 ".concat(z===e?"bg-blue-50 text-blue-600":""),onClick:()=>{U(e),g(!1),"Team ID"===e?M(""):O("")},children:[z===e&&(0,r.jsx)("svg",{className:"h-4 w-4 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e]},e))})]}),(0,r.jsx)("input",{type:"text",placeholder:"Enter value...",className:"px-3 py-1.5 border rounded-md text-sm flex-1 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:"Team ID"===z?E:T,onChange:e=>{"Team ID"===z?O(e.target.value):M(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{O(""),M("")},children:(0,r.jsx)("span",{className:"text-gray-500",children:"\xd7"})})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50",onClick:()=>{O(""),M(""),p(!1)},children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>{L(E),R(T),Z(1),p(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsxs)("button",{onClick:()=>P(!A),className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),K()]}),A&&(0,r.jsx)("div",{className:"absolute right-0 mt-2 w-64 bg-white rounded-lg shadow-lg border p-2 z-50",children:(0,r.jsxs)("div",{className:"space-y-1",children:[[{label:"Last 15 Minutes",value:15,unit:"minutes"},{label:"Last Hour",value:1,unit:"hours"},{label:"Last 4 Hours",value:4,unit:"hours"},{label:"Last 24 Hours",value:24,unit:"hours"},{label:"Last 7 Days",value:7,unit:"days"}].map(e=>(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(K()===e.label?"bg-blue-50 text-blue-600":""),onClick:()=>{k(lQ()().format("YYYY-MM-DDTHH:mm")),N(lQ()().subtract(e.value,e.unit).format("YYYY-MM-DDTHH:mm")),P(!1),C(!1)},children:e.label},e.label)),(0,r.jsx)("div",{className:"border-t my-2"}),(0,r.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ".concat(I?"bg-blue-50 text-blue-600":""),onClick:()=>C(!I),children:"Custom Range"})]})})]}),(0,r.jsxs)("button",{onClick:()=>{q.refetch()},className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",title:"Refresh data",children:[(0,r.jsx)("svg",{className:"w-4 h-4 ".concat(q.isFetching?"animate-spin":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,r.jsx)("span",{children:"Refresh"})]})]}),I&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:w,onChange:e=>{N(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})}),(0,r.jsx)("span",{className:"text-gray-500",children:"to"}),(0,r.jsx)("div",{children:(0,r.jsx)("input",{type:"datetime-local",value:S,onChange:e=>{k(e.target.value),Z(1)},className:"px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Showing"," ",q.isLoading?"...":q.data?(f-1)*_+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*_,q.data.total):0," ","of"," ",q.isLoading?"...":q.data?q.data.total:0," ","results"]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",q.isLoading?"...":f," of"," ",q.isLoading?"...":q.data?q.data.total_pages:1]}),(0,r.jsx)("button",{onClick:()=>Z(e=>Math.max(1,e-1)),disabled:q.isLoading||1===f,className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,r.jsx)("button",{onClick:()=>Z(e=>{var l;return Math.min((null===(l=q.data)||void 0===l?void 0:l.total_pages)||1,e+1)}),disabled:q.isLoading||f===((null===(t=q.data)||void 0===t?void 0:t.total_pages)||1),className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]})}),(0,r.jsx)(el,{columns:l3,data:B,renderSubComponent:l7,getRowCanExpand:()=>!0})]})]})}function l7(e){var l,s;let{row:t}=e,a=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,r.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium ",children:"Request Details"})}),(0,r.jsxs)("div",{className:"space-y-2 p-4 ",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request ID:"}),(0,r.jsx)("span",{children:t.original.request_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Key:"}),(0,r.jsx)("span",{children:t.original.api_key})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Team ID:"}),(0,r.jsx)("span",{children:t.original.team_id})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Model:"}),(0,r.jsx)("span",{children:t.original.model})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Api Base:"}),(0,r.jsx)("span",{children:t.original.api_base})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Call Type:"}),(0,r.jsx)("span",{children:t.original.call_type})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Spend:"}),(0,r.jsx)("span",{children:t.original.spend})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Total Tokens:"}),(0,r.jsx)("span",{children:t.original.total_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Prompt Tokens:"}),(0,r.jsx)("span",{children:t.original.prompt_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Completion Tokens:"}),(0,r.jsx)("span",{children:t.original.completion_tokens})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Start Time:"}),(0,r.jsx)("span",{children:t.original.startTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"End Time:"}),(0,r.jsx)("span",{children:t.original.endTime})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Hit:"}),(0,r.jsx)("span",{children:t.original.cache_hit})]}),(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Cache Key:"}),(0,r.jsx)("span",{children:t.original.cache_key})]}),(null==t?void 0:null===(l=t.original)||void 0===l?void 0:l.requester_ip_address)&&(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"font-medium w-1/3",children:"Request IP Address:"}),(0,r.jsx)("span",{children:null==t?void 0:null===(s=t.original)||void 0===s?void 0:s.requester_ip_address})]})]})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request Tags"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.request_tags),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Request"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.messages),null,2)})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,r.jsx)("div",{})]}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm",children:JSON.stringify(a(t.original.response),null,2)})]}),t.original.metadata&&Object.keys(t.original.metadata).length>0&&(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,r.jsx)("div",{className:"flex justify-between items-center p-4 border-b",children:(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"})}),(0,r.jsx)("pre",{className:"p-4 text-wrap overflow-auto text-sm ",children:JSON.stringify(t.original.metadata,null,2)})]})]})}var l9=s(92699),se=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,r.jsx)(b.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(ei.Z,{children:"LlamaIndex"}),(0,r.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="'.concat(s,'", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="').concat(s,'",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lJ.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="'.concat(s,'",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})})},sl=s(243),ss=s(94263);async function st(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lD.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await r.chat.completions.create({model:s,stream:!0,messages:e})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content,t.model)}catch(e){I.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var sa=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:n}=e,[o,d]=(0,i.useState)(n?"custom":"session"),[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[p,_]=(0,i.useState)([]),[y,v]=(0,i.useState)(void 0),[w,N]=(0,i.useState)([]),k=(0,i.useRef)(null);(0,i.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,x.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),v(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,i.useEffect)(()=>{k.current&&setTimeout(()=>{var e;null===(e=k.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[p]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===u.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){I.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},i=[...p.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];_([...p,r]);try{y&&await st(i,(e,l)=>C("assistant",e,l),y,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=eS.default;return(0,r.jsxs)("div",{children:[(0,r.jsx)(e,{level:1,children:"Access Denied"}),(0,r.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,r.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,r.jsx)(g.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(ei.Z,{children:"Chat"})}),(0,r.jsx)(ec.Z,{children:(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"API Key Source"}),(0,r.jsx)(S.default,{disabled:n,defaultValue:"session",style:{width:"100%"},onChange:e=>d(e),options:[{value:"session",label:"Current UI Session"},{value:"custom",label:"Virtual Key"}]}),"custom"===o&&(0,r.jsx)(Z.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:m,value:c})]}),(0,r.jsxs)(j.Z,{className:"mx-2",children:[(0,r.jsx)(b.Z,{children:"Select Model:"}),(0,r.jsx)(S.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),v(e)},options:w,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(f.Z,{onClick:()=>{_([]),I.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(Y.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(X.Z,{children:(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{})})}),(0,r.jsxs)(J.Z,{children:[p.map((e,l)=>(0,r.jsx)(ee.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,r.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,r.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,r.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,r.jsx)(sl.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...i}=e,n=/language-(\w+)/.exec(t||"");return!s&&n?(0,r.jsx)(lJ.Z,{style:ss.Z,language:n[1],PreTag:"div",...i,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...i,children:a})}},children:e.content})})]})},l)),(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{ref:k,style:{height:"1px"}})})})]})]}),(0,r.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,r.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,r.jsx)(Z.Z,{type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,r.jsx)(f.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},sr=s(19226),si=s(45937),sn=s(92403),so=s(28595),sd=s(68208),sc=s(9775),sm=s(41361),su=s(37527),sh=s(15883),sx=s(12660),sp=s(88009),sj=s(48231),sg=s(41169),sf=s(44625),sZ=s(57400),s_=s(55322);let{Sider:sy}=sr.default,sv=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],sb=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(sn.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(so.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(sd.Z,{}),roles:sv},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(sc.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(sm.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(su.Z,{}),roles:sv},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(sh.Z,{}),roles:sv},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(sx.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sp.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sj.Z,{}),roles:sv},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sg.Z,{}),roles:sv,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(sf.Z,{}),roles:sv},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(su.Z,{}),roles:sv},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(sZ.Z,{}),roles:sv}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(s_.Z,{}),roles:sv,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(s_.Z,{}),roles:sv},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(sx.Z,{}),roles:sv},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(s_.Z,{}),roles:sv},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(s_.Z,{}),roles:sv}]}];var sw=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=sb.find(l=>l.page===e);if(l)return l.key;for(let l of sb)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),i=sb.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(sr.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sy,{theme:"light",width:220,children:(0,r.jsx)(si.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:i.map(e=>{var s;return{key:e.key,icon:e.icon,label:e.label,children:null===(s=e.children)||void 0===s?void 0:s.map(e=>({key:e.key,icon:e.icon,label:e.label,onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}})),onClick:e.children?void 0:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)}}})})})})},sN=s(96889);console.log=function(){};var sS=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:n,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,i.useState)(null!==a?a:0),[m,u]=(0,i.useState)(o?o.max_budget:null);(0,i.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(n);else{let e=!1;if(o.team_memberships)for(let s of o.team_memberships)s.user_id===l&&"max_budget"in s.litellm_budget_table&&null!==s.litellm_budget_table.max_budget&&(u(s.litellm_budget_table.max_budget),e=!0);e||u(o.max_budget)}}},[o,n]);let[h,p]=(0,i.useState)([]);(0,i.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,x.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,i.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",h),j=h):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=h);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,r.jsx)("div",{className:"flex items-center",children:(0,r.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,r.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,r.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})},sk=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sI=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sC=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:n,premiumUser:o}=e,d=new Date,[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)([]),[v,N]=(0,i.useState)([]),[S,k]=(0,i.useState)([]),[I,C]=(0,i.useState)([]),[A,P]=(0,i.useState)([]),[E,O]=(0,i.useState)([]),[T,M]=(0,i.useState)([]),[D,L]=(0,i.useState)({}),[F,R]=(0,i.useState)([]),[z,U]=(0,i.useState)(""),[V,q]=(0,i.useState)(["all-tags"]),[B,K]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[W,H]=(0,i.useState)(null),[G,el]=(0,i.useState)(0),ea=new Date(d.getFullYear(),d.getMonth(),1),em=new Date(d.getFullYear(),d.getMonth()+1,0),eu=ef(ea),eh=ef(em);function ex(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",n),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,x.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,i.useEffect)(()=>{eg(B.from,B.to)},[B,V]);let ej=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let a=await (0,x.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),y(a)},eg=async(e,s)=>{if(!e||!s||!l)return;let t=await ep();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),k((await (0,x.J$)(l,e.toISOString(),s.toISOString(),0===V.length?void 0:V)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ef(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}console.log("Start date is ".concat(eu)),console.log("End date is ".concat(eh));let eZ=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},e_=(e,l,s,t)=>{let a=[],r=new Date(l),i=e=>{if(e.includes("-"))return e;{let[l,s]=e.split(" ");return new Date(new Date().getFullYear(),new Date("".concat(l," 01 2024")).getMonth(),parseInt(s)).toISOString().split("T")[0]}},n=new Map(e.map(e=>{let l=i(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(n.has(e))a.push(n.get(e));else{let l={date:e,api_requests:0,total_tokens:0};t.forEach(e=>{l[e]||(l[e]=0)}),a.push(l)}r.setDate(r.getDate()+1)}return a},ey=async()=>{if(l)try{let e=await (0,x.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e,t,a,[]),i=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(i),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},ev=()=>eZ(()=>l&&s?(0,x.OU)(l,s,eu,eh):Promise.reject("No access token or token"),M,"Error fetching provider spend"),eb=async()=>{l&&await eZ(async()=>(await (0,x.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:Number(e.total_spend.toFixed(2))})),h,"Error fetching top keys")},ew=async()=>{l&&await eZ(async()=>(await (0,x.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),Z,"Error fetching top models")},eN=async()=>{l&&await eZ(async()=>{let e=await (0,x.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return N(e_(e.daily_spend,t,a,e.teams)),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:Number(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eS=()=>{l&&eZ(async()=>(await (0,x.X)(l)).tag_names,C,"Error fetching tag names")},ek=()=>{l&&eZ(()=>{var e,s;return(0,x.J$)(l,null===(e=B.from)||void 0===e?void 0:e.toISOString(),null===(s=B.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>k(e.spend_per_tag),"Error fetching top tags")},eC=()=>{l&&eZ(()=>(0,x.b1)(l,null,void 0,void 0),y,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,x.wd)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e_(e.daily_data||[],t,a,["api_requests","total_tokens"]);L({...e,daily_data:r})}catch(e){console.error("Error fetching global activity:",e)}},eP=async()=>{if(l)try{let e=await (0,x.xA)(l,eu,eh),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=e.map(e=>({...e,daily_data:e_(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,i.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(H(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",W),ey(),ev(),eb(),ew(),eA(),eP(),sI(t)&&(eN(),eS(),ek(),eC()))}})()},[l,s,t,a,eu,eh]),null==W?void 0:W.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(b.Z,{className:"mt-4",children:["SpendLogs in DB has ",W.NUM_SPEND_LOGS_ROWS," rows.",(0,r.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,r.jsx)(f.Z,{className:"mt-4",children:(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(ei.Z,{children:"All Up"}),sI(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ei.Z,{children:"Team Based Usage"}),(0,r.jsx)(ei.Z,{children:"Customer Usage"}),(0,r.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{})})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(en.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(ei.Z,{children:"Cost"}),(0,r.jsx)(ei.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(b.Z,{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content mb-2 mt-2 text-lg",children:["Project Spend ",new Date().toLocaleString("default",{month:"long"})," 1 - ",new Date(new Date().getFullYear(),new Date().getMonth()+1,0).getDate()]}),(0,r.jsx)(sS,{userID:a,userRole:t,accessToken:l,userSpend:G,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Monthly Spend"}),(0,r.jsx)(eU.Z,{data:c,index:"date",categories:["spend"],colors:["cyan"],valueFormatter:e=>"$ ".concat(e.toFixed(2)),yAxisWidth:100,tickGap:5})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top API Keys"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:u,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Top Models"}),(0,r.jsx)(eU.Z,{className:"mt-4 h-40",data:p,index:"key",categories:["spend"],colors:["cyan"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1,valueFormatter:e=>"$".concat(e.toFixed(2))})]})}),(0,r.jsx)(j.Z,{numColSpan:1}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sk.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend",colors:["cyan"],valueFormatter:e=>"$".concat(e.toFixed(2))})}),(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Provider"}),(0,r.jsx)(Q.Z,{children:"Spend"})]})}),(0,r.jsx)(J.Z,{children:T.map(e=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.provider}),(0,r.jsx)($.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})})]})})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"All Up"}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(D.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(D.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:D.daily_data,valueFormatter:ex,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),(0,r.jsx)(r.Fragment,{children:F.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:e.model}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(ez.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ex,onValueChange:e=>console.log(e)})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(eI.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eU.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ex,onValueChange:e=>console.log(e)})]})]})]},l))})]})})]})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(er.Z,{className:"mb-2",children:[(0,r.jsx)(w.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sN.Z,{data:E})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eU.Z,{className:"h-72",data:v,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,r.jsx)(j.Z,{numColSpan:2})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Time Range"}),(0,r.jsx)(eF.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(b.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{ej(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==n?void 0:n.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{ej(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(Y.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Customer"}),(0,r.jsx)(Q.Z,{children:"Spend"}),(0,r.jsx)(Q.Z,{children:"Total Events"})]})}),(0,r.jsx)(J.Z,{children:null==_?void 0:_.map((e,l)=>{var s;return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.end_user}),(0,r.jsx)($.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)($.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(g.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eF.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lE.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lO.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsx)(lO.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lE.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lO.Z,{value:"all-tags",onClick:()=>q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,r.jsxs)(et.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,r.jsxs)(g.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(b.Z,{children:["Get Started Tracking cost per tag ",(0,r.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,r.jsx)(eU.Z,{className:"h-72",data:S,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sA=e=>{if(e)return e.toISOString().split("T")[0]};function sP(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var sE=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:n}=e,[o,d]=(0,i.useState)([]),[c,m]=(0,i.useState)([]),[u,h]=(0,i.useState)([]),[p,Z]=(0,i.useState)([]),[_,y]=(0,i.useState)("0"),[v,w]=(0,i.useState)("0"),[N,S]=(0,i.useState)("0"),[k,C]=(0,i.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,i.useState)(""),[E,O]=(0,i.useState)("");(0,i.useEffect)(()=>{l&&k&&((async()=>{Z(await (0,x.zg)(l,sA(k.from),sA(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),M=Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(p.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let D=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,x.zg)(l,sA(e),sA(s))))};(0,i.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",p);let e=p;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),u.length>0&&(e=e.filter(e=>u.includes(e.model))),console.log("before processed data in cache dashboard",e);let l=0,s=0,t=0,a=e.reduce((e,a)=>{console.log("Processing item:",a),a.call_type||(console.log("Item has no call_type:",a),a.call_type="Unknown"),l+=(a.total_rows||0)-(a.cache_hit_true_rows||0),s+=a.cache_hit_true_rows||0,t+=a.cached_completion_tokens||0;let r=e.find(e=>e.name===a.call_type);return r?(r["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),r["Cache hit"]+=a.cache_hit_true_rows||0,r["Cached Completion Tokens"]+=a.cached_completion_tokens||0,r["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(sP(s)),w(sP(t));let r=s+l;r>0?S((s/r*100).toFixed(2)):S("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,p]);let L=async()=>{try{I.ZP.info("Running cache health check..."),O("");let e=await (0,x.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),O(e)}catch(e){console.error("Error running health check:",e),O("Error running health check")}};return(0,r.jsxs)(en.Z,{className:"gap-2 p-8 h-full w-full mt-2 mb-8",children:[(0,r.jsxs)(eo.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)(ei.Z,{children:"Cache Analytics"}),(0,r.jsx)(ei.Z,{children:(0,r.jsx)("pre",{children:"Cache Health"})})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[A&&(0,r.jsxs)(b.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eR.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:()=>{P(new Date().toLocaleString())}})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(g.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lE.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lO.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lE.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:M.map(e=>(0,r.jsx)(lO.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eF.Z,{enableSelect:!0,value:k,onValueChange:e=>{C(e),D(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[N,"%"]})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,r.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,r.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:v})})]})]}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eU.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sP,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(eI.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eU.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sP,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{className:"mt-4",children:[(0,r.jsx)(b.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(f.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),E&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(E,null,2)})]})})]})]})},sO=e=>{let{accessToken:l}=e,[s,t]=(0,i.useState)([]);return(0,i.useEffect)(()=>{l&&(async()=>{try{let e=await (0,x.t3)(l);console.log("guardrails: ".concat(JSON.stringify(e))),t(e.guardrails)}catch(e){console.error("Error fetching guardrails:",e)}})()},[l]),(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsxs)(b.Z,{className:"mb-4",children:["Configured guardrails and their current status. Setup guardrails in config.yaml."," ",(0,r.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-700 underline",children:"Docs"})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(Y.Z,{children:[(0,r.jsx)(X.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(Q.Z,{children:"Guardrail Name"}),(0,r.jsx)(Q.Z,{children:"Mode"}),(0,r.jsx)(Q.Z,{children:"Status"})]})}),(0,r.jsx)(J.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)($.Z,{children:e.guardrail_name}),(0,r.jsx)($.Z,{children:e.litellm_params.mode}),(0,r.jsx)($.Z,{children:(0,r.jsx)("div",{className:"inline-flex rounded-full px-2 py-1 text-xs font-medium\n ".concat(e.litellm_params.default_on?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:e.litellm_params.default_on?"Always On":"Per Request"})})]},l)):(0,r.jsx)(ee.Z,{children:(0,r.jsx)($.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};let sT=new d.S;function sM(){let[e,l]=(0,i.useState)(""),[s,t]=(0,i.useState)(!1),[a,d]=(0,i.useState)(!1),[m,u]=(0,i.useState)(null),[j,g]=(0,i.useState)(null),[f,Z]=(0,i.useState)(null),[_,y]=(0,i.useState)([]),[v,b]=(0,i.useState)([]),[w,N]=(0,i.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[S,k]=(0,i.useState)(!0),I=(0,n.useSearchParams)(),[C,A]=(0,i.useState)({data:[]}),[P,E]=(0,i.useState)(null),O=I.get("userID"),T=I.get("invitation_id"),[M,D]=(0,i.useState)(()=>I.get("page")||"api-keys"),[L,F]=(0,i.useState)(null);return(0,i.useEffect)(()=>{E(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,i.useEffect)(()=>{if(!P)return;let e=(0,o.o)(P);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),F(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"org_admin":return"Org Admin";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&D("usage")}else console.log("User role not defined");e.user_email?u(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?k("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&t(e.premium_user),e.auth_header_name&&(0,x.K8)(e.auth_header_name)}},[P]),(0,i.useEffect)(()=>{L&&O&&e&&q(O,e,L,b),L&&O&&e&&p(L,O,e,null,g),L&&l_(L,y)},[L,O,e]),(0,r.jsx)(i.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sT,children:T?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(h,{userID:O,userRole:e,premiumUser:s,setProxySettings:N,proxySettings:w}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sw,{setPage:e=>{let l=new URLSearchParams(I);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),D(e)},userRole:e,defaultSelectedKey:M})}),"api-keys"==M?(0,r.jsx)(ek,{userID:O,userRole:e,premiumUser:s,teams:j,keys:f,setUserRole:l,userEmail:m,setUserEmail:u,setTeams:g,setKeys:Z,organizations:_}):"models"==M?(0,r.jsx)(lc,{userID:O,userRole:e,token:P,keys:f,accessToken:L,modelData:C,setModelData:A,premiumUser:s,teams:j}):"llm-playground"==M?(0,r.jsx)(sa,{userID:O,userRole:e,token:P,accessToken:L,disabledPersonalKeyCreation:a}):"users"==M?(0,r.jsx)(lp,{userID:O,userRole:e,token:P,keys:f,teams:j,accessToken:L,setKeys:Z}):"teams"==M?(0,r.jsx)(lf,{teams:j,setTeams:g,searchParams:I,accessToken:L,userID:O,userRole:e,organizations:_}):"organizations"==M?(0,r.jsx)(ly,{organizations:_,setOrganizations:y,userModels:v,accessToken:L,userRole:e,premiumUser:s}):"admin-panel"==M?(0,r.jsx)(lb,{setTeams:g,searchParams:I,accessToken:L,showSSOBanner:S,premiumUser:s}):"api_ref"==M?(0,r.jsx)(se,{proxySettings:w}):"settings"==M?(0,r.jsx)(lP,{userID:O,userRole:e,accessToken:L,premiumUser:s}):"budgets"==M?(0,r.jsx)(l$,{accessToken:L}):"guardrails"==M?(0,r.jsx)(sO,{accessToken:L}):"general-settings"==M?(0,r.jsx)(lz,{userID:O,userRole:e,accessToken:L,modelData:C}):"model-hub"==M?(0,r.jsx)(l9.Z,{accessToken:L,publicPage:!1,premiumUser:s}):"caching"==M?(0,r.jsx)(sE,{userID:O,userRole:e,token:P,accessToken:L,premiumUser:s}):"pass-through-settings"==M?(0,r.jsx)(lH,{userID:O,userRole:e,accessToken:L,modelData:C}):"logs"==M?(0,r.jsx)(l6,{userID:O,userRole:e,token:P,accessToken:L}):(0,r.jsx)(sC,{userID:O,userRole:e,token:P,accessToken:L,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,812,250,699,971,117,744],function(){return e(e.s=1900)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/r-JFaQKckChAbyF6OLpws/_buildManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_buildManifest.js rename to ui/litellm-dashboard/out/_next/static/r-JFaQKckChAbyF6OLpws/_buildManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/r-JFaQKckChAbyF6OLpws/_ssgManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/yJuobVnL1vdr5eQA0jUcl/_ssgManifest.js rename to ui/litellm-dashboard/out/_next/static/r-JFaQKckChAbyF6OLpws/_ssgManifest.js diff --git a/ui/litellm-dashboard/out/index.html b/ui/litellm-dashboard/out/index.html index 8b55c7037d..3c08487efa 100644 --- a/ui/litellm-dashboard/out/index.html +++ b/ui/litellm-dashboard/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.txt b/ui/litellm-dashboard/out/index.txt index bbed2c879b..7ca4e40a7b 100644 --- a/ui/litellm-dashboard/out/index.txt +++ b/ui/litellm-dashboard/out/index.txt @@ -1,7 +1,7 @@ 2:I[19107,[],"ClientPageRoot"] -3:I[79333,["665","static/chunks/3014691f-0b72c78cfebbd712.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-1cbed529ecb084e0.js","261","static/chunks/261-57d48f76eec1e568.js","755","static/chunks/755-8a74d7ff30e7d680.js","812","static/chunks/812-34d6bec3abb0e912.js","250","static/chunks/250-f1e2db7aa40a2982.js","699","static/chunks/699-fcda99cfef09c606.js","931","static/chunks/app/page-46aa398e93cfa70d.js"],"default",1] +3:I[15940,["665","static/chunks/3014691f-0b72c78cfebbd712.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-1cbed529ecb084e0.js","261","static/chunks/261-57d48f76eec1e568.js","755","static/chunks/755-8a74d7ff30e7d680.js","812","static/chunks/812-34d6bec3abb0e912.js","250","static/chunks/250-f1e2db7aa40a2982.js","699","static/chunks/699-fcda99cfef09c606.js","931","static/chunks/app/page-e673cacf03d84561.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["yJuobVnL1vdr5eQA0jUcl",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] +0:["r-JFaQKckChAbyF6OLpws",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/model_hub.html b/ui/litellm-dashboard/out/model_hub.html index cf6c85ee51..fcf4a40091 100644 --- a/ui/litellm-dashboard/out/model_hub.html +++ b/ui/litellm-dashboard/out/model_hub.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/ui/litellm-dashboard/out/model_hub.txt b/ui/litellm-dashboard/out/model_hub.txt index a8d428dceb..c230f94244 100644 --- a/ui/litellm-dashboard/out/model_hub.txt +++ b/ui/litellm-dashboard/out/model_hub.txt @@ -2,6 +2,6 @@ 3:I[52829,["42","static/chunks/42-1cbed529ecb084e0.js","261","static/chunks/261-57d48f76eec1e568.js","250","static/chunks/250-f1e2db7aa40a2982.js","699","static/chunks/699-fcda99cfef09c606.js","418","static/chunks/app/model_hub/page-068a441595bd0fc3.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["yJuobVnL1vdr5eQA0jUcl",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] +0:["r-JFaQKckChAbyF6OLpws",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/onboarding.html b/ui/litellm-dashboard/out/onboarding.html index 1e070dcc42..dfa3a56228 100644 --- a/ui/litellm-dashboard/out/onboarding.html +++ b/ui/litellm-dashboard/out/onboarding.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/ui/litellm-dashboard/out/onboarding.txt b/ui/litellm-dashboard/out/onboarding.txt index 0d25fdf541..dd4f3a9b24 100644 --- a/ui/litellm-dashboard/out/onboarding.txt +++ b/ui/litellm-dashboard/out/onboarding.txt @@ -2,6 +2,6 @@ 3:I[12011,["665","static/chunks/3014691f-0b72c78cfebbd712.js","42","static/chunks/42-1cbed529ecb084e0.js","755","static/chunks/755-8a74d7ff30e7d680.js","250","static/chunks/250-f1e2db7aa40a2982.js","461","static/chunks/app/onboarding/page-0992dd0b4cd99a23.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["yJuobVnL1vdr5eQA0jUcl",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] +0:["r-JFaQKckChAbyF6OLpws",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[null,["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/86f6cc749f6b8493.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/ui/_next/static/css/c43d141ac9732358.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_cf7686","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null