From 5fc008626f2b5a2cfde806d578f33a4ad7b7746d Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 15 Feb 2025 16:47:54 -0800 Subject: [PATCH] ui new build --- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 .../out/_next/static/chunks/app/page-508ac4d06e0d1277.js | 1 + .../out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.js | 1 - 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 | 2 +- litellm/proxy/_experimental/out/onboarding.txt | 2 +- ui/litellm-dashboard/out/404.html | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 .../out/_next/static/chunks/app/page-508ac4d06e0d1277.js | 1 + .../out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.js | 1 - 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(+), 16 deletions(-) rename litellm/proxy/_experimental/out/_next/static/{SyoNkMOnybMJCs1FpMdUS => SLeC9QjabwQfDLWx06pJ4}/_buildManifest.js (100%) rename litellm/proxy/_experimental/out/_next/static/{SyoNkMOnybMJCs1FpMdUS => SLeC9QjabwQfDLWx06pJ4}/_ssgManifest.js (100%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/app/page-508ac4d06e0d1277.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.js rename ui/litellm-dashboard/out/_next/static/{SyoNkMOnybMJCs1FpMdUS => SLeC9QjabwQfDLWx06pJ4}/_buildManifest.js (100%) rename ui/litellm-dashboard/out/_next/static/{SyoNkMOnybMJCs1FpMdUS => SLeC9QjabwQfDLWx06pJ4}/_ssgManifest.js (100%) create mode 100644 ui/litellm-dashboard/out/_next/static/chunks/app/page-508ac4d06e0d1277.js delete mode 100644 ui/litellm-dashboard/out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.js diff --git a/litellm/proxy/_experimental/out/_next/static/SyoNkMOnybMJCs1FpMdUS/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/SyoNkMOnybMJCs1FpMdUS/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/SyoNkMOnybMJCs1FpMdUS/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/SyoNkMOnybMJCs1FpMdUS/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-508ac4d06e0d1277.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-508ac4d06e0d1277.js new file mode 100644 index 00000000000..333efeee934 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-508ac4d06e0d1277.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,36733))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return y}});var t=s(57437),a=s(2265),r=s(99376),n=s(20831),i=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),g=s(14474),j=s(13634),f=s(73002);function y(){let[e]=j.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"),[y,Z]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,N]=(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,g.o)(s);A(s),console.log("decoded:",t),Z(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),N(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)(i.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)(n.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)(j.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",y,"token:",C,"formValues:",e),y&&C&&(e.user_email=v,S&&s&&(0,p.m_)(y,s,S,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)(j.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:v,defaultValue:v,className:"max-w-md"})}),(0,t.jsx)(j.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"})})]})]})})}},36733:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sS}});var t,a,r=s(57437),n=s(2265),i=s(99376),o=s(14474),d=s(90946),c=s(29827);let m={organization_id:null,organization_alias:"Default Organization"};var u=s(27648),h=s(92643),x=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:n,proxySettings:i,currentOrg:o=null,onOrgChange:d=()=>{},onNewOrg:c=()=>{},organizations:x=[]}=e;console.log("currentOrg: ".concat(JSON.stringify(o))),console.log("organizations: ".concat(JSON.stringify(x)));let p=(null==i?void 0:i.PROXY_LOGOUT_URL)||"",g=[{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(a)]})]})},{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=p},children:"Logout"})}],j=[{key:"header",label:"Organizations",type:"group",style:{color:"#6B7280",fontSize:"0.875rem"}},{key:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:"Default Organization"})}),onClick:()=>d(m)},...x.filter(e=>null!==e.organization_id).map(e=>{var l;return{key:null!==(l=e.organization_id)&&void 0!==l?l:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:e.organization_alias})}),onClick:()=>d(e)}}),{key:"note",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 text-gray-500 text-xs italic",children:(0,r.jsx)("span",{children:"Switching between organizations on the UI is currently in beta."})}),disabled:!0}];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)(u.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:"ml-8 flex items-center",children:[(0,r.jsx)(h.Z,{menu:{items:j,style:{width:"280px",padding:"4px",marginTop:"4px"}},trigger:["click"],placement:"bottomLeft",children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-700 hover:text-gray-900 transition-colors",children:[o?o.organization_alias:"Default Organization",(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"})})]})}),(0,r.jsx)("span",{className:"ml-2 text-[10px] bg-blue-100 text-blue-800 font-medium px-2 py-0.5 rounded",children:"BETA"})]}),(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)(h.Z,{menu:{items:g,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"})})]})})]})]})})})},p=s(19250);let g=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO,l):await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),f=s(67101),y=s(20831),Z=s(26637),_=s(87452),b=s(88829),v=s(72208),w=s(84264),S=s(96761),N=s(29233),k=s(41326),I=s(13634),C=s(41021),A=s(51369),P=s(8104),O=s(20577),E=s(56632),T=s(73002);let D=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,p.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},L=(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 F=s(15424),R=s(75957);let{Option:z}=k.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)=>L(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,p.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:i,data:o,setData:d}=e,[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,D]=(0,n.useState)(null),[L,B]=(0,n.useState)([]),[K,W]=(0,n.useState)([]),[H,G]=(0,n.useState)("you"),[Y,J]=(0,n.useState)(U(o)),[$,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(s),el=()=>{u(!1),c.resetFields()},es=()=>{u(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{l&&a&&i&&q(l,a,i,B)},[i,l,a]),(0,n.useEffect)(()=>{(async()=>{try{let e=(await (0,p.t3)(i)).guardrails.map(e=>e.guardrail_name);X(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[i]);let et=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",n=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===n).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(n,", please provide another key alias"));if(C.ZP.info("Making API Call"),u(!0),"you"===H&&(e.user_id=l),"service_account"===H){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,p.wX)(i,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),x(m.key),D(m.soft_budget),C.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),C.ZP.error("Error creating the key: ".concat(e))}};return(0,n.useEffect)(()=>{W(V(Q,L)),c.setFieldValue("models",[])},[Q,L]),(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(A.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:el,onCancel:es,children:(0,r.jsxs)(I.Z,{form:c,onFinish:et,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(P.ZP.Group,{onChange:e=>G(e.target.value),value:H,children:[(0,r.jsx)(P.ZP,{value:"you",children:"You"}),(0,r.jsx)(P.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(P.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==H,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===H,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)(I.Z.Item,{label:"you"===H||"another_user"===H?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===H?"key name":"service account ID")}],help:"you"===H?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(k.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{c.setFieldValue("team_id",e),ee((null==t?void 0:t.find(l=>l.team_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==t?void 0:t.map(e=>(0,r.jsxs)(k.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))})}),(0,r.jsx)(I.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)(k.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"),K.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)(b.Z,{children:[(0,r.jsx)(I.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)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.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)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:$.map(e=>({value:e,label:e}))})}),(0,r.jsx)(I.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)(I.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:Y})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(A.Z,{visible:m,onOk:el,onCancel:es,footer:null,children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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:()=>{C.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(w.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=s(21626),H=s(97214),G=s(28241),Y=s(58834),J=s(69552),$=s(71876),X=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,i]=(0,n.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,n.useState)(!0),[c,m]=(0,n.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!s||!t){console.log("currentOrg",s),console.log("accessToken",t);return}d(!0);let a=await (0,p.OD)(t,s.organization_id,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),i(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,n.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}},Q=s(71594),ee=s(24525);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:i=!1}=e,o=(0,Q.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,ee.sC)(),getExpandedRowModel:(0,ee.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(W.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(Y.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)($.Z,{children:e.headers.map(e=>(0,r.jsx)(J.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,Q.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(H.Z,{children:i?(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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)(n.Fragment,{children:[(0,r.jsx)($.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)(G.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,Q.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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),en=s(12485),ei=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:i,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=I.Z.useForm(),[h,x]=(0,n.useState)([]),g=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,n.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,p.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let j={...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)(I.Z,{form:u,onFinish:i,initialValues:j,layout:"vertical",children:[(0,r.jsx)(I.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[g.length>0&&(0,r.jsx)(k.default.Option,{value:"all-team-models",children:"All Team Models"}),g.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(k.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(k.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(I.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(I.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)(y.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a,onSuccess:i}=e,[o]=I.Z.useForm(),[d,c]=(0,n.useState)(null),[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(null);(0,n.useEffect)(()=>{s&&l&&o.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,o]),(0,n.useEffect)(()=>{(null==m?void 0:m.duration)?x((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}})(m.duration)):x(null)},[null==m?void 0:m.duration]);let g=async()=>{if(l&&a)try{let e=await o.validateFields(),s=await (0,p.s0)(a,l.token,e);c(s.key),i&&i({...l,key_name:s.key_name,...e}),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}},_=()=>{c(null),o.resetFields(),t()};return(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:s,onCancel:_,footer:d?[(0,r.jsx)(y.Z,{onClick:_,children:"Close"},"close")]:[(0,r.jsx)(y.Z,{onClick:_,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:g,children:"Regenerate"},"regenerate")],children:d?(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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)(w.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:d})}),(0,r.jsx)(N.CopyToClipboard,{text:d,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(I.Z,{form:o,layout:"vertical",onValuesChange:e=>{"duration"in e&&u(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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"]}),h&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",h]})]})})}function eg(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:i,userRole:o,teams:d}=e,[c,m]=(0,n.useState)(!1),[u]=I.Z.useForm(),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:"Key not found"})]});let Z=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),C.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,p.Nc)(a,e),C.ZP.success("Key updated successfully"),m(!1)}catch(e){C.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},_=async()=>{try{if(!a)return;await (0,p.I1)(a,t.token),C.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),C.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)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(S.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(y.Z,{icon:eu.Z,variant:"secondary",onClick:()=>j(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(y.Z,{icon:eh.Z,variant:"secondary",onClick:()=>x(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:g,onClose:()=>j(!1),accessToken:a,onSuccess:e=>{j(!1)}}),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)(y.Z,{onClick:_,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>x(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(w.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(w.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)(S.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(y.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:Z,teams:d,accessToken:a,userID:i,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(w.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(w.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(w.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(w.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(w.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(w.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)})]})]})]})})]})]})]})}let ej=e=>{let{teams:l,selectedTeam:s,setSelectedTeam:t}=e;return(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-600",children:"Where Team is"}),(0,r.jsxs)(es.Z,{value:(null==s?void 0:s.team_id)||"",onValueChange:e=>{t((null==l?void 0:l.find(l=>l.team_id===e))||null)},placeholder:"Team ID",className:"w-[400px]",children:[(0,r.jsx)(et.Z,{value:"team_id",children:"Team ID"}),null==l?void 0:l.map(e=>(0,r.jsxs)(et.Z,{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))]})]})})};function ef(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:i=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h}=e,[x,p]=(0,n.useState)(null),g=[{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)(y.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.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Organization",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{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:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{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:x?(0,r.jsx)(eg,{keyId:x,onClose:()=>p(null),keyData:l.find(e=>e.token===x),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",children:[(0,r.jsx)(ej,{teams:o,selectedTeam:d,setSelectedTeam:c}),(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)*i+1," - ").concat(Math.min(t.currentPage*i,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:g.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ey=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:i,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u}=e,[h,x]=(0,n.useState)(!1),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),[k,P]=(0,n.useState)(null),[E,T]=(0,n.useState)(null),[M,L]=(0,n.useState)((null==a?void 0:a.team_id)||""),[F,R]=(0,n.useState)("");(0,n.useEffect)(()=>{L((null==a?void 0:a.team_id)||"")},[a]),(0,n.useMemo)(()=>{let e={};return M&&(e.team_id=M),F&&(e.key_alias=F),e},[M,F]);let{keys:z,isLoading:U,error:V,pagination:q,refresh:B}=X({selectedTeam:a,currentOrg:u,accessToken:t}),[W,H]=(0,n.useState)(!1),[G,Y]=(0,n.useState)(!1),[J,$]=(0,n.useState)(null),[Q,ee]=(0,n.useState)([]),el=new Set,[es,et]=(0,n.useState)(!1),[ea,er]=(0,n.useState)(!1),[en,ei]=(0,n.useState)(null),[eo,ed]=(0,n.useState)(null),[ec]=I.Z.useForm(),[em,eu]=(0,n.useState)(null),[eh,ex]=(0,n.useState)(el),[ep,eg]=(0,n.useState)([]);(0,n.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",J),(null==eo?void 0:eo.duration)?eu((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}})(eo.duration)):eu(null),console.log("calculateNewExpiryTime:",em)},[J,null==eo?void 0:eo.duration]),(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await D(l,s,t);e&&ee(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ex(e)}},[c]);let ej=async()=>{if(null!=b&&null!=o){try{await (0,p.I1)(t,b);let e=o.filter(e=>e.token!==b);d(e)}catch(e){console.error("Error deleting the key:",e)}_(!1),v(null)}},ey=(e,l)=>{ed(s=>({...s,[e]:l}))},eZ=async()=>{if(!m){C.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=J)try{let e=await ec.validateFields(),l=await (0,p.s0)(t,J.token,e);if(ei(l.key),o){let s=o.map(s=>s.token===(null==J?void 0:J.token)?{...s,key_name:l.key_name,...e}:s);d(s)}er(!1),ec.resetFields(),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}};return Array.from(new Set(z.map(e=>e.key_alias?e.key_alias:"Not Set"))),(0,r.jsxs)("div",{children:[(0,r.jsx)(ef,{keys:z,isLoading:U,pagination:q,onPageChange:e=>{B({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:i,accessToken:t,userID:l,userRole:s}),g&&(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)(y.Z,{onClick:ej,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{_(!1),v(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:ea,onCancel:()=>{er(!1),ec.resetFields()},footer:[(0,r.jsx)(y.Z,{onClick:()=>{er(!1),ec.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:eZ,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(I.Z,{form:ec,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&ey("duration",e.duration)},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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==J?void 0:J.expires)!=null?new Date(J.expires).toLocaleString():"Never"]}),em&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",em]})]}):(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)(y.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"})})]})}),en&&(0,r.jsx)(A.Z,{visible:!!en,onCancel:()=>ei(null),footer:[(0,r.jsx)(y.Z,{onClick:()=>ei(null),children:"Close"},"close")],children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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==J?void 0:J.key_alias)||"No alias set"})}),(0,r.jsx)(w.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:en})}),(0,r.jsx)(N.CopyToClipboard,{text:en,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eZ=s(12011),e_=s(68060);console.log=function(){},console.log("isLocal:",!1);var eb=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,setOrganizations:x,premiumUser:y,currentOrg:Z}=e;console.log("currentOrg in user dashboard: ".concat(JSON.stringify(Z)));let[_,b]=(0,n.useState)(null),v=(0,i.useSearchParams)(),w=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=v.get("invitation_id"),[N,k]=(0,n.useState)(null),[I,C]=(0,n.useState)(null),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(w){let e=(0,o.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),k(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&&N&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);if(e)P(JSON.parse(e));else{console.log("currentOrg: ".concat(JSON.stringify(Z)));let e=async()=>{x(await (0,p.r6)(N))};(async()=>{try{let e=await (0,p.g)(N);E(e);let t=await (0,p.Br)(N,l,s,!1,null,null);b(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,p.So)(N,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),P(a),console.log("userModels:",A),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),g(N,l,s,Z,u),e()}}},[l,w,N,a,s]),(0,n.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(Z),", accessToken: ").concat(N,", userID: ").concat(l,", userRole: ").concat(s)),N&&(console.log("fetching teams"),g(N,l,s,Z,u))},[Z]),(0,n.useEffect)(()=>{if(null!==a&&null!=T&&null!==T.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))T.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===T.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),C(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;C(e)}},[T]),null!=S)return(0,r.jsx)(eZ.default,{});if(null==l||null==w){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==N)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=e_.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",T),(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,r.jsx)(f.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:T,teams:t,userRole:s,accessToken:N,data:a,setData:h},T?T.team_id:null),(0,r.jsx)(ey,{userID:l,userRole:s,accessToken:N,selectedTeam:T||null,setSelectedTeam:D,data:a,setData:h,premiumUser:y,teams:t,currentOrg:Z})]})})})},ev=s(97765),ew=s(47451),eS=s(69410),eN=()=>{let e=I.Z.useFormInstance();return(I.Z.useWatch("model",e)||[]).includes("all-wildcard")?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!1,className:"mb-0",rules:[e=>{let{getFieldValue:l}=e;return{validator:(e,s)=>!(l("model")||[]).includes("all-wildcard")||s?Promise.resolve():Promise.reject(Error('Public Model Name is required unless "All Models" is selected.'))}}],children:(0,r.jsx)(Z.Z,{placeholder:"my-gpt-4"})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})};(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 ek={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"},eI={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"},eC=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(ek).find(l=>ek[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eI[s],displayName:s}},eA=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",eP=(e,l)=>{console.log("Provider key: ".concat(e));let s=ek[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};var eO=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,n=I.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(I.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)(I.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.toString())}):s.length>0?(0,r.jsx)(k.default,{allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{e.includes("all-wildcard")&&n.setFieldsValue({model_name:void 0})},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.toString())})}),(0,r.jsx)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},eE=s(63709),eT=s(90464);let{Link:eD}=e_.default;var eM=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s}=e,[t]=I.Z.useForm(),[a,i]=n.useState(!1),[o,d]=n.useState("per_token"),c=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),m=(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)(b.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(I.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(eE.Z,{onChange:e=>{i(e),e||t.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),a&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(I.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:"per_token",onChange:e=>d(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(I.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(I.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)(eD,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(eE.Z,{onChange:e=>{let l=t.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?t.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):t.setFieldValue("litellm_extra_params","")}catch(l){e?t.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):t.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(ew.Z,{className:"mb-4",children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(eD,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})},eL=s(18502),eF=s(3632);let{Link:eR}=e_.default;var ez=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)(I.Z.Item,{label:"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)(I.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)(I.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(eL.Z,{...s,children:(0,r.jsx)(T.ZP,{icon:(0,r.jsx)(eF.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(k.default,{placeholder:"Select API Base",children:[(0,r.jsx)(k.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(k.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(I.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)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(eR,{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)(I.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)(I.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)(I.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)(I.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"})})]})};let eU=async(e,l,s,t)=>{try{if(console.log("handling submit for formValues:",e),e.model&&e.model.includes("all-wildcard")){let l=ek[e.custom_llm_provider]+"/*";e.model_name=l,e.model=l}let a=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(a)),console.log("received type of deployments: ".concat(typeof a)),a.forEach(async s=>{console.log("litellm_model: ".concat(s));let a={},r={};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),a.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=ek[s];a.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)r[l]=s;else if("custom_model_name"===l)a.model=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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))r[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){s&&(a[l]=Number(s));continue}else a[l]=s}let i={model_name:n,litellm_params:a,model_info:r},o=await (0,p.kK)(l,i);t&&t(),console.log("response for model create call: ".concat(o.data))}),s.resetFields()}catch(e){C.ZP.error("Failed to create model: "+e,10)}};var eV=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[n]=I.Z.useForm(),i={},o="",d="";if(t){var c,m;i={...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)),i.model_id=d)}return(0,r.jsx)(A.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{n.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}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(I.Z,{form:n,onFinish:a,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},eq=s(53003),eB=s(47323),eK=s(75105),eW=s(40278),eH=s(14301),eG=s(15731),eY=s(53410),eJ=s(2356),e$=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,i]=(0,n.useState)(!1),o=async()=>{try{C.ZP.info("Making API Call"),i(!0);let e=await (0,p.Og)(s,l);console.log("model delete Response:",e),C.ZP.success("Model ".concat(l," deleted successfully")),i(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eB.Z,{onClick:()=>i(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(A.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>i(!1),children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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})]})})]})})]})},eX=s(94789),eQ=s(59664),e0=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eQ.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)(eX.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)(y.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},e1=s(17906);let{Title:e2,Link:e4}=e_.default,e5={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var e3=e=>{let{accessToken:l,token:s,userRole:t,userID:i,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m}=e,[u,h]=(0,n.useState)([]),[x]=I.Z.useForm(),[g,j]=(0,n.useState)(null),[Z,_]=(0,n.useState)(""),[b,v]=(0,n.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[N,P]=(0,n.useState)([]),[E,D]=(0,n.useState)(a.OpenAI),[M,L]=(0,n.useState)(""),[F,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(null),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)([]),[el,em]=(0,n.useState)(null),[eh,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)([]),[ej,ef]=(0,n.useState)([]),[ey,eZ]=(0,n.useState)([]),[eb,ew]=(0,n.useState)([]),[eE,eT]=(0,n.useState)([]),[eD,eL]=(0,n.useState)([]),[eF,eR]=(0,n.useState)([]),[eX,eQ]=(0,n.useState)([]),[e4,e3]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e8,e6]=(0,n.useState)(null),[e7,e9]=(0,n.useState)(0),[le,ll]=(0,n.useState)({}),[ls,lt]=(0,n.useState)([]),[la,lr]=(0,n.useState)(!1),[ln,li]=(0,n.useState)(null),[lo,ld]=(0,n.useState)(null),[lc,lm]=(0,n.useState)([]),[lu,lh]=(0,n.useState)(!1),lx=e=>{let l=eP(e,g);v(l),console.log("providerModels: ".concat(l))},lp=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!i||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),em(e);let r=null==ln?void 0:ln.token;void 0===r&&(r=null);let n=lo;void 0===n&&(n=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,p.o6)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model metrics response:",o),eg(o.data),ef(o.all_api_bases);let d=await (0,p.Rg)(l,e,s.toISOString(),a.toISOString());eZ(d.data),ew(d.all_api_bases);let c=await (0,p.N8)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model exceptions response:",c),eT(c.data),eL(c.exception_types);let m=await (0,p.fP)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);if(console.log("slowResponses:",m),eQ(m),e){let t=await (0,p.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);ll(t);let r=await (0,p.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);lt(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,n.useEffect)(()=>{lp(el,e4.from,e4.to)},[ln,lo]);let lg=e=>{B(e),z(!0)},lj=e=>{B(e),V(!0)},lf=async e=>{if(console.log("handleEditSubmit:",e),null==l)return;let s={},t=null;for(let[l,a]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?s[l]=""===a?null:a:t=""===a?null:a;let a={litellm_params:Object.keys(s).length>0?s:void 0,model_info:void 0!==t?{id:t}:void 0};console.log("handleEditSubmit payload:",a);try{await (0,p.um)(l,a),C.ZP.success("Model updated successfully, restart server to see updates"),z(!1),B(null)}catch(e){console.log("Error occurred")}},ly=()=>{_(new Date().toLocaleString())},lZ=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e8);try{await (0,p.K_)(l,{router_settings:{model_group_retry_policy:e8}}),C.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),C.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!l||!s||!t||!i)return;let e=async()=>{try{var e,s,a,r,n,o,d,m,u,h,x,g;let j=await (0,p.hy)(l);P(j);let f=await (0,p.AZ)(l,i,t);console.log("Model data response:",f.data),c(f);let y=new Set;for(let e=0;e0&&(_=Z[Z.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",el);let b=await (0,p.o6)(l,i,t,_,null===(e=e4.from)||void 0===e?void 0:e.toISOString(),null===(s=e4.to)||void 0===s?void 0:s.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model metrics response:",b),eg(b.data),ef(b.all_api_bases);let v=await (0,p.Rg)(l,_,null===(a=e4.from)||void 0===a?void 0:a.toISOString(),null===(r=e4.to)||void 0===r?void 0:r.toISOString());eZ(v.data),ew(v.all_api_bases);let w=await (0,p.N8)(l,i,t,_,null===(n=e4.from)||void 0===n?void 0:n.toISOString(),null===(o=e4.to)||void 0===o?void 0:o.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model exceptions response:",w),eT(w.data),eL(w.exception_types);let S=await (0,p.fP)(l,i,t,_,null===(d=e4.from)||void 0===d?void 0:d.toISOString(),null===(m=e4.to)||void 0===m?void 0:m.toISOString(),null==ln?void 0:ln.token,lo),N=await (0,p.n$)(l,null===(u=e4.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=e4.to)||void 0===h?void 0:h.toISOString().split("T")[0],_);ll(N);let k=await (0,p.v9)(l,null===(x=e4.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(g=e4.to)||void 0===g?void 0:g.toISOString().split("T")[0],_);lt(k),console.log("dailyExceptions:",N),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",S),eQ(S);let I=await (0,p.j2)(l);lm(null==I?void 0:I.end_users);let C=(await (0,p.BL)(l,i,t)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,O=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",O),e6(A),e9(O)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&i&&e();let a=async()=>{let e=await (0,p.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),j(e)};null==g&&a(),ly()},[l,s,t,i,g,Z]),!o||!l||!s||!t||!i)return(0,r.jsx)("div",{children:"Loading..."});let l_=[],lb=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(g)),null!=g&&"object"==typeof g&&e in g)?g[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&&(n=null==a?void 0:a.input_cost_per_token,i=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=n,o.data[e].output_cost=i,o.data[e].litellm_model_name=s,lb.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===(lS=l.litellm_params)||void 0===lS?void 0:lS.api_base,o.data[e].cleanedLitellmParams=m,l_.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}=e_.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 lN=async()=>{try{C.ZP.info("Running health check..."),L("");let e=await (0,p.EY)(l);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lk=(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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:()=>{li(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:()=>{li(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{ld(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:()=>{li(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:()=>{li(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lI=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let n=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.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:[n&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),i.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(b.length));let lC=Object.keys(a).find(e=>a[e]===E);return lC&&N.find(e=>e.name===ek[lC]),(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,r.jsxs)(ei.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)(en.Z,{children:"All Models"}),(0,r.jsx)(en.Z,{children:"Add Model"}),(0,r.jsx)(en.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(en.Z,{children:"Model Analytics"}),(0,r.jsx)(en.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[Z&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",Z]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ly})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||void 0,onValueChange:e=>em("all"===e?"all":e),value:el||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(J.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(J.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)(J.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)(J.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)(J.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)(J.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:o.data.filter(e=>"all"===el||e.model_name===el||null==el||""===el).map((e,s)=>{var a;return(0,r.jsxs)($.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)(G.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,r.jsx)(G.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:eC(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)(G.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)(G.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)(G.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)(G.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)(G.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)(G.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)(G.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)(G.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(f.Z,{numItems:3,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eG.Z,size:"sm",onClick:()=>lj(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>lg(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(e$,{modelID:e.model_info.id,accessToken:l,callback:ly})})]})})]},s)})})]})})]}),(0,r.jsx)(eV,{visible:F,onCancel:()=>{z(!1),B(null)},model:q,onSubmit:lf}),(0,r.jsxs)(A.Z,{title:q&&q.model_name,visible:U,width:800,footer:null,onCancel:()=>{V(!1),B(null)},children:[(0,r.jsx)(S.Z,{children:"Model Info"}),(0,r.jsx)(e1.Z,{language:"json",children:q&&JSON.stringify(q,null,2)})]})]}),(0,r.jsxs)(ed.Z,{className:"h-full",children:[(0,r.jsx)(e2,{level:2,children:"Add new model"}),(0,r.jsx)(er.Z,{children:(0,r.jsx)(I.Z,{form:x,onFinish:()=>{x.validateFields().then(e=>{eU(e,l,x,ly)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(k.default,{showSearch:!0,value:E,onChange:e=>{D(e),lx(e),x.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(k.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eI[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)(eO,{selectedProvider:E,providerModels:b,getPlaceholder:eA}),(0,r.jsx)(eN,{}),(0,r.jsx)(ez,{selectedProvider:E,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;x.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?C.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&C.ZP.error("".concat(e.file.name," file upload failed."))}}}),(0,r.jsx)(eM,{showAdvancedSettings:lu,setShowAdvancedSettings:lh}),(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)(e_.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(y.Z,{onClick:lN,children:"Run `/health`"}),M&&(0,r.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:e4,className:"mr-2",onValueChange:e=>{e3(e),lp(el,e.from,e.to)}})]}),(0,r.jsxs)(eS.Z,{className:"ml-2",children:[(0,r.jsx)(w.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:el||K[0],value:el||K[0],children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lp(e,e4.from,e4.to),children:e},l))})]}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eH.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,r.jsx)(y.Z,{icon:eJ.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(en.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)(w.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ep&&ej&&(0,r.jsx)(eK.Z,{title:"Model Latency",className:"h-72",data:ep,showLegend:!1,index:"date",categories:ej,connectNulls:!0,customTooltip:lI})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e0,{modelMetrics:ey,modelMetricsCategories:eb,customTooltip:lI,premiumUser:m})})]})]})})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Deployment"}),(0,r.jsx)(J.Z,{children:"Success Responses"}),(0,r.jsxs)(J.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(H.Z,{children:eX.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.api_base}),(0,r.jsx)(G.Z,{children:e.total_count}),(0,r.jsx)(G.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Exceptions for ",el]}),(0,r.jsx)(eW.Z,{className:"h-60",data:eE,index:"model",categories:eD,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Up Rate Limit Errors (429) for ",el]}),(0,r.jsxs)(f.Z,{numItems:1,children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",le.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.Z,{className:"h-40",data:le.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eS.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:ls.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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:ls&&ls.length>0&&ls.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.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)(y.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)(S.Z,{children:e.api_base}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||K[0],value:el||K[0],onValueChange:e=>em(e),children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))})]}),(0,r.jsxs)(S.Z,{children:["Retry Policy for ",el]}),(0,r.jsx)(w.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),e5&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(e5).map((e,l)=>{var s;let[t,a]=e,n=null==e8?void 0:null===(s=e8[el])||void 0===s?void 0:s[a];return null==n&&(n=e7),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(O.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{e6(l=>{var s;let t=null!==(s=null==l?void 0:l[el])&&void 0!==s?s:{};return{...null!=l?l:{},[el]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(y.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})};function e8(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:n,Paragraph:i}=e_.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)(A.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(i,{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)(w.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(w.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)(w.Z,{children:"Invitation Link"}),(0,r.jsx)(w.Z,{children:(0,r.jsx)(w.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>C.ZP.success("Copied!"),children:(0,r.jsx)(y.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:e6}=k.default;var e7=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,n.useState)(null),[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)([]),[f,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),S=(0,i.useRouter)(),[N,P]=(0,n.useState)("http://localhost:4000");(0,n.useEffect)(()=>{(async()=>{try{let e=await (0,p.So)(s,l,"any"),t=[];for(let l=0;l{S&&P(new URL("/",window.location.href).toString())},[S]);let O=async e=>{try{var t;C.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,p.Ov)(s,null,e);console.log("user create Response:",a),x(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};v(e),_(!0)}else(0,p.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,v(e),_(!0)});C.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)(y.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(A.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),x(null),c.resetFields()},children:[(0,r.jsx)(w.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(I.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(k.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(e6,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(e6,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(I.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)(T.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(e8,{isInvitationLinkModalVisible:f,setIsInvitationLinkModalVisible:_,baseUrl:N,invitationLinkData:b})]})},e9=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,n.useState)(a),[c]=I.Z.useForm();(0,n.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,r.jsx)(A.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(I.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)(I.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)(I.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var le=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(1),[_,b]=n.useState(null),[v,w]=(0,n.useState)(null),[S,N]=(0,n.useState)(!1),[k,I]=(0,n.useState)(null),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{E(e),P(!0)},L=async()=>{if(O&&l)try{if(await (0,p.Eb)(l,[O]),C.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==O);h(e)}}catch(e){console.error("Error deleting user:",e),C.ZP.error("Failed to delete user")}P(!1),E(null)},F=async()=>{I(null),N(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,p.pf)(l,e,null),C.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)),I(null),N(!1)}};return((0,n.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(j));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,p.Br)(l,null,a,!0,j,25);sessionStorage.setItem("userList_".concat(j),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,p.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),D(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&i&&e()},[l,s,a,i,j]),u&&l&&s&&a&&i)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(f.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(e7,{userID:i,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)(ei.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(W.Z,{className:"mt-5",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(J.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(J.Z,{children:"API Keys"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.user_id||"-"}),(0,r.jsx)(G.Z,{children:e.user_email||"-"}),(0,r.jsx)(G.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)(G.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)(G.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(f.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)(G.Z,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,onClick:()=>{I(e),N(!0)},children:"View Keys"}),(0,r.jsx)(eB.Z,{icon:eh.Z,onClick:()=>M(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)(e9,{visible:S,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: ",O]})]})]})})}),(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{P(!1),E(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),Z(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",j," 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===j,onClick:()=>l(j-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:j===e,onClick:()=>l(j+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},ll=e=>{var l,s,t;let{visible:a,onCancel:i,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=I.Z.useForm();console.log("Initial Data:",d),(0,n.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(),C.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){C.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)(k.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(A.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:i,children:(0,r.jsxs)(I.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(I.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)(w.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(I.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)(I.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)(k.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)(k.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(k.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)(I.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)(T.ZP,{onClick:i,className:"mr-2",children:"Cancel"}),(0,r.jsx)(T.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},ls=s(7310),lt=s.n(ls),la=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:i="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]=I.Z.useForm(),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}x(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,p.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{x(!1)}},y=(0,n.useCallback)(lt()((e,l)=>f(e,l),300),[]),Z=(e,l)=>{j(l),y(e,l)},_=(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)(A.Z,{title:i,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(I.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(I.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>Z(e,"user_email"),onSelect:(e,l)=>_(e,l),options:"user_email"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>Z(e,"user_id"),onSelect:(e,l)=>_(e,l),options:"user_id"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(I.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(k.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)(T.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},lr=e=>{let{teamId:l,accessToken:s,currentAliases:t,availableModels:a,onUpdate:i}=e,[o,d]=(0,n.useState)(!1),[c]=I.Z.useForm(),m=async e=>{try{if(!s)return;let a={...t,[e.alias_name]:e.original_model};await (0,p.Gh)(s,{team_id:l,model_aliases:a}),C.ZP.success("Model alias created successfully"),d(!1),c.resetFields(),t[e.alias_name]=e.original_model}catch(e){C.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)(S.Z,{children:"Team Aliases"}),(0,r.jsx)(w.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)(y.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)(A.Z,{title:"Create Model Alias",open:o,onCancel:()=>{d(!1),c.resetFields()},footer:null,width:500,children:(0,r.jsxs)(I.Z,{form:c,onFinish:m,layout:"vertical",className:"mt-4",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Points To",name:"original_model",rules:[{required:!0,message:"Please select a model"}],children:(0,r.jsx)(k.default,{placeholder:"Select model version",className:"w-full font-mono",showSearch:!0,optionFilterProp:"children",children:a.map(e=>(0,r.jsx)(k.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)(y.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)(y.Z,{size:"md",variant:"secondary",type:"submit",children:"Create Alias"})]})]})})]})},ln=e=>{var l,s,t;let{teamId:a,onClose:i,accessToken:o,is_team_admin:d,is_proxy_admin:c,userModels:m,editTeam:u}=e,[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)(!0),[Z,_]=(0,n.useState)(!1),[b]=I.Z.useForm(),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),[D,L]=(0,n.useState)(!1);console.log("userModels in team info",m);let z=d||c,U=async()=>{try{if(j(!0),!o)return;let e=await (0,p.Xm)(o,a);x(e)}catch(e){C.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{j(!1)}};(0,n.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,p.cu)(o,a,l),C.ZP.success("Team member added successfully"),_(!1),b.resetFields(),U()}catch(e){C.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,p.sN)(o,a,l),C.ZP.success("Team member updated successfully"),N(!1),U()}catch(e){C.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},B=async e=>{try{if(null==o)return;await (0,p.Lp)(o,a,e),C.ZP.success("Team member removed successfully"),U()}catch(e){C.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,p.Gh)(o,s),C.ZP.success("Team settings updated successfully"),L(!1),U()}catch(e){C.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(g)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:X}=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)(T.ZP,{onClick:i,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:X.team_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:X.team_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:u?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",X.spend.toFixed(6)]}),(0,r.jsxs)(w.Z,{children:["of ",null===X.max_budget?"Unlimited":"$".concat(X.max_budget)]}),X.budget_duration&&(0,r.jsxs)(w.Z,{className:"text-gray-500",children:["Reset: ",X.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",X.rpm_limit||"Unlimited"]}),X.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",X.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:X.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:h.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)(G.Z,{children:z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P(e),N(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>B(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(y.Z,{onClick:()=>_(!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)(S.Z,{children:"Team Settings"}),z&&!D&&(0,r.jsx)(y.Z,{onClick:()=>L(!0),children:"Edit Settings"})]}),D?(0,r.jsxs)(I.Z,{form:b,onFinish:K,initialValues:{...X,team_alias:X.team_alias,models:X.models,tpm_limit:X.tpm_limit,rpm_limit:X.rpm_limit,max_budget:X.max_budget,budget_duration:X.budget_duration,guardrails:(null===(l=X.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),m.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>L(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:X.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:X.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(X.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:X.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",X.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==X.max_budget?"$".concat(X.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",X.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:X.blocked?"red":"green",children:X.blocked?"Blocked":"Active"})]})]})]}),(0,r.jsx)(lr,{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)(ll,{visible:v,onCancel:()=>N(!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)(la,{isVisible:Z,onCancel:()=>_(!1),onSubmit:V,accessToken:o})]})},li=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,p.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let i=async e=>{if(l&&s)try{await (0,p.cu)(l,e,{user_id:s,role:"user"}),C.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),C.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Description"}),(0,r.jsx)(J.Z,{children:"Members"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsxs)(H.Z,{children:[t.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.team_alias})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.description||"No description available"})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{size:"xs",variant:"secondary",onClick:()=>i(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(w.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};var lo=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o,currentOrg:d}=e,[c,m]=(0,n.useState)("");(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&g(t,i,o,d,a)},[l]),(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&g(t,i,o,d,a),ek()},[c]);let[u]=I.Z.useForm(),[h]=I.Z.useForm(),{Title:x,Paragraph:S}=e_.default,[N,P]=(0,n.useState)(""),[E,L]=(0,n.useState)(!1),[z,U]=(0,n.useState)(null),[V,q]=(0,n.useState)(null),[B,K]=(0,n.useState)(!1),[X,Q]=(0,n.useState)(!1),[ee,el]=(0,n.useState)(!1),[es,et]=(0,n.useState)(!1),[em,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)(!1),[ej,ef]=(0,n.useState)(null),[ey,eZ]=(0,n.useState)({}),[eb,ev]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,p.t3)(t)).guardrails.map(e=>e.guardrail_name);ev(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let ew=async e=>{ef(e),eg(!0)},eS=async()=>{if(null!=ej&&null!=l&&null!=t){try{await (0,p.rs)(t,ej);let e=l.filter(e=>e.team_id!==ej);a(e)}catch(e){console.error("Error deleting the team:",e)}eg(!1),ef(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{let e;if(null===i||null===o||null===t||null===l)return;let s={};e="Admin"!=o&&"Admin Viewer"!=o?await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO,i):await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO);for(let l=0;l{try{if(null===i||null===o||null===t)return;let e=await D(i,o,t);e&&ex(e)}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eN=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,n=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=(null==e?void 0:e.organization_id)||(null==d?void 0:d.organization_id);if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,n.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));C.ZP.info("Creating Team");let o=await (0,p.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),C.ZP.success("Team created"),Q(!1)}}catch(e){console.error("Error creating the team:",e),C.ZP.error("Error creating the team: "+e,20)}},ek=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4",children:V?(0,r.jsx)(ln,{teamId:V,onClose:()=>{q(null),K(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===V)),is_proxy_admin:"Admin"==o,userModels:em,editTeam:B}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Teams"}),(0,r.jsx)(en.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ek})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(w.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(f.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-y-auto max-h-[50vh]",children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Team ID"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"})]})}),(0,r.jsx)(H.Z,{children:l&&l.length>0?l.filter(e=>{let l=d?d.organization_id:null;return e.organization_id===l}).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(y.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:()=>{q(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)(G.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)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(w.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,r.jsxs)(w.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,r.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,r.jsxs)(G.Z,{children:[(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].keys&&ey[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].members_with_roles&&ey[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)(G.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{q(e.team_id),K(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>ew(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),ep&&(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)(y.Z,{onClick:eS,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{eg(!1),ef(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>Q(!0),children:"+ Create New Team"}),(0,r.jsx)(A.Z,{title:"Create Team",visible:X,width:800,footer:null,onOk:()=>{Q(!1),u.resetFields()},onCancel:()=>{Q(!1),u.resetFields()},children:(0,r.jsxs)(I.Z,{form:u,onFinish:eN,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),em.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,r.jsx)(Z.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eb.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(li,{accessToken:t,userID:i})})]})]})})},ld=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:i,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(!0),[g]=I.Z.useForm(),[j,Z]=(0,n.useState)(!1),[_,b]=(0,n.useState)(!1),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),D=i||o,L=async()=>{try{if(x(!0),!a)return;let e=await (0,p.t$)(a,s);u(e)}catch(e){C.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{x(!1)}};(0,n.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,p.vh)(a,s,l),C.ZP.success("Organization member added successfully"),b(!1),g.resetFields(),L()}catch(e){C.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,p.LY)(a,s,l),C.ZP.success("Organization member updated successfully"),N(!1),g.resetFields(),L()}catch(e){C.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,p.Sb)(a,s,e.user_id),C.ZP.success("Organization member deleted successfully"),N(!1),g.resetFields(),L()}catch(e){C.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");C.ZP.success("Organization settings updated successfully"),Z(!1),L()}catch(e){C.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)(T.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:m.organization_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(w.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)(w.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Created At"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)(G.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),N(!0)}}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(y.Z,{onClick:()=>{b(!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)(S.Z,{children:"Organization Settings"}),D&&!j&&(0,r.jsx)(y.Z,{onClick:()=>Z(!0),children:"Edit Settings"})]}),j?(0,r.jsxs)(I.Z,{form:g,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)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>Z(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.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)(w.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)(w.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)(w.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)(la,{isVisible:_,onCancel:()=>b(!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)(ll,{visible:v,onCancel:()=>N(!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 lc=async(e,l)=>{l(await (0,p.r6)(e))};var lm=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:i,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,x]=(0,n.useState)(null),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(null),[P,E]=(0,n.useState)(!1),[T]=I.Z.useForm();(0,n.useEffect)(()=>{0===l.length&&a&&lc(a,m)},[l,a]);let D=e=>{e&&(N(e),v(!0))},L=async()=>{if(S&&a)try{await (0,p.cq)(a,S),C.ZP.success("Organization deleted successfully"),v(!1),N(null),lc(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,p.H1)(a,e),E(!1),T.resetFields(),lc(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(ld,{organizationId:h,onClose:()=>{x(null),_(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:g}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[i&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",i]}),(0,r.jsx)(eB.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)(w.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(f.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Organization ID"}),(0,r.jsx)(J.Z,{children:"Organization Name"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsx)(H.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,n,i,o,d,c,m;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(y.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:()=>x(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)(G.Z,{children:e.organization_alias}),(0,r.jsx)(G.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{children:e.spend}),(0,r.jsx)(G.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===(n=e.litellm_budget_table)||void 0===n?void 0:n.max_budget:"No limit"}),(0,r.jsx)(G.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["TPM: ",(null===(i=e.litellm_budget_table)||void 0===i?void 0:i.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)(G.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{x(e.organization_id),_(!0)}}),(0,r.jsx)(eB.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)(y.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Organization"}),(0,r.jsx)(A.Z,{title:"Create Organization",visible:P,width:800,footer:null,onCancel:()=>{E(!1),T.resetFields()},children:(0,r.jsxs)(I.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(y.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),b?(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{v(!1),N(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(w.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 lu=()=>{let[e,l]=(0,n.useState)("http://localhost:4000");return(0,n.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lh=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=I.Z.useForm(),[d]=I.Z.useForm(),{Title:c,Paragraph:m}=e_.default,[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(!1),[v,S]=(0,n.useState)(!1),[N,k]=(0,n.useState)(!1),[P,O]=(0,n.useState)(!1),[D,M]=(0,n.useState)(!1),[L,F]=(0,n.useState)(!1),[R,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(!1),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(null);(0,i.useRouter)();let[el,es]=(0,n.useState)(null);console.log=function(){};let et=lu(),ea="All IP Addresses Allowed",en=et;en+="/fallback/login";let ei=async()=>{try{if(!0!==a){C.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,p.PT)(s);X(e&&e.length>0?e:[ea])}else X([ea])}catch(e){console.error("Error fetching allowed IPs:",e),C.ZP.error("Failed to fetch allowed IPs ".concat(e)),X([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,p.eH)(s,e.ip);let l=await (0,p.PT)(s);X(l),C.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),C.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{ee(e),B(!0)},ec=async()=>{if(Q&&s)try{await (0,p.$I)(s,Q);let e=await (0,p.PT)(s);X(e.length>0?e:[ea]),C.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),C.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),ee(null)}},em=()=>{F(!1)};(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,p.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,p.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)),g(e),es(await (0,p.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=x){var l;C.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,p.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,p.XO)(s,a).then(e=>{Z(e),b(!0)}),console.log("response for team create call: ".concat(t));let r=x.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"),x.push(t),g(x)),o.resetFields(),k(!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,p.K_)(s,l)};return console.log("admins: ".concat(null==x?void 0:x.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)(f.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)(y.Z,{onClick:()=>!0===a?M(!0):C.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(y.Z,{onClick:ei,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(A.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{M(!1),o.resetFields()},onCancel:()=>{M(!1),o.resetFields()},children:(0,r.jsxs)(I.Z,{form:o,onFinish:e=>{eu(e),eh(e),M(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.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)(I.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(A.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)(w.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(w.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)(T.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(A.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(y.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"IP Address"}),(0,r.jsx)(J.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(H.Z,{children:K.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e}),(0,r.jsx)(G.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(y.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(A.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(I.Z,{onFinish:eo,children:[(0,r.jsx)(I.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)(I.Z.Item,{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(A.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(y.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",Q,"?"]})})]}),(0,r.jsxs)(eX.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:en,target:"_blank",children:[(0,r.jsx)("b",{children:en})," "]})]})]})]})},lx=s(92858),lp=s(44643),lg=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:n}=e,[i]=I.Z.useForm();return(0,r.jsxs)(I.Z,{form:i,onFinish:()=>{console.log("INSIDE ONFINISH");let e=i.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)($.Z,{children:[(0,r.jsxs)(G.Z,{align:"center",children:[(0,r.jsx)(w.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?n?(0,r.jsx)(I.Z.Item,{name:e.field_name,children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lx.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)(G.Z,{children:(0,r.jsx)(y.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)(I.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lx.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lj=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(0,p.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lg,{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,...n}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(n)));try{(0,p.jA)(l,"alerting_args",n),"boolean"==typeof r&&(!0==r?(0,p.jA)(l,"alerting",["slack"]):(0,p.jA)(l,"alerting",[])),C.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lf=s(86582);let{Title:ly,Paragraph:lZ}=e_.default;console.log=function(){};var l_=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,n.useState)([]),[d,c]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[h]=I.Z.useForm(),[x,g]=(0,n.useState)(null),[j,_]=(0,n.useState)([]),[b,v]=(0,n.useState)(""),[S,N]=(0,n.useState)({}),[P,O]=(0,n.useState)([]),[E,D]=(0,n.useState)(!1),[M,L]=(0,n.useState)([]),[F,R]=(0,n.useState)(null),[z,U]=(0,n.useState)([]),[V,q]=(0,n.useState)(!1),[B,K]=(0,n.useState)(null),X=e=>{P.includes(e)?O(P.filter(l=>l!==e)):O([...P,e])},Q={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,n.useEffect)(()=>{l&&s&&t&&(0,p.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),O(e.active_alerts),v(s),N(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ee=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,p.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.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,p.K_)(l,{environment_variables:s}),C.ZP.success("Callback added successfully"),u(!1),h.resetFields(),g(null)}catch(e){C.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,p.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),C.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),g(null)}catch(e){C.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),g(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(i)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(en.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(en.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(en.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(f.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(J.Z,{children:"Callback Name"})})}),(0,r.jsx)(H.Z,{children:i.map((e,s)=>(0,r.jsxs)($.Z,{className:"flex justify-between",children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.name})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(Q).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)}):(0,r.jsx)(y.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)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:S&&S[s]?S[s]:b})})]},l)})})]}),(0,r.jsx)(y.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(Q).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,p.K_)(l,s)}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lj,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Email Settings"}),(0,r.jsxs)(w.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)(G.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(f.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)(w.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)(w.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)(y.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(A.Z,{title:"Add Logging Callback",visible:E,width:800,onCancel:()=>D(!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)(I.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lf.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(k.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),em(l))},children:M&&Object.values(M).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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(A.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(I.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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lb=s(92414),lv=s(46030);let{Option:lw}=k.default;var lS=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=I.Z.useForm(),[o,d]=(0,n.useState)(!1),[c,m]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(A.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,r.jsxs)(I.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,n=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:n};console.log(o);try{(0,p.K_)(s,{router_settings:o}),a(o)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lb.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lN=s(33619);async function lk(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lN.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});C.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lI={ttl:3600,lowest_latency_buffer:0},lC=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)(b.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(w.Z,{children:"No specific settings"})})]})};var lA=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)({}),[d,c]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g]=I.Z.useForm(),[_,b]=(0,n.useState)(null),[v,N]=(0,n.useState)(null),[k,A]=(0,n.useState)(null),P={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,n.useEffect)(()=>{l&&s&&t&&((0,p.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,p.YU)(l).then(e=>{u(e)}))},[l,s,t]);let E=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks));let s=i.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...i,fallbacks:s};try{await (0,p.K_)(l,{router_settings:t}),o(t),C.ZP.success("Router settings updated successfully")}catch(e){C.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))},D=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,p.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},M=(e,s)=>{if(l)try{(0,p.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,v];if("routing_strategy_args"==l&&"latency-based-routing"==v){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,p.K_)(l,{router_settings:s})}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(ei.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)(en.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(en.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(en.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(S.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(i).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)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,r.jsx)(G.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:N,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)(lC,{selectedStrategy:v,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:lI,paramExplanation:P})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>L(i),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Model Name"}),(0,r.jsx)(J.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(H.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:t}),(0,r.jsx)(G.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{onClick:()=>lk(t,l),children:"Test Fallback"})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lS,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"}),(0,r.jsx)(J.Z,{children:"Status"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.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)(G.Z,{children:"Integer"==e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:[(0,r.jsx)(y.Z,{onClick:()=>D(e.field_name,l),children:"Update"}),(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>M(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lP=s(93142),lO=s(45246),lE=s(96473),lT=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,n.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let n=[...t];n[e]=[l,r],a(n),null==s||s(Object.fromEntries(n))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lP.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)(lO.Z,{onClick:()=>i(l)})]},l)}),(0,r.jsx)(T.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lE.Z,{}),children:"Add Header"})]})};let{Option:lD}=k.default;var lM=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=I.Z.useForm(),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(A.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(I.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,p.Vt)(l,e),s(r)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.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)(I.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)(I.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)(I.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)(lT,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lL=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&s&&t&&(0,p.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,p.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),C.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(ei.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Path"}),(0,r.jsx)(J.Z,{children:"Target"}),(0,r.jsx)(J.Z,{children:"Headers"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:i.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.path})}),(0,r.jsx)(G.Z,{children:e.target}),(0,r.jsx)(G.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lM,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lF=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[n]=I.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call");let l=await (0,p.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),C.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),n.resetFields()},onCancel:()=>{t(!1),n.resetFields()},children:(0,r.jsxs)(I.Z,{form:n,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lR=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=I.Z.useForm();(0,n.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call"),t(!0);let l=await (0,p.qI)(s,e);a(e=>e?[...e,l]:[l]),C.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(I.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},lz=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)(!1),[a,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),[c,m]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&(0,p.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),i(!0))},h=async(e,s)=>{if(null==l)return;C.ZP.info("Request made"),await (0,p.NV)(l,e);let t=[...c];t.splice(s,1),m(t),C.ZP.success("Budget Deleted.")},x=async()=>{null!=l&&(0,p.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)(y.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lF,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lR,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:x}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Budget ID"}),(0,r.jsx)(J.Z,{children:"Max Budget"}),(0,r.jsx)(J.Z,{children:"TPM"}),(0,r.jsx)(J.Z,{children:"RPM"})]})}),(0,r.jsx)(H.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)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.budget_id}),(0,r.jsx)(G.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)(G.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)(G.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(w.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(en.Z,{children:"Test it (Curl)"}),(0,r.jsx)(en.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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)'})})]})]})]})]})},lU=s(77398),lV=s.n(lU),lq=s(20016);async function lB(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 lK=e=>{let{ipAddress:l}=e,[s,t]=n.useState("-");return n.useEffect(()=>{if(!l)return;let e=!0;return lB(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},lW=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"}},lH=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:lW(l)})},lG=[{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)(lH,{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)(lK,{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:eC(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)]})})})}}],lY=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,p.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 lJ(e){var l,s,t;let{accessToken:a,token:i,userRole:o,userID:d}=e,[m,u]=(0,n.useState)(""),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1),[f,y]=(0,n.useState)(1),[Z]=(0,n.useState)(50),_=(0,n.useRef)(null),b=(0,n.useRef)(null),v=(0,n.useRef)(null),[w,S]=(0,n.useState)(lV()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[N,k]=(0,n.useState)(lV()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,n.useState)(!1),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(""),[T,D]=(0,n.useState)(""),[M,L]=(0,n.useState)(""),[F,R]=(0,n.useState)(""),[z,U]=(0,n.useState)("Team ID"),V=(0,c.NL)();(0,n.useEffect)(()=>{function e(e){_.current&&!_.current.contains(e.target)&&j(!1),b.current&&!b.current.contains(e.target)&&x(!1),v.current&&!v.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,lq.a)({queryKey:["logs","table",f,Z,w,N,M,F],queryFn:async()=>{if(!a||!i||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:Z,total_pages:0};let e=lV()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?lV()(N).utc().format("YYYY-MM-DD HH:mm:ss"):lV()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,p.h3)(a,F||void 0,M||void 0,void 0,e,l,f,Z);return await lY(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&&!!i&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!i||!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(lV()(w).format("MMM D, h:mm A")," - ").concat(lV()(N).format("MMM D, h:mm A"));let e=lV()(),l=lV()(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:b,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:()=>x(!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:()=>j(!g),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"})})]}),g&&(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),j(!1),"Team ID"===e?D(""):E("")},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?O:T,onChange:e=>{"Team ID"===z?E(e.target.value):D(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{E(""),D("")},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:()=>{E(""),D(""),x(!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(O),R(T),y(1),x(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:v,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(lV()().format("YYYY-MM-DDTHH:mm")),S(lV()().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=>{S(e.target.value),y(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:N,onChange:e=>{k(e.target.value),y(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)*Z+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*Z,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:()=>y(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:()=>y(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:lG,data:B,renderSubComponent:l$,getRowCanExpand:()=>!0})]})]})}function l$(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 lX=s(92699),lQ=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)(f.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)(w.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(en.Z,{children:"LlamaIndex"}),(0,r.jsx)(en.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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 ')})})]})]})]})})})},l0=s(243),l1=s(94263);async function l2(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lN.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var l4=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,n.useState)(i?"custom":"session"),[c,m]=(0,n.useState)(""),[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)([]),[_,b]=(0,n.useState)(void 0),[v,S]=(0,n.useState)([]),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,p.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)),S(s),b(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,n.useEffect)(()=>{N.current&&setTimeout(()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[x]);let I=(e,l,s)=>{g(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){C.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},n=[...x.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];g([...x,r]);try{_&&await l2(n,(e,l)=>I("assistant",e,l),_,e)}catch(e){console.error("Error fetching model response",e),I("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=e_.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)(f.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(en.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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"API Key Source"}),(0,r.jsx)(k.default,{disabled:i,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)(w.Z,{children:"Select Model:"}),(0,r.jsx)(k.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),b(e)},options:v,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(y.Z,{onClick:()=>{g([]),C.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(W.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{})})}),(0,r.jsxs)(H.Z,{children:[x.map((e,l)=>(0,r.jsx)($.Z,{children:(0,r.jsxs)(G.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)(l0.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...n}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,r.jsx)(e1.Z,{style:l1.Z,language:i[1],PreTag:"div",...n,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...n,children:a})}},children:e.content})})]})},l)),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{ref:N,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)(y.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},l5=s(19226),l3=s(61787),l8=s(92403),l6=s(28595),l7=s(68208),l9=s(9775),se=s(41361),sl=s(37527),ss=s(15883),st=s(12660),sa=s(88009),sr=s(48231),sn=s(41169),si=s(44625),so=s(57400),sd=s(55322);let{Sider:sc}=l5.default,sm=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],su=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(l8.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(l6.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(l7.Z,{}),roles:sm},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(l9.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(se.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(ss.Z,{}),roles:sm},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(st.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sa.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sr.Z,{}),roles:sm},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sn.Z,{}),roles:sm,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(si.Z,{}),roles:sm},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(so.Z,{}),roles:sm}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(st.Z,{}),roles:sm},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm}]}];var sh=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=su.find(l=>l.page===e);if(l)return l.key;for(let l of su)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),n=su.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(l5.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sc,{theme:"light",width:220,children:(0,r.jsx)(l3.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:n.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)}}})})})})},sx=s(96889);console.log=function(){};var sp=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,n.useState)(null!==a?a:0),[m,u]=(0,n.useState)(o?o.max_budget:null);(0,n.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(i);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,i]);let[h,x]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,p.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,n.useEffect)(()=>{null!==a&&c(a)},[a]);let g=[];o&&o.models&&(g=o.models),g&&g.includes("all-proxy-models")?(console.log("user models:",h),g=h):g&&g.includes("all-team-models")?g=o.models:g&&0===g.length&&(g=h);let j=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:["$",j]})]}),(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"})]})]})})},sg=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sj=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sf=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[b,v]=(0,n.useState)([]),[N,k]=(0,n.useState)([]),[I,C]=(0,n.useState)([]),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)([]),[T,D]=(0,n.useState)([]),[M,L]=(0,n.useState)({}),[F,R]=(0,n.useState)([]),[z,U]=(0,n.useState)(""),[V,q]=(0,n.useState)(["all-tags"]),[B,K]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[X,Q]=(0,n.useState)(null),[ee,el]=(0,n.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",i),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,p.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,n.useEffect)(()=>{ej(B.from,B.to)},[B,V]);let eg=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,p.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),_(a)},ej=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,p.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 ey=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eZ=(e,l,s,t)=>{let a=[],r=new Date(l),n=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]}},i=new Map(e.map(e=>{let l=n(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(i.has(e))a.push(i.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},e_=async()=>{if(l)try{let e=await (0,p.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=eZ(e,t,a,[]),n=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(n),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},eb=()=>ey(()=>l&&s?(0,p.OU)(l,s,eu,eh):Promise.reject("No access token or token"),D,"Error fetching provider spend"),ew=async()=>{l&&await ey(async()=>(await (0,p.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")},eS=async()=>{l&&await ey(async()=>(await (0,p.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),g,"Error fetching top models")},eN=async()=>{l&&await ey(async()=>{let e=await (0,p.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return v(eZ(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)}))},E,"Error fetching team spend")},ek=()=>{l&&ey(async()=>(await (0,p.X)(l)).tag_names,C,"Error fetching tag names")},eI=()=>{l&&ey(()=>{var e,s;return(0,p.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&&ey(()=>(0,p.b1)(l,null,void 0,void 0),_,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,p.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=eZ(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,p.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:eZ(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,n.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(Q(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",X),e_(),eb(),ew(),eS(),eA(),eP(),sj(t)&&(eN(),ek(),eI(),eC()))}})()},[l,s,t,a,eu,eh]),null==X?void 0:X.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(w.Z,{className:"mt-4",children:["SpendLogs in DB has ",X.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)(y.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(en.Z,{children:"All Up"}),sj(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(en.Z,{children:"Team Based Usage"}),(0,r.jsx)(en.Z,{children:"Customer Usage"}),(0,r.jsx)(en.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(en.Z,{children:"Cost"}),(0,r.jsx)(en.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(w.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)(sp,{userID:a,userRole:t,accessToken:l,userSpend:ee,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Monthly Spend"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top API Keys"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top Models"}),(0,r.jsx)(eW.Z,{className:"mt-4 h-40",data:x,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)(S.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sg.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Provider"}),(0,r.jsx)(J.Z,{children:"Spend"})]})}),(0,r.jsx)(H.Z,{children:T.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.provider}),(0,r.jsx)(G.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)(f.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"All Up"}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(M.sum_api_requests)]}),(0,r.jsx)(eK.Z,{className:"h-40",data:M.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(M.sum_total_tokens)]}),(0,r.jsx)(eW.Z,{className:"h-40",data:M.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)(S.Z,{children:e.model}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(eK.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eW.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)(f.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)(S.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sx.Z,{data:O})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eW.Z,{className:"h-72",data:b,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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{eg(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{eg(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(W.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Customer"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Total Events"})]})}),(0,r.jsx)(H.Z,{children:null==Z?void 0:Z.map((e,l)=>{var s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.end_user}),(0,r.jsx)(G.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)(G.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eq.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(lv.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(f.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)(S.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(w.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)(eW.Z,{className:"h-72",data:N,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sy=e=>{if(e)return e.toISOString().split("T")[0]};function sZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var s_=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,n.useState)([]),[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)("0"),[b,v]=(0,n.useState)("0"),[S,N]=(0,n.useState)("0"),[k,I]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,n.useState)(""),[O,E]=(0,n.useState)("");(0,n.useEffect)(()=>{l&&k&&((async()=>{g(await (0,p.zg)(l,sy(k.from),sy(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),D=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let M=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),g(await (0,p.zg)(l,sy(e),sy(s))))};(0,n.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",x);let e=x;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},[]);_(sZ(s)),v(sZ(t));let r=s+l;r>0?N((s/r*100).toFixed(2)):N("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,x]);let L=async()=>{try{C.ZP.info("Running cache health check..."),E("");let e=await (0,p.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),E(e)}catch(e){console.error("Error running health check:",e),E("Error running health check")}};return(0,r.jsxs)(ei.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)(en.Z,{children:"Cache Analytics"}),(0,r.jsx)(en.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)(w.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eB.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)(f.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:D.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eq.Z,{enableSelect:!0,value:k,onValueChange:e=>{I(e),M(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:[S,"%"]})})]}),(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:Z})})]}),(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:b})})]})]}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eW.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eW.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sZ,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)(w.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(y.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),O&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(O,null,2)})]})})]})]})},sb=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(async()=>{try{let e=await (0,p.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)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Guardrail Name"}),(0,r.jsx)(J.Z,{children:"Mode"}),(0,r.jsx)(J.Z,{children:"Status"})]})}),(0,r.jsx)(H.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.guardrail_name}),(0,r.jsx)(G.Z,{children:e.litellm_params.mode}),(0,r.jsx)(G.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)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};function sv(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"}}let sw=new d.S;function sS(){let[e,l]=(0,n.useState)(""),[s,t]=(0,n.useState)(!1),[a,d]=(0,n.useState)(!1),[u,h]=(0,n.useState)(null),[g,j]=(0,n.useState)(null),[f,y]=(0,n.useState)(null),[Z,_]=(0,n.useState)(m),[b,v]=(0,n.useState)([]),[w,S]=(0,n.useState)([]),[N,k]=(0,n.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[I,C]=(0,n.useState)(!0),A=(0,i.useSearchParams)(),[P,O]=(0,n.useState)({data:[]}),[E,T]=(0,n.useState)(null),D=A.get("userID"),M=A.get("invitation_id"),[L,F]=(0,n.useState)(()=>A.get("page")||"api-keys"),[R,z]=(0,n.useState)(null);return(0,n.useEffect)(()=>{T(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,n.useEffect)(()=>{if(!E)return;let e=(0,o.o)(E);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),z(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=sv(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&F("usage")}else console.log("User role not defined");e.user_email?h(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?C("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,p.K8)(e.auth_header_name)}},[E]),(0,n.useEffect)(()=>{R&&D&&e&&q(D,e,R,S)},[R,D,e]),(0,r.jsx)(n.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sw,children:M?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(x,{userID:D,userRole:e,userEmail:u,premiumUser:s,setProxySettings:k,proxySettings:N,currentOrg:Z,organizations:b,onOrgChange:s=>{if(_(s),console.log("org: ".concat(JSON.stringify(s))),s.members&&"Admin"!=e)for(let e of s.members)console.log("member: ".concat(JSON.stringify(e))),e.user_id==D&&(console.log("member.user_role: ".concat(e.user_role)),l(sv(e.user_role)));j(null)}}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sh,{setPage:e=>{let l=new URLSearchParams(A);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),F(e)},userRole:e,defaultSelectedKey:L})}),"api-keys"==L?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):"models"==L?(0,r.jsx)(e3,{userID:D,userRole:e,token:E,keys:f,accessToken:R,modelData:P,setModelData:O,premiumUser:s}):"llm-playground"==L?(0,r.jsx)(l4,{userID:D,userRole:e,token:E,accessToken:R,disabledPersonalKeyCreation:a}):"users"==L?(0,r.jsx)(le,{userID:D,userRole:e,token:E,keys:f,teams:g,accessToken:R,setKeys:y}):"teams"==L?(0,r.jsx)(lo,{teams:g,setTeams:j,searchParams:A,accessToken:R,userID:D,userRole:e,currentOrg:Z}):"organizations"==L?(0,r.jsx)(lm,{organizations:b,setOrganizations:v,userModels:w,accessToken:R,userRole:e,premiumUser:s}):"admin-panel"==L?(0,r.jsx)(lh,{setTeams:j,searchParams:A,accessToken:R,showSSOBanner:I,premiumUser:s}):"api_ref"==L?(0,r.jsx)(lQ,{proxySettings:N}):"settings"==L?(0,r.jsx)(l_,{userID:D,userRole:e,accessToken:R,premiumUser:s}):"budgets"==L?(0,r.jsx)(lz,{accessToken:R}):"guardrails"==L?(0,r.jsx)(sb,{accessToken:R}):"general-settings"==L?(0,r.jsx)(lA,{userID:D,userRole:e,accessToken:R,modelData:P}):"model-hub"==L?(0,r.jsx)(lX.Z,{accessToken:R,publicPage:!1,premiumUser:s}):"caching"==L?(0,r.jsx)(s_,{userID:D,userRole:e,token:E,accessToken:R,premiumUser:s}):"pass-through-settings"==L?(0,r.jsx)(lL,{userID:D,userRole:e,accessToken:R,modelData:P}):"logs"==L?(0,r.jsx)(lJ,{userID:D,userRole:e,token:E,accessToken:R}):(0,r.jsx)(sf,{userID:D,userRole:e,token:E,accessToken:R,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,270,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-7a5ba6fe8c2fe4b2.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.js deleted file mode 100644 index 7c4b4beb9a8..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.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,36733))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return y}});var t=s(57437),a=s(2265),r=s(99376),n=s(20831),i=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),g=s(14474),j=s(13634),f=s(73002);function y(){let[e]=j.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"),[y,Z]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,N]=(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,g.o)(s);A(s),console.log("decoded:",t),Z(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),N(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)(i.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)(n.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)(j.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",y,"token:",C,"formValues:",e),y&&C&&(e.user_email=v,S&&s&&(0,p.m_)(y,s,S,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)(j.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:v,defaultValue:v,className:"max-w-md"})}),(0,t.jsx)(j.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"})})]})]})})}},36733:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sS}});var t,a,r=s(57437),n=s(2265),i=s(99376),o=s(14474),d=s(90946),c=s(29827);let m={organization_id:null,organization_alias:"Default Organization"};var u=s(27648),h=s(92643),x=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:n,proxySettings:i,currentOrg:o=null,onOrgChange:d=()=>{},onNewOrg:c=()=>{},organizations:x=[]}=e;console.log("currentOrg: ".concat(JSON.stringify(o))),console.log("organizations: ".concat(JSON.stringify(x)));let p=(null==i?void 0:i.PROXY_LOGOUT_URL)||"",g=[{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(a)]})]})},{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=p},children:"Logout"})}],j=[{key:"header",label:"Organizations",type:"group",style:{color:"#6B7280",fontSize:"0.875rem"}},{key:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:"Default Organization"})}),onClick:()=>d(m)},...x.filter(e=>null!==e.organization_id).map(e=>{var l;return{key:null!==(l=e.organization_id)&&void 0!==l?l:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:e.organization_alias})}),onClick:()=>d(e)}}),{key:"note",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 text-gray-500 text-xs italic",children:(0,r.jsx)("span",{children:"Switching between organizations on the UI is currently in beta."})}),disabled:!0}];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)(u.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:"ml-8 flex items-center",children:[(0,r.jsx)(h.Z,{menu:{items:j,style:{width:"280px",padding:"4px",marginTop:"4px"}},trigger:["click"],placement:"bottomLeft",children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-700 hover:text-gray-900 transition-colors",children:[o?o.organization_alias:"Default Organization",(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"})})]})}),(0,r.jsx)("span",{className:"ml-2 text-[10px] bg-blue-100 text-blue-800 font-medium px-2 py-0.5 rounded",children:"BETA"})]}),(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)(h.Z,{menu:{items:g,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"})})]})})]})]})})})},p=s(19250);let g=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO,l):await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),f=s(67101),y=s(20831),Z=s(26637),_=s(87452),b=s(88829),v=s(72208),w=s(84264),S=s(96761),N=s(29233),k=s(41326),I=s(13634),C=s(41021),A=s(51369),P=s(8104),O=s(20577),E=s(56632),T=s(73002);let D=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,p.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},L=(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 F=s(15424),R=s(75957);let{Option:z}=k.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)=>L(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,p.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:i,data:o,setData:d}=e,[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,D]=(0,n.useState)(null),[L,B]=(0,n.useState)([]),[K,W]=(0,n.useState)([]),[H,G]=(0,n.useState)("you"),[Y,J]=(0,n.useState)(U(o)),[$,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(s),el=()=>{u(!1),c.resetFields()},es=()=>{u(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{l&&a&&i&&q(l,a,i,B)},[i,l,a]),(0,n.useEffect)(()=>{(async()=>{try{let e=(await (0,p.t3)(i)).guardrails.map(e=>e.guardrail_name);X(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[i]);let et=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",n=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===n).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(n,", please provide another key alias"));if(C.ZP.info("Making API Call"),u(!0),"you"===H&&(e.user_id=l),"service_account"===H){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,p.wX)(i,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),x(m.key),D(m.soft_budget),C.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),C.ZP.error("Error creating the key: ".concat(e))}};return(0,n.useEffect)(()=>{W(V(Q,L)),c.setFieldValue("models",[])},[Q,L]),(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(A.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:el,onCancel:es,children:(0,r.jsxs)(I.Z,{form:c,onFinish:et,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(P.ZP.Group,{onChange:e=>G(e.target.value),value:H,children:[(0,r.jsx)(P.ZP,{value:"you",children:"You"}),(0,r.jsx)(P.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(P.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==H,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===H,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)(I.Z.Item,{label:"you"===H||"another_user"===H?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===H?"key name":"service account ID")}],help:"you"===H?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(k.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{c.setFieldValue("team_id",e),ee((null==t?void 0:t.find(l=>l.team_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==t?void 0:t.map(e=>(0,r.jsxs)(k.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))})}),(0,r.jsx)(I.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)(k.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"),K.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)(b.Z,{children:[(0,r.jsx)(I.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)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.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)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:$.map(e=>({value:e,label:e}))})}),(0,r.jsx)(I.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)(I.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:Y})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(A.Z,{visible:m,onOk:el,onCancel:es,footer:null,children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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:()=>{C.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(w.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=s(21626),H=s(97214),G=s(28241),Y=s(58834),J=s(69552),$=s(71876),X=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,i]=(0,n.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,n.useState)(!0),[c,m]=(0,n.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!s||!t){console.log("currentOrg",s),console.log("accessToken",t);return}d(!0);let a=await (0,p.OD)(t,s.organization_id,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),i(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,n.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}},Q=s(71594),ee=s(24525);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:i=!1}=e,o=(0,Q.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,ee.sC)(),getExpandedRowModel:(0,ee.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(W.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(Y.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)($.Z,{children:e.headers.map(e=>(0,r.jsx)(J.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,Q.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(H.Z,{children:i?(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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)(n.Fragment,{children:[(0,r.jsx)($.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)(G.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,Q.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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),en=s(12485),ei=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:i,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=I.Z.useForm(),[h,x]=(0,n.useState)([]),g=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,n.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,p.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let j={...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)(I.Z,{form:u,onFinish:i,initialValues:j,layout:"vertical",children:[(0,r.jsx)(I.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[g.length>0&&(0,r.jsx)(k.default.Option,{value:"all-team-models",children:"All Team Models"}),g.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(k.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(k.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(I.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(I.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)(y.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a,onSuccess:i}=e,[o]=I.Z.useForm(),[d,c]=(0,n.useState)(null),[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(null);(0,n.useEffect)(()=>{s&&l&&o.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,o]),(0,n.useEffect)(()=>{(null==m?void 0:m.duration)?x((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}})(m.duration)):x(null)},[null==m?void 0:m.duration]);let g=async()=>{if(l&&a)try{let e=await o.validateFields(),s=await (0,p.s0)(a,l.token,e);c(s.key),i&&i({...l,key_name:s.key_name,...e}),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}},_=()=>{c(null),o.resetFields(),t()};return(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:s,onCancel:_,footer:d?[(0,r.jsx)(y.Z,{onClick:_,children:"Close"},"close")]:[(0,r.jsx)(y.Z,{onClick:_,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:g,children:"Regenerate"},"regenerate")],children:d?(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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)(w.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:d})}),(0,r.jsx)(N.CopyToClipboard,{text:d,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(I.Z,{form:o,layout:"vertical",onValuesChange:e=>{"duration"in e&&u(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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"]}),h&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",h]})]})})}function eg(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:i,userRole:o,teams:d}=e,[c,m]=(0,n.useState)(!1),[u]=I.Z.useForm(),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:"Key not found"})]});let Z=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),C.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,p.Nc)(a,e),C.ZP.success("Key updated successfully"),m(!1)}catch(e){C.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},_=async()=>{try{if(!a)return;await (0,p.I1)(a,t.token),C.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),C.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)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(S.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(y.Z,{icon:eu.Z,variant:"secondary",onClick:()=>j(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(y.Z,{icon:eh.Z,variant:"secondary",onClick:()=>x(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:g,onClose:()=>j(!1),accessToken:a,onSuccess:e=>{j(!1)}}),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)(y.Z,{onClick:_,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>x(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(w.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(w.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)(S.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(y.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:Z,teams:d,accessToken:a,userID:i,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(w.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(w.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(w.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(w.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(w.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(w.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)})]})]})]})})]})]})]})}let ej=e=>{let{teams:l,selectedTeam:s,setSelectedTeam:t}=e;return(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-600",children:"Where Team is"}),(0,r.jsxs)(es.Z,{value:(null==s?void 0:s.team_id)||"",onValueChange:e=>{t((null==l?void 0:l.find(l=>l.team_id===e))||null)},placeholder:"Team ID",className:"w-[400px]",children:[(0,r.jsx)(et.Z,{value:"team_id",children:"Team ID"}),null==l?void 0:l.map(e=>(0,r.jsxs)(et.Z,{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))]})]})})};function ef(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:i=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h}=e,[x,p]=(0,n.useState)(null),g=[{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)(y.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.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Organization",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{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:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{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:x?(0,r.jsx)(eg,{keyId:x,onClose:()=>p(null),keyData:l.find(e=>e.token===x),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",children:[(0,r.jsx)(ej,{teams:o,selectedTeam:d,setSelectedTeam:c}),(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)*i+1," - ").concat(Math.min(t.currentPage*i,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:g.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ey=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:i,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u}=e,[h,x]=(0,n.useState)(!1),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),[k,P]=(0,n.useState)(null),[E,T]=(0,n.useState)(null),[M,L]=(0,n.useState)((null==a?void 0:a.team_id)||""),[F,R]=(0,n.useState)("");(0,n.useEffect)(()=>{L((null==a?void 0:a.team_id)||"")},[a]),(0,n.useMemo)(()=>{let e={};return M&&(e.team_id=M),F&&(e.key_alias=F),e},[M,F]);let{keys:z,isLoading:U,error:V,pagination:q,refresh:B}=X({selectedTeam:a,currentOrg:u,accessToken:t}),[W,H]=(0,n.useState)(!1),[G,Y]=(0,n.useState)(!1),[J,$]=(0,n.useState)(null),[Q,ee]=(0,n.useState)([]),el=new Set,[es,et]=(0,n.useState)(!1),[ea,er]=(0,n.useState)(!1),[en,ei]=(0,n.useState)(null),[eo,ed]=(0,n.useState)(null),[ec]=I.Z.useForm(),[em,eu]=(0,n.useState)(null),[eh,ex]=(0,n.useState)(el),[ep,eg]=(0,n.useState)([]);(0,n.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",J),(null==eo?void 0:eo.duration)?eu((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}})(eo.duration)):eu(null),console.log("calculateNewExpiryTime:",em)},[J,null==eo?void 0:eo.duration]),(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await D(l,s,t);e&&ee(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ex(e)}},[c]);let ej=async()=>{if(null!=b&&null!=o){try{await (0,p.I1)(t,b);let e=o.filter(e=>e.token!==b);d(e)}catch(e){console.error("Error deleting the key:",e)}_(!1),v(null)}},ey=(e,l)=>{ed(s=>({...s,[e]:l}))},eZ=async()=>{if(!m){C.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=J)try{let e=await ec.validateFields(),l=await (0,p.s0)(t,J.token,e);if(ei(l.key),o){let s=o.map(s=>s.token===(null==J?void 0:J.token)?{...s,key_name:l.key_name,...e}:s);d(s)}er(!1),ec.resetFields(),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}};return Array.from(new Set(z.map(e=>e.key_alias?e.key_alias:"Not Set"))),(0,r.jsxs)("div",{children:[(0,r.jsx)(ef,{keys:z,isLoading:U,pagination:q,onPageChange:e=>{B({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:i,accessToken:t,userID:l,userRole:s}),g&&(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)(y.Z,{onClick:ej,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{_(!1),v(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:ea,onCancel:()=>{er(!1),ec.resetFields()},footer:[(0,r.jsx)(y.Z,{onClick:()=>{er(!1),ec.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:eZ,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(I.Z,{form:ec,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&ey("duration",e.duration)},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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==J?void 0:J.expires)!=null?new Date(J.expires).toLocaleString():"Never"]}),em&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",em]})]}):(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)(y.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"})})]})}),en&&(0,r.jsx)(A.Z,{visible:!!en,onCancel:()=>ei(null),footer:[(0,r.jsx)(y.Z,{onClick:()=>ei(null),children:"Close"},"close")],children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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==J?void 0:J.key_alias)||"No alias set"})}),(0,r.jsx)(w.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:en})}),(0,r.jsx)(N.CopyToClipboard,{text:en,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eZ=s(12011),e_=s(68060);console.log=function(){},console.log("isLocal:",!1);var eb=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,setOrganizations:x,premiumUser:y,currentOrg:Z}=e;console.log("currentOrg in user dashboard: ".concat(JSON.stringify(Z)));let[_,b]=(0,n.useState)(null),v=(0,i.useSearchParams)(),w=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=v.get("invitation_id"),[N,k]=(0,n.useState)(null),[I,C]=(0,n.useState)(null),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(w){let e=(0,o.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),k(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&&N&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);if(e)P(JSON.parse(e));else{console.log("currentOrg: ".concat(JSON.stringify(Z)));let e=async()=>{x(await (0,p.r6)(N))};(async()=>{try{let e=await (0,p.g)(N);E(e);let t=await (0,p.Br)(N,l,s,!1,null,null);b(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,p.So)(N,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),P(a),console.log("userModels:",A),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),g(N,l,s,Z,u),e()}}},[l,w,N,a,s]),(0,n.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(Z),", accessToken: ").concat(N,", userID: ").concat(l,", userRole: ").concat(s)),N&&(console.log("fetching teams"),g(N,l,s,Z,u))},[Z]),(0,n.useEffect)(()=>{if(null!==a&&null!=T&&null!==T.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))T.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===T.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),C(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;C(e)}},[T]),null!=S)return(0,r.jsx)(eZ.default,{});if(null==l||null==w){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==N)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=e_.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",T),(0,r.jsx)("div",{className:"w-full mx-4 overflow-hidden h-[75vh]",children:(0,r.jsx)(f.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:T,teams:t,userRole:s,accessToken:N,data:a,setData:h},T?T.team_id:null),(0,r.jsx)(ey,{userID:l,userRole:s,accessToken:N,selectedTeam:T||null,setSelectedTeam:D,data:a,setData:h,premiumUser:y,teams:t,currentOrg:Z})]})})})},ev=s(97765),ew=s(47451),eS=s(69410),eN=()=>{let e=I.Z.useFormInstance();return(I.Z.useWatch("model",e)||[]).includes("all-wildcard")?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!1,className:"mb-0",rules:[e=>{let{getFieldValue:l}=e;return{validator:(e,s)=>!(l("model")||[]).includes("all-wildcard")||s?Promise.resolve():Promise.reject(Error('Public Model Name is required unless "All Models" is selected.'))}}],children:(0,r.jsx)(Z.Z,{placeholder:"my-gpt-4"})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})};(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 ek={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"},eI={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"},eC=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(ek).find(l=>ek[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eI[s],displayName:s}},eA=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",eP=(e,l)=>{console.log("Provider key: ".concat(e));let s=ek[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};var eO=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,n=I.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(I.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)(I.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.toString())}):s.length>0?(0,r.jsx)(k.default,{allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{e.includes("all-wildcard")&&n.setFieldsValue({model_name:void 0})},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.toString())})}),(0,r.jsx)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},eE=s(63709),eT=s(90464);let{Link:eD}=e_.default;var eM=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s}=e,[t]=I.Z.useForm(),[a,i]=n.useState(!1),[o,d]=n.useState("per_token"),c=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),m=(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)(b.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(I.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(eE.Z,{onChange:e=>{i(e),e||t.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),a&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(I.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:"per_token",onChange:e=>d(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(I.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(I.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)(eD,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(eE.Z,{onChange:e=>{let l=t.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?t.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):t.setFieldValue("litellm_extra_params","")}catch(l){e?t.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):t.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(ew.Z,{className:"mb-4",children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(eD,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})},eL=s(18502),eF=s(3632);let{Link:eR}=e_.default;var ez=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)(I.Z.Item,{label:"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)(I.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)(I.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(eL.Z,{...s,children:(0,r.jsx)(T.ZP,{icon:(0,r.jsx)(eF.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(k.default,{placeholder:"Select API Base",children:[(0,r.jsx)(k.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(k.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(I.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)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(eR,{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)(I.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)(I.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)(I.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)(I.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"})})]})};let eU=async(e,l,s,t)=>{try{if(console.log("handling submit for formValues:",e),e.model&&e.model.includes("all-wildcard")){let l=ek[e.custom_llm_provider]+"/*";e.model_name=l,e.model=l}let a=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(a)),console.log("received type of deployments: ".concat(typeof a)),a.forEach(async s=>{console.log("litellm_model: ".concat(s));let a={},r={};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),a.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=ek[s];a.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)r[l]=s;else if("custom_model_name"===l)a.model=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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))r[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){s&&(a[l]=Number(s));continue}else a[l]=s}let i={model_name:n,litellm_params:a,model_info:r},o=await (0,p.kK)(l,i);t&&t(),console.log("response for model create call: ".concat(o.data))}),s.resetFields()}catch(e){C.ZP.error("Failed to create model: "+e,10)}};var eV=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[n]=I.Z.useForm(),i={},o="",d="";if(t){var c,m;i={...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)),i.model_id=d)}return(0,r.jsx)(A.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{n.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}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(I.Z,{form:n,onFinish:a,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},eq=s(53003),eB=s(47323),eK=s(75105),eW=s(40278),eH=s(14301),eG=s(15731),eY=s(53410),eJ=s(2356),e$=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,i]=(0,n.useState)(!1),o=async()=>{try{C.ZP.info("Making API Call"),i(!0);let e=await (0,p.Og)(s,l);console.log("model delete Response:",e),C.ZP.success("Model ".concat(l," deleted successfully")),i(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eB.Z,{onClick:()=>i(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(A.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>i(!1),children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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})]})})]})})]})},eX=s(94789),eQ=s(59664),e0=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eQ.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)(eX.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)(y.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},e1=s(17906);let{Title:e2,Link:e4}=e_.default,e5={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var e3=e=>{let{accessToken:l,token:s,userRole:t,userID:i,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m}=e,[u,h]=(0,n.useState)([]),[x]=I.Z.useForm(),[g,j]=(0,n.useState)(null),[Z,_]=(0,n.useState)(""),[b,v]=(0,n.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[N,P]=(0,n.useState)([]),[E,D]=(0,n.useState)(a.OpenAI),[M,L]=(0,n.useState)(""),[F,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(null),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)([]),[el,em]=(0,n.useState)(null),[eh,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)([]),[ej,ef]=(0,n.useState)([]),[ey,eZ]=(0,n.useState)([]),[eb,ew]=(0,n.useState)([]),[eE,eT]=(0,n.useState)([]),[eD,eL]=(0,n.useState)([]),[eF,eR]=(0,n.useState)([]),[eX,eQ]=(0,n.useState)([]),[e4,e3]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e8,e6]=(0,n.useState)(null),[e7,e9]=(0,n.useState)(0),[le,ll]=(0,n.useState)({}),[ls,lt]=(0,n.useState)([]),[la,lr]=(0,n.useState)(!1),[ln,li]=(0,n.useState)(null),[lo,ld]=(0,n.useState)(null),[lc,lm]=(0,n.useState)([]),[lu,lh]=(0,n.useState)(!1),lx=e=>{let l=eP(e,g);v(l),console.log("providerModels: ".concat(l))},lp=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!i||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),em(e);let r=null==ln?void 0:ln.token;void 0===r&&(r=null);let n=lo;void 0===n&&(n=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,p.o6)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model metrics response:",o),eg(o.data),ef(o.all_api_bases);let d=await (0,p.Rg)(l,e,s.toISOString(),a.toISOString());eZ(d.data),ew(d.all_api_bases);let c=await (0,p.N8)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model exceptions response:",c),eT(c.data),eL(c.exception_types);let m=await (0,p.fP)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);if(console.log("slowResponses:",m),eQ(m),e){let t=await (0,p.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);ll(t);let r=await (0,p.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);lt(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,n.useEffect)(()=>{lp(el,e4.from,e4.to)},[ln,lo]);let lg=e=>{B(e),z(!0)},lj=e=>{B(e),V(!0)},lf=async e=>{if(console.log("handleEditSubmit:",e),null==l)return;let s={},t=null;for(let[l,a]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?s[l]=""===a?null:a:t=""===a?null:a;let a={litellm_params:Object.keys(s).length>0?s:void 0,model_info:void 0!==t?{id:t}:void 0};console.log("handleEditSubmit payload:",a);try{await (0,p.um)(l,a),C.ZP.success("Model updated successfully, restart server to see updates"),z(!1),B(null)}catch(e){console.log("Error occurred")}},ly=()=>{_(new Date().toLocaleString())},lZ=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e8);try{await (0,p.K_)(l,{router_settings:{model_group_retry_policy:e8}}),C.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),C.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!l||!s||!t||!i)return;let e=async()=>{try{var e,s,a,r,n,o,d,m,u,h,x,g;let j=await (0,p.hy)(l);P(j);let f=await (0,p.AZ)(l,i,t);console.log("Model data response:",f.data),c(f);let y=new Set;for(let e=0;e0&&(_=Z[Z.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",el);let b=await (0,p.o6)(l,i,t,_,null===(e=e4.from)||void 0===e?void 0:e.toISOString(),null===(s=e4.to)||void 0===s?void 0:s.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model metrics response:",b),eg(b.data),ef(b.all_api_bases);let v=await (0,p.Rg)(l,_,null===(a=e4.from)||void 0===a?void 0:a.toISOString(),null===(r=e4.to)||void 0===r?void 0:r.toISOString());eZ(v.data),ew(v.all_api_bases);let w=await (0,p.N8)(l,i,t,_,null===(n=e4.from)||void 0===n?void 0:n.toISOString(),null===(o=e4.to)||void 0===o?void 0:o.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model exceptions response:",w),eT(w.data),eL(w.exception_types);let S=await (0,p.fP)(l,i,t,_,null===(d=e4.from)||void 0===d?void 0:d.toISOString(),null===(m=e4.to)||void 0===m?void 0:m.toISOString(),null==ln?void 0:ln.token,lo),N=await (0,p.n$)(l,null===(u=e4.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=e4.to)||void 0===h?void 0:h.toISOString().split("T")[0],_);ll(N);let k=await (0,p.v9)(l,null===(x=e4.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(g=e4.to)||void 0===g?void 0:g.toISOString().split("T")[0],_);lt(k),console.log("dailyExceptions:",N),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",S),eQ(S);let I=await (0,p.j2)(l);lm(null==I?void 0:I.end_users);let C=(await (0,p.BL)(l,i,t)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,O=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",O),e6(A),e9(O)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&i&&e();let a=async()=>{let e=await (0,p.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),j(e)};null==g&&a(),ly()},[l,s,t,i,g,Z]),!o||!l||!s||!t||!i)return(0,r.jsx)("div",{children:"Loading..."});let l_=[],lb=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(g)),null!=g&&"object"==typeof g&&e in g)?g[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&&(n=null==a?void 0:a.input_cost_per_token,i=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=n,o.data[e].output_cost=i,o.data[e].litellm_model_name=s,lb.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===(lS=l.litellm_params)||void 0===lS?void 0:lS.api_base,o.data[e].cleanedLitellmParams=m,l_.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}=e_.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 lN=async()=>{try{C.ZP.info("Running health check..."),L("");let e=await (0,p.EY)(l);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lk=(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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:()=>{li(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:()=>{li(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{ld(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:()=>{li(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:()=>{li(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lI=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let n=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.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:[n&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),i.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(b.length));let lC=Object.keys(a).find(e=>a[e]===E);return lC&&N.find(e=>e.name===ek[lC]),(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,r.jsxs)(ei.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)(en.Z,{children:"All Models"}),(0,r.jsx)(en.Z,{children:"Add Model"}),(0,r.jsx)(en.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(en.Z,{children:"Model Analytics"}),(0,r.jsx)(en.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[Z&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",Z]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ly})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||void 0,onValueChange:e=>em("all"===e?"all":e),value:el||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(J.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(J.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)(J.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)(J.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)(J.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)(J.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:o.data.filter(e=>"all"===el||e.model_name===el||null==el||""===el).map((e,s)=>{var a;return(0,r.jsxs)($.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)(G.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,r.jsx)(G.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:eC(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)(G.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)(G.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)(G.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)(G.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)(G.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)(G.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)(G.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)(G.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(f.Z,{numItems:3,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eG.Z,size:"sm",onClick:()=>lj(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>lg(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(e$,{modelID:e.model_info.id,accessToken:l,callback:ly})})]})})]},s)})})]})})]}),(0,r.jsx)(eV,{visible:F,onCancel:()=>{z(!1),B(null)},model:q,onSubmit:lf}),(0,r.jsxs)(A.Z,{title:q&&q.model_name,visible:U,width:800,footer:null,onCancel:()=>{V(!1),B(null)},children:[(0,r.jsx)(S.Z,{children:"Model Info"}),(0,r.jsx)(e1.Z,{language:"json",children:q&&JSON.stringify(q,null,2)})]})]}),(0,r.jsxs)(ed.Z,{className:"h-full",children:[(0,r.jsx)(e2,{level:2,children:"Add new model"}),(0,r.jsx)(er.Z,{children:(0,r.jsx)(I.Z,{form:x,onFinish:()=>{x.validateFields().then(e=>{eU(e,l,x,ly)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(k.default,{showSearch:!0,value:E,onChange:e=>{D(e),lx(e),x.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(k.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eI[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)(eO,{selectedProvider:E,providerModels:b,getPlaceholder:eA}),(0,r.jsx)(eN,{}),(0,r.jsx)(ez,{selectedProvider:E,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;x.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?C.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&C.ZP.error("".concat(e.file.name," file upload failed."))}}}),(0,r.jsx)(eM,{showAdvancedSettings:lu,setShowAdvancedSettings:lh}),(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)(e_.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(y.Z,{onClick:lN,children:"Run `/health`"}),M&&(0,r.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:e4,className:"mr-2",onValueChange:e=>{e3(e),lp(el,e.from,e.to)}})]}),(0,r.jsxs)(eS.Z,{className:"ml-2",children:[(0,r.jsx)(w.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:el||K[0],value:el||K[0],children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lp(e,e4.from,e4.to),children:e},l))})]}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eH.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,r.jsx)(y.Z,{icon:eJ.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(en.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)(w.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ep&&ej&&(0,r.jsx)(eK.Z,{title:"Model Latency",className:"h-72",data:ep,showLegend:!1,index:"date",categories:ej,connectNulls:!0,customTooltip:lI})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e0,{modelMetrics:ey,modelMetricsCategories:eb,customTooltip:lI,premiumUser:m})})]})]})})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Deployment"}),(0,r.jsx)(J.Z,{children:"Success Responses"}),(0,r.jsxs)(J.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(H.Z,{children:eX.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.api_base}),(0,r.jsx)(G.Z,{children:e.total_count}),(0,r.jsx)(G.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Exceptions for ",el]}),(0,r.jsx)(eW.Z,{className:"h-60",data:eE,index:"model",categories:eD,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Up Rate Limit Errors (429) for ",el]}),(0,r.jsxs)(f.Z,{numItems:1,children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",le.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.Z,{className:"h-40",data:le.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eS.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:ls.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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:ls&&ls.length>0&&ls.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.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)(y.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)(S.Z,{children:e.api_base}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||K[0],value:el||K[0],onValueChange:e=>em(e),children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))})]}),(0,r.jsxs)(S.Z,{children:["Retry Policy for ",el]}),(0,r.jsx)(w.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),e5&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(e5).map((e,l)=>{var s;let[t,a]=e,n=null==e8?void 0:null===(s=e8[el])||void 0===s?void 0:s[a];return null==n&&(n=e7),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(O.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{e6(l=>{var s;let t=null!==(s=null==l?void 0:l[el])&&void 0!==s?s:{};return{...null!=l?l:{},[el]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(y.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})};function e8(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:n,Paragraph:i}=e_.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)(A.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(i,{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)(w.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(w.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)(w.Z,{children:"Invitation Link"}),(0,r.jsx)(w.Z,{children:(0,r.jsx)(w.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>C.ZP.success("Copied!"),children:(0,r.jsx)(y.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:e6}=k.default;var e7=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,n.useState)(null),[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)([]),[f,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),S=(0,i.useRouter)(),[N,P]=(0,n.useState)("http://localhost:4000");(0,n.useEffect)(()=>{(async()=>{try{let e=await (0,p.So)(s,l,"any"),t=[];for(let l=0;l{S&&P(new URL("/",window.location.href).toString())},[S]);let O=async e=>{try{var t;C.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,p.Ov)(s,null,e);console.log("user create Response:",a),x(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};v(e),_(!0)}else(0,p.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,v(e),_(!0)});C.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)(y.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(A.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),x(null),c.resetFields()},children:[(0,r.jsx)(w.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(I.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(k.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(e6,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(e6,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(I.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)(T.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(e8,{isInvitationLinkModalVisible:f,setIsInvitationLinkModalVisible:_,baseUrl:N,invitationLinkData:b})]})},e9=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,n.useState)(a),[c]=I.Z.useForm();(0,n.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,r.jsx)(A.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(I.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)(I.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)(I.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var le=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(1),[_,b]=n.useState(null),[v,w]=(0,n.useState)(null),[S,N]=(0,n.useState)(!1),[k,I]=(0,n.useState)(null),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{E(e),P(!0)},L=async()=>{if(O&&l)try{if(await (0,p.Eb)(l,[O]),C.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==O);h(e)}}catch(e){console.error("Error deleting user:",e),C.ZP.error("Failed to delete user")}P(!1),E(null)},F=async()=>{I(null),N(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,p.pf)(l,e,null),C.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)),I(null),N(!1)}};return((0,n.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(j));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,p.Br)(l,null,a,!0,j,25);sessionStorage.setItem("userList_".concat(j),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,p.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),D(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&i&&e()},[l,s,a,i,j]),u&&l&&s&&a&&i)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(f.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(e7,{userID:i,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)(ei.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(W.Z,{className:"mt-5",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(J.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(J.Z,{children:"API Keys"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.user_id||"-"}),(0,r.jsx)(G.Z,{children:e.user_email||"-"}),(0,r.jsx)(G.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)(G.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)(G.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(f.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)(G.Z,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,onClick:()=>{I(e),N(!0)},children:"View Keys"}),(0,r.jsx)(eB.Z,{icon:eh.Z,onClick:()=>M(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)(e9,{visible:S,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: ",O]})]})]})})}),(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{P(!1),E(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),Z(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",j," 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===j,onClick:()=>l(j-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:j===e,onClick:()=>l(j+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},ll=e=>{var l,s,t;let{visible:a,onCancel:i,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=I.Z.useForm();console.log("Initial Data:",d),(0,n.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(),C.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){C.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)(k.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(A.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:i,children:(0,r.jsxs)(I.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(I.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)(w.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(I.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)(I.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)(k.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)(k.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(k.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)(I.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)(T.ZP,{onClick:i,className:"mr-2",children:"Cancel"}),(0,r.jsx)(T.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},ls=s(7310),lt=s.n(ls),la=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:i="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]=I.Z.useForm(),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}x(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,p.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{x(!1)}},y=(0,n.useCallback)(lt()((e,l)=>f(e,l),300),[]),Z=(e,l)=>{j(l),y(e,l)},_=(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)(A.Z,{title:i,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(I.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(I.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>Z(e,"user_email"),onSelect:(e,l)=>_(e,l),options:"user_email"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>Z(e,"user_id"),onSelect:(e,l)=>_(e,l),options:"user_id"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(I.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(k.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)(T.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},lr=e=>{let{teamId:l,accessToken:s,currentAliases:t,availableModels:a,onUpdate:i}=e,[o,d]=(0,n.useState)(!1),[c]=I.Z.useForm(),m=async e=>{try{if(!s)return;let a={...t,[e.alias_name]:e.original_model};await (0,p.Gh)(s,{team_id:l,model_aliases:a}),C.ZP.success("Model alias created successfully"),d(!1),c.resetFields(),t[e.alias_name]=e.original_model}catch(e){C.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)(S.Z,{children:"Team Aliases"}),(0,r.jsx)(w.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)(y.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)(A.Z,{title:"Create Model Alias",open:o,onCancel:()=>{d(!1),c.resetFields()},footer:null,width:500,children:(0,r.jsxs)(I.Z,{form:c,onFinish:m,layout:"vertical",className:"mt-4",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Points To",name:"original_model",rules:[{required:!0,message:"Please select a model"}],children:(0,r.jsx)(k.default,{placeholder:"Select model version",className:"w-full font-mono",showSearch:!0,optionFilterProp:"children",children:a.map(e=>(0,r.jsx)(k.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)(y.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)(y.Z,{size:"md",variant:"secondary",type:"submit",children:"Create Alias"})]})]})})]})},ln=e=>{var l,s,t;let{teamId:a,onClose:i,accessToken:o,is_team_admin:d,is_proxy_admin:c,userModels:m,editTeam:u}=e,[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)(!0),[Z,_]=(0,n.useState)(!1),[b]=I.Z.useForm(),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),[D,L]=(0,n.useState)(!1);console.log("userModels in team info",m);let z=d||c,U=async()=>{try{if(j(!0),!o)return;let e=await (0,p.Xm)(o,a);x(e)}catch(e){C.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{j(!1)}};(0,n.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,p.cu)(o,a,l),C.ZP.success("Team member added successfully"),_(!1),b.resetFields(),U()}catch(e){C.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,p.sN)(o,a,l),C.ZP.success("Team member updated successfully"),N(!1),U()}catch(e){C.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},B=async e=>{try{if(null==o)return;await (0,p.Lp)(o,a,e),C.ZP.success("Team member removed successfully"),U()}catch(e){C.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,p.Gh)(o,s),C.ZP.success("Team settings updated successfully"),L(!1),U()}catch(e){C.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(g)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:X}=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)(T.ZP,{onClick:i,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:X.team_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:X.team_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:u?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",X.spend.toFixed(6)]}),(0,r.jsxs)(w.Z,{children:["of ",null===X.max_budget?"Unlimited":"$".concat(X.max_budget)]}),X.budget_duration&&(0,r.jsxs)(w.Z,{className:"text-gray-500",children:["Reset: ",X.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",X.rpm_limit||"Unlimited"]}),X.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",X.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:X.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:h.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)(G.Z,{children:z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P(e),N(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>B(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(y.Z,{onClick:()=>_(!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)(S.Z,{children:"Team Settings"}),z&&!D&&(0,r.jsx)(y.Z,{onClick:()=>L(!0),children:"Edit Settings"})]}),D?(0,r.jsxs)(I.Z,{form:b,onFinish:K,initialValues:{...X,team_alias:X.team_alias,models:X.models,tpm_limit:X.tpm_limit,rpm_limit:X.rpm_limit,max_budget:X.max_budget,budget_duration:X.budget_duration,guardrails:(null===(l=X.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),m.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>L(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:X.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:X.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(X.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:X.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",X.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==X.max_budget?"$".concat(X.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",X.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:X.blocked?"red":"green",children:X.blocked?"Blocked":"Active"})]})]})]}),(0,r.jsx)(lr,{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)(ll,{visible:v,onCancel:()=>N(!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)(la,{isVisible:Z,onCancel:()=>_(!1),onSubmit:V,accessToken:o})]})},li=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,p.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let i=async e=>{if(l&&s)try{await (0,p.cu)(l,e,{user_id:s,role:"user"}),C.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),C.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Description"}),(0,r.jsx)(J.Z,{children:"Members"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsxs)(H.Z,{children:[t.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.team_alias})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.description||"No description available"})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{size:"xs",variant:"secondary",onClick:()=>i(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(w.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};var lo=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o,currentOrg:d}=e,[c,m]=(0,n.useState)("");(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&g(t,i,o,d,a)},[l]),(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&g(t,i,o,d,a),ek()},[c]);let[u]=I.Z.useForm(),[h]=I.Z.useForm(),{Title:x,Paragraph:S}=e_.default,[N,P]=(0,n.useState)(""),[E,L]=(0,n.useState)(!1),[z,U]=(0,n.useState)(null),[V,q]=(0,n.useState)(null),[B,K]=(0,n.useState)(!1),[X,Q]=(0,n.useState)(!1),[ee,el]=(0,n.useState)(!1),[es,et]=(0,n.useState)(!1),[em,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)(!1),[ej,ef]=(0,n.useState)(null),[ey,eZ]=(0,n.useState)({}),[eb,ev]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,p.t3)(t)).guardrails.map(e=>e.guardrail_name);ev(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let ew=async e=>{ef(e),eg(!0)},eS=async()=>{if(null!=ej&&null!=l&&null!=t){try{await (0,p.rs)(t,ej);let e=l.filter(e=>e.team_id!==ej);a(e)}catch(e){console.error("Error deleting the team:",e)}eg(!1),ef(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{let e;if(null===i||null===o||null===t||null===l)return;let s={};e="Admin"!=o&&"Admin Viewer"!=o?await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO,i):await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO);for(let l=0;l{try{if(null===i||null===o||null===t)return;let e=await D(i,o,t);e&&ex(e)}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eN=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,n=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=(null==e?void 0:e.organization_id)||(null==d?void 0:d.organization_id);if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,n.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));C.ZP.info("Creating Team");let o=await (0,p.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),C.ZP.success("Team created"),Q(!1)}}catch(e){console.error("Error creating the team:",e),C.ZP.error("Error creating the team: "+e,20)}},ek=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4",children:V?(0,r.jsx)(ln,{teamId:V,onClose:()=>{q(null),K(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===V)),is_proxy_admin:"Admin"==o,userModels:em,editTeam:B}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Teams"}),(0,r.jsx)(en.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ek})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(w.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(f.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-y-auto max-h-[50vh]",children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Team ID"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"})]})}),(0,r.jsx)(H.Z,{children:l&&l.length>0?l.filter(e=>{let l=d?d.organization_id:null;return e.organization_id===l}).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(y.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:()=>{q(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)(G.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)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(w.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,r.jsxs)(w.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,r.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,r.jsxs)(G.Z,{children:[(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].keys&&ey[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].members_with_roles&&ey[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)(G.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{q(e.team_id),K(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>ew(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),ep&&(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)(y.Z,{onClick:eS,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{eg(!1),ef(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>Q(!0),children:"+ Create New Team"}),(0,r.jsx)(A.Z,{title:"Create Team",visible:X,width:800,footer:null,onOk:()=>{Q(!1),u.resetFields()},onCancel:()=>{Q(!1),u.resetFields()},children:(0,r.jsxs)(I.Z,{form:u,onFinish:eN,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),em.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,r.jsx)(Z.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eb.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(li,{accessToken:t,userID:i})})]})]})})},ld=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:i,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(!0),[g]=I.Z.useForm(),[j,Z]=(0,n.useState)(!1),[_,b]=(0,n.useState)(!1),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),D=i||o,L=async()=>{try{if(x(!0),!a)return;let e=await (0,p.t$)(a,s);u(e)}catch(e){C.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{x(!1)}};(0,n.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,p.vh)(a,s,l),C.ZP.success("Organization member added successfully"),b(!1),g.resetFields(),L()}catch(e){C.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,p.LY)(a,s,l),C.ZP.success("Organization member updated successfully"),N(!1),g.resetFields(),L()}catch(e){C.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,p.Sb)(a,s,e.user_id),C.ZP.success("Organization member deleted successfully"),N(!1),g.resetFields(),L()}catch(e){C.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");C.ZP.success("Organization settings updated successfully"),Z(!1),L()}catch(e){C.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)(T.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:m.organization_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(w.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)(w.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Created At"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)(G.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),N(!0)}}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(y.Z,{onClick:()=>{b(!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)(S.Z,{children:"Organization Settings"}),D&&!j&&(0,r.jsx)(y.Z,{onClick:()=>Z(!0),children:"Edit Settings"})]}),j?(0,r.jsxs)(I.Z,{form:g,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)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>Z(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.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)(w.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)(w.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)(w.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)(la,{isVisible:_,onCancel:()=>b(!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)(ll,{visible:v,onCancel:()=>N(!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 lc=async(e,l)=>{l(await (0,p.r6)(e))};var lm=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:i,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,x]=(0,n.useState)(null),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(null),[P,E]=(0,n.useState)(!1),[T]=I.Z.useForm();(0,n.useEffect)(()=>{0===l.length&&a&&lc(a,m)},[l,a]);let D=e=>{e&&(N(e),v(!0))},L=async()=>{if(S&&a)try{await (0,p.cq)(a,S),C.ZP.success("Organization deleted successfully"),v(!1),N(null),lc(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,p.H1)(a,e),E(!1),T.resetFields(),lc(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(ld,{organizationId:h,onClose:()=>{x(null),_(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:g}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[i&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",i]}),(0,r.jsx)(eB.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)(w.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(f.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Organization ID"}),(0,r.jsx)(J.Z,{children:"Organization Name"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsx)(H.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,n,i,o,d,c,m;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(y.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:()=>x(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)(G.Z,{children:e.organization_alias}),(0,r.jsx)(G.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{children:e.spend}),(0,r.jsx)(G.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===(n=e.litellm_budget_table)||void 0===n?void 0:n.max_budget:"No limit"}),(0,r.jsx)(G.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["TPM: ",(null===(i=e.litellm_budget_table)||void 0===i?void 0:i.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)(G.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{x(e.organization_id),_(!0)}}),(0,r.jsx)(eB.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)(y.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Organization"}),(0,r.jsx)(A.Z,{title:"Create Organization",visible:P,width:800,footer:null,onCancel:()=>{E(!1),T.resetFields()},children:(0,r.jsxs)(I.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(y.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),b?(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{v(!1),N(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(w.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 lu=()=>{let[e,l]=(0,n.useState)("http://localhost:4000");return(0,n.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lh=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=I.Z.useForm(),[d]=I.Z.useForm(),{Title:c,Paragraph:m}=e_.default,[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(!1),[v,S]=(0,n.useState)(!1),[N,k]=(0,n.useState)(!1),[P,O]=(0,n.useState)(!1),[D,M]=(0,n.useState)(!1),[L,F]=(0,n.useState)(!1),[R,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(!1),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(null);(0,i.useRouter)();let[el,es]=(0,n.useState)(null);console.log=function(){};let et=lu(),ea="All IP Addresses Allowed",en=et;en+="/fallback/login";let ei=async()=>{try{if(!0!==a){C.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,p.PT)(s);X(e&&e.length>0?e:[ea])}else X([ea])}catch(e){console.error("Error fetching allowed IPs:",e),C.ZP.error("Failed to fetch allowed IPs ".concat(e)),X([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,p.eH)(s,e.ip);let l=await (0,p.PT)(s);X(l),C.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),C.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{ee(e),B(!0)},ec=async()=>{if(Q&&s)try{await (0,p.$I)(s,Q);let e=await (0,p.PT)(s);X(e.length>0?e:[ea]),C.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),C.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),ee(null)}},em=()=>{F(!1)};(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,p.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,p.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)),g(e),es(await (0,p.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=x){var l;C.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,p.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,p.XO)(s,a).then(e=>{Z(e),b(!0)}),console.log("response for team create call: ".concat(t));let r=x.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"),x.push(t),g(x)),o.resetFields(),k(!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,p.K_)(s,l)};return console.log("admins: ".concat(null==x?void 0:x.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)(f.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)(y.Z,{onClick:()=>!0===a?M(!0):C.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(y.Z,{onClick:ei,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(A.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{M(!1),o.resetFields()},onCancel:()=>{M(!1),o.resetFields()},children:(0,r.jsxs)(I.Z,{form:o,onFinish:e=>{eu(e),eh(e),M(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.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)(I.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(A.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)(w.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(w.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)(T.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(A.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(y.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"IP Address"}),(0,r.jsx)(J.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(H.Z,{children:K.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e}),(0,r.jsx)(G.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(y.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(A.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(I.Z,{onFinish:eo,children:[(0,r.jsx)(I.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)(I.Z.Item,{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(A.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(y.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",Q,"?"]})})]}),(0,r.jsxs)(eX.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:en,target:"_blank",children:[(0,r.jsx)("b",{children:en})," "]})]})]})]})},lx=s(92858),lp=s(44643),lg=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:n}=e,[i]=I.Z.useForm();return(0,r.jsxs)(I.Z,{form:i,onFinish:()=>{console.log("INSIDE ONFINISH");let e=i.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)($.Z,{children:[(0,r.jsxs)(G.Z,{align:"center",children:[(0,r.jsx)(w.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?n?(0,r.jsx)(I.Z.Item,{name:e.field_name,children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lx.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)(G.Z,{children:(0,r.jsx)(y.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)(I.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lx.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lj=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(0,p.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lg,{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,...n}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(n)));try{(0,p.jA)(l,"alerting_args",n),"boolean"==typeof r&&(!0==r?(0,p.jA)(l,"alerting",["slack"]):(0,p.jA)(l,"alerting",[])),C.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lf=s(86582);let{Title:ly,Paragraph:lZ}=e_.default;console.log=function(){};var l_=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,n.useState)([]),[d,c]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[h]=I.Z.useForm(),[x,g]=(0,n.useState)(null),[j,_]=(0,n.useState)([]),[b,v]=(0,n.useState)(""),[S,N]=(0,n.useState)({}),[P,O]=(0,n.useState)([]),[E,D]=(0,n.useState)(!1),[M,L]=(0,n.useState)([]),[F,R]=(0,n.useState)(null),[z,U]=(0,n.useState)([]),[V,q]=(0,n.useState)(!1),[B,K]=(0,n.useState)(null),X=e=>{P.includes(e)?O(P.filter(l=>l!==e)):O([...P,e])},Q={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,n.useEffect)(()=>{l&&s&&t&&(0,p.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),O(e.active_alerts),v(s),N(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ee=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,p.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.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,p.K_)(l,{environment_variables:s}),C.ZP.success("Callback added successfully"),u(!1),h.resetFields(),g(null)}catch(e){C.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,p.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),C.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),g(null)}catch(e){C.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),g(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(i)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(en.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(en.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(en.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(f.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(J.Z,{children:"Callback Name"})})}),(0,r.jsx)(H.Z,{children:i.map((e,s)=>(0,r.jsxs)($.Z,{className:"flex justify-between",children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.name})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(Q).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)}):(0,r.jsx)(y.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)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:S&&S[s]?S[s]:b})})]},l)})})]}),(0,r.jsx)(y.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(Q).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,p.K_)(l,s)}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lj,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Email Settings"}),(0,r.jsxs)(w.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)(G.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(f.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)(w.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)(w.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)(y.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(A.Z,{title:"Add Logging Callback",visible:E,width:800,onCancel:()=>D(!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)(I.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lf.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(k.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),em(l))},children:M&&Object.values(M).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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(A.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(I.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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lb=s(92414),lv=s(46030);let{Option:lw}=k.default;var lS=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=I.Z.useForm(),[o,d]=(0,n.useState)(!1),[c,m]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(A.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,r.jsxs)(I.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,n=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:n};console.log(o);try{(0,p.K_)(s,{router_settings:o}),a(o)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lb.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lN=s(33619);async function lk(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lN.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});C.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lI={ttl:3600,lowest_latency_buffer:0},lC=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)(b.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(w.Z,{children:"No specific settings"})})]})};var lA=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)({}),[d,c]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g]=I.Z.useForm(),[_,b]=(0,n.useState)(null),[v,N]=(0,n.useState)(null),[k,A]=(0,n.useState)(null),P={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,n.useEffect)(()=>{l&&s&&t&&((0,p.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,p.YU)(l).then(e=>{u(e)}))},[l,s,t]);let E=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks));let s=i.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...i,fallbacks:s};try{await (0,p.K_)(l,{router_settings:t}),o(t),C.ZP.success("Router settings updated successfully")}catch(e){C.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))},D=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,p.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},M=(e,s)=>{if(l)try{(0,p.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,v];if("routing_strategy_args"==l&&"latency-based-routing"==v){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,p.K_)(l,{router_settings:s})}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(ei.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)(en.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(en.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(en.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(S.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(i).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)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,r.jsx)(G.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:N,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)(lC,{selectedStrategy:v,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:lI,paramExplanation:P})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>L(i),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Model Name"}),(0,r.jsx)(J.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(H.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:t}),(0,r.jsx)(G.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{onClick:()=>lk(t,l),children:"Test Fallback"})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lS,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"}),(0,r.jsx)(J.Z,{children:"Status"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.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)(G.Z,{children:"Integer"==e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:[(0,r.jsx)(y.Z,{onClick:()=>D(e.field_name,l),children:"Update"}),(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>M(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lP=s(93142),lO=s(45246),lE=s(96473),lT=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,n.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let n=[...t];n[e]=[l,r],a(n),null==s||s(Object.fromEntries(n))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lP.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)(lO.Z,{onClick:()=>i(l)})]},l)}),(0,r.jsx)(T.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lE.Z,{}),children:"Add Header"})]})};let{Option:lD}=k.default;var lM=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=I.Z.useForm(),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(A.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(I.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,p.Vt)(l,e),s(r)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.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)(I.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)(I.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)(I.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)(lT,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lL=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&s&&t&&(0,p.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,p.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),C.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(ei.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Path"}),(0,r.jsx)(J.Z,{children:"Target"}),(0,r.jsx)(J.Z,{children:"Headers"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:i.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.path})}),(0,r.jsx)(G.Z,{children:e.target}),(0,r.jsx)(G.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lM,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lF=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[n]=I.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call");let l=await (0,p.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),C.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),n.resetFields()},onCancel:()=>{t(!1),n.resetFields()},children:(0,r.jsxs)(I.Z,{form:n,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lR=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=I.Z.useForm();(0,n.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call"),t(!0);let l=await (0,p.qI)(s,e);a(e=>e?[...e,l]:[l]),C.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(I.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},lz=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)(!1),[a,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),[c,m]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&(0,p.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),i(!0))},h=async(e,s)=>{if(null==l)return;C.ZP.info("Request made"),await (0,p.NV)(l,e);let t=[...c];t.splice(s,1),m(t),C.ZP.success("Budget Deleted.")},x=async()=>{null!=l&&(0,p.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)(y.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lF,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lR,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:x}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Budget ID"}),(0,r.jsx)(J.Z,{children:"Max Budget"}),(0,r.jsx)(J.Z,{children:"TPM"}),(0,r.jsx)(J.Z,{children:"RPM"})]})}),(0,r.jsx)(H.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)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.budget_id}),(0,r.jsx)(G.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)(G.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)(G.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(w.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(en.Z,{children:"Test it (Curl)"}),(0,r.jsx)(en.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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)'})})]})]})]})]})},lU=s(77398),lV=s.n(lU),lq=s(20016);async function lB(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 lK=e=>{let{ipAddress:l}=e,[s,t]=n.useState("-");return n.useEffect(()=>{if(!l)return;let e=!0;return lB(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},lW=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"}},lH=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:lW(l)})},lG=[{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)(lH,{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)(lK,{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:eC(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)]})})})}}],lY=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,p.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 lJ(e){var l,s,t;let{accessToken:a,token:i,userRole:o,userID:d}=e,[m,u]=(0,n.useState)(""),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1),[f,y]=(0,n.useState)(1),[Z]=(0,n.useState)(50),_=(0,n.useRef)(null),b=(0,n.useRef)(null),v=(0,n.useRef)(null),[w,S]=(0,n.useState)(lV()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[N,k]=(0,n.useState)(lV()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,n.useState)(!1),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(""),[T,D]=(0,n.useState)(""),[M,L]=(0,n.useState)(""),[F,R]=(0,n.useState)(""),[z,U]=(0,n.useState)("Team ID"),V=(0,c.NL)();(0,n.useEffect)(()=>{function e(e){_.current&&!_.current.contains(e.target)&&j(!1),b.current&&!b.current.contains(e.target)&&x(!1),v.current&&!v.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,lq.a)({queryKey:["logs","table",f,Z,w,N,M,F],queryFn:async()=>{if(!a||!i||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:Z,total_pages:0};let e=lV()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?lV()(N).utc().format("YYYY-MM-DD HH:mm:ss"):lV()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,p.h3)(a,F||void 0,M||void 0,void 0,e,l,f,Z);return await lY(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&&!!i&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!i||!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(lV()(w).format("MMM D, h:mm A")," - ").concat(lV()(N).format("MMM D, h:mm A"));let e=lV()(),l=lV()(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:b,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:()=>x(!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:()=>j(!g),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"})})]}),g&&(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),j(!1),"Team ID"===e?D(""):E("")},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?O:T,onChange:e=>{"Team ID"===z?E(e.target.value):D(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{E(""),D("")},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:()=>{E(""),D(""),x(!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(O),R(T),y(1),x(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:v,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(lV()().format("YYYY-MM-DDTHH:mm")),S(lV()().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=>{S(e.target.value),y(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:N,onChange:e=>{k(e.target.value),y(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)*Z+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*Z,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:()=>y(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:()=>y(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:lG,data:B,renderSubComponent:l$,getRowCanExpand:()=>!0})]})]})}function l$(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 lX=s(92699),lQ=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)(f.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)(w.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(en.Z,{children:"LlamaIndex"}),(0,r.jsx)(en.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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 ')})})]})]})]})})})},l0=s(243),l1=s(94263);async function l2(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lN.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var l4=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,n.useState)(i?"custom":"session"),[c,m]=(0,n.useState)(""),[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)([]),[_,b]=(0,n.useState)(void 0),[v,S]=(0,n.useState)([]),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,p.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)),S(s),b(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,n.useEffect)(()=>{N.current&&setTimeout(()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[x]);let I=(e,l,s)=>{g(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){C.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},n=[...x.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];g([...x,r]);try{_&&await l2(n,(e,l)=>I("assistant",e,l),_,e)}catch(e){console.error("Error fetching model response",e),I("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=e_.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)(f.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(en.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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"API Key Source"}),(0,r.jsx)(k.default,{disabled:i,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)(w.Z,{children:"Select Model:"}),(0,r.jsx)(k.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),b(e)},options:v,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(y.Z,{onClick:()=>{g([]),C.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(W.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{})})}),(0,r.jsxs)(H.Z,{children:[x.map((e,l)=>(0,r.jsx)($.Z,{children:(0,r.jsxs)(G.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)(l0.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...n}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,r.jsx)(e1.Z,{style:l1.Z,language:i[1],PreTag:"div",...n,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...n,children:a})}},children:e.content})})]})},l)),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{ref:N,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)(y.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},l5=s(19226),l3=s(61787),l8=s(92403),l6=s(28595),l7=s(68208),l9=s(9775),se=s(41361),sl=s(37527),ss=s(15883),st=s(12660),sa=s(88009),sr=s(48231),sn=s(41169),si=s(44625),so=s(57400),sd=s(55322);let{Sider:sc}=l5.default,sm=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],su=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(l8.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(l6.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(l7.Z,{}),roles:sm},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(l9.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(se.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(ss.Z,{}),roles:sm},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(st.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sa.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sr.Z,{}),roles:sm},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sn.Z,{}),roles:sm,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(si.Z,{}),roles:sm},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(so.Z,{}),roles:sm}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(st.Z,{}),roles:sm},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm}]}];var sh=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=su.find(l=>l.page===e);if(l)return l.key;for(let l of su)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),n=su.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(l5.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sc,{theme:"light",width:220,children:(0,r.jsx)(l3.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:n.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)}}})})})})},sx=s(96889);console.log=function(){};var sp=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,n.useState)(null!==a?a:0),[m,u]=(0,n.useState)(o?o.max_budget:null);(0,n.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(i);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,i]);let[h,x]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,p.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,n.useEffect)(()=>{null!==a&&c(a)},[a]);let g=[];o&&o.models&&(g=o.models),g&&g.includes("all-proxy-models")?(console.log("user models:",h),g=h):g&&g.includes("all-team-models")?g=o.models:g&&0===g.length&&(g=h);let j=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:["$",j]})]}),(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"})]})]})})},sg=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sj=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sf=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[b,v]=(0,n.useState)([]),[N,k]=(0,n.useState)([]),[I,C]=(0,n.useState)([]),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)([]),[T,D]=(0,n.useState)([]),[M,L]=(0,n.useState)({}),[F,R]=(0,n.useState)([]),[z,U]=(0,n.useState)(""),[V,q]=(0,n.useState)(["all-tags"]),[B,K]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[X,Q]=(0,n.useState)(null),[ee,el]=(0,n.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",i),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,p.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,n.useEffect)(()=>{ej(B.from,B.to)},[B,V]);let eg=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,p.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),_(a)},ej=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,p.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 ey=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eZ=(e,l,s,t)=>{let a=[],r=new Date(l),n=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]}},i=new Map(e.map(e=>{let l=n(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(i.has(e))a.push(i.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},e_=async()=>{if(l)try{let e=await (0,p.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=eZ(e,t,a,[]),n=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(n),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},eb=()=>ey(()=>l&&s?(0,p.OU)(l,s,eu,eh):Promise.reject("No access token or token"),D,"Error fetching provider spend"),ew=async()=>{l&&await ey(async()=>(await (0,p.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")},eS=async()=>{l&&await ey(async()=>(await (0,p.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),g,"Error fetching top models")},eN=async()=>{l&&await ey(async()=>{let e=await (0,p.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return v(eZ(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)}))},E,"Error fetching team spend")},ek=()=>{l&&ey(async()=>(await (0,p.X)(l)).tag_names,C,"Error fetching tag names")},eI=()=>{l&&ey(()=>{var e,s;return(0,p.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&&ey(()=>(0,p.b1)(l,null,void 0,void 0),_,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,p.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=eZ(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,p.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:eZ(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,n.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(Q(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",X),e_(),eb(),ew(),eS(),eA(),eP(),sj(t)&&(eN(),ek(),eI(),eC()))}})()},[l,s,t,a,eu,eh]),null==X?void 0:X.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(w.Z,{className:"mt-4",children:["SpendLogs in DB has ",X.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)(y.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(en.Z,{children:"All Up"}),sj(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(en.Z,{children:"Team Based Usage"}),(0,r.jsx)(en.Z,{children:"Customer Usage"}),(0,r.jsx)(en.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(en.Z,{children:"Cost"}),(0,r.jsx)(en.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(w.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)(sp,{userID:a,userRole:t,accessToken:l,userSpend:ee,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Monthly Spend"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top API Keys"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top Models"}),(0,r.jsx)(eW.Z,{className:"mt-4 h-40",data:x,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)(S.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sg.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Provider"}),(0,r.jsx)(J.Z,{children:"Spend"})]})}),(0,r.jsx)(H.Z,{children:T.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.provider}),(0,r.jsx)(G.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)(f.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"All Up"}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(M.sum_api_requests)]}),(0,r.jsx)(eK.Z,{className:"h-40",data:M.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(M.sum_total_tokens)]}),(0,r.jsx)(eW.Z,{className:"h-40",data:M.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)(S.Z,{children:e.model}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(eK.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eW.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)(f.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)(S.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sx.Z,{data:O})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eW.Z,{className:"h-72",data:b,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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{eg(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{eg(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(W.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Customer"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Total Events"})]})}),(0,r.jsx)(H.Z,{children:null==Z?void 0:Z.map((e,l)=>{var s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.end_user}),(0,r.jsx)(G.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)(G.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eq.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(lv.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(f.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)(S.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(w.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)(eW.Z,{className:"h-72",data:N,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sy=e=>{if(e)return e.toISOString().split("T")[0]};function sZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var s_=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,n.useState)([]),[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)("0"),[b,v]=(0,n.useState)("0"),[S,N]=(0,n.useState)("0"),[k,I]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,n.useState)(""),[O,E]=(0,n.useState)("");(0,n.useEffect)(()=>{l&&k&&((async()=>{g(await (0,p.zg)(l,sy(k.from),sy(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),D=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let M=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),g(await (0,p.zg)(l,sy(e),sy(s))))};(0,n.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",x);let e=x;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},[]);_(sZ(s)),v(sZ(t));let r=s+l;r>0?N((s/r*100).toFixed(2)):N("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,x]);let L=async()=>{try{C.ZP.info("Running cache health check..."),E("");let e=await (0,p.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),E(e)}catch(e){console.error("Error running health check:",e),E("Error running health check")}};return(0,r.jsxs)(ei.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)(en.Z,{children:"Cache Analytics"}),(0,r.jsx)(en.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)(w.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eB.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)(f.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:D.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eq.Z,{enableSelect:!0,value:k,onValueChange:e=>{I(e),M(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:[S,"%"]})})]}),(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:Z})})]}),(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:b})})]})]}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eW.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eW.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sZ,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)(w.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(y.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),O&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(O,null,2)})]})})]})]})},sb=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(async()=>{try{let e=await (0,p.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)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Guardrail Name"}),(0,r.jsx)(J.Z,{children:"Mode"}),(0,r.jsx)(J.Z,{children:"Status"})]})}),(0,r.jsx)(H.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.guardrail_name}),(0,r.jsx)(G.Z,{children:e.litellm_params.mode}),(0,r.jsx)(G.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)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};function sv(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"}}let sw=new d.S;function sS(){let[e,l]=(0,n.useState)(""),[s,t]=(0,n.useState)(!1),[a,d]=(0,n.useState)(!1),[u,h]=(0,n.useState)(null),[g,j]=(0,n.useState)(null),[f,y]=(0,n.useState)(null),[Z,_]=(0,n.useState)(m),[b,v]=(0,n.useState)([]),[w,S]=(0,n.useState)([]),[N,k]=(0,n.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[I,C]=(0,n.useState)(!0),A=(0,i.useSearchParams)(),[P,O]=(0,n.useState)({data:[]}),[E,T]=(0,n.useState)(null),D=A.get("userID"),M=A.get("invitation_id"),[L,F]=(0,n.useState)(()=>A.get("page")||"api-keys"),[R,z]=(0,n.useState)(null);return(0,n.useEffect)(()=>{T(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,n.useEffect)(()=>{if(!E)return;let e=(0,o.o)(E);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),z(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=sv(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&F("usage")}else console.log("User role not defined");e.user_email?h(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?C("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,p.K8)(e.auth_header_name)}},[E]),(0,n.useEffect)(()=>{R&&D&&e&&q(D,e,R,S)},[R,D,e]),(0,r.jsx)(n.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sw,children:M?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(x,{userID:D,userRole:e,userEmail:u,premiumUser:s,setProxySettings:k,proxySettings:N,currentOrg:Z,organizations:b,onOrgChange:s=>{if(_(s),console.log("org: ".concat(JSON.stringify(s))),s.members&&"Admin"!=e)for(let e of s.members)console.log("member: ".concat(JSON.stringify(e))),e.user_id==D&&(console.log("member.user_role: ".concat(e.user_role)),l(sv(e.user_role)));j(null)}}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sh,{setPage:e=>{let l=new URLSearchParams(A);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),F(e)},userRole:e,defaultSelectedKey:L})}),"api-keys"==L?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):"models"==L?(0,r.jsx)(e3,{userID:D,userRole:e,token:E,keys:f,accessToken:R,modelData:P,setModelData:O,premiumUser:s}):"llm-playground"==L?(0,r.jsx)(l4,{userID:D,userRole:e,token:E,accessToken:R,disabledPersonalKeyCreation:a}):"users"==L?(0,r.jsx)(le,{userID:D,userRole:e,token:E,keys:f,teams:g,accessToken:R,setKeys:y}):"teams"==L?(0,r.jsx)(lo,{teams:g,setTeams:j,searchParams:A,accessToken:R,userID:D,userRole:e,currentOrg:Z}):"organizations"==L?(0,r.jsx)(lm,{organizations:b,setOrganizations:v,userModels:w,accessToken:R,userRole:e,premiumUser:s}):"admin-panel"==L?(0,r.jsx)(lh,{setTeams:j,searchParams:A,accessToken:R,showSSOBanner:I,premiumUser:s}):"api_ref"==L?(0,r.jsx)(lQ,{proxySettings:N}):"settings"==L?(0,r.jsx)(l_,{userID:D,userRole:e,accessToken:R,premiumUser:s}):"budgets"==L?(0,r.jsx)(lz,{accessToken:R}):"guardrails"==L?(0,r.jsx)(sb,{accessToken:R}):"general-settings"==L?(0,r.jsx)(lA,{userID:D,userRole:e,accessToken:R,modelData:P}):"model-hub"==L?(0,r.jsx)(lX.Z,{accessToken:R,publicPage:!1,premiumUser:s}):"caching"==L?(0,r.jsx)(s_,{userID:D,userRole:e,token:E,accessToken:R,premiumUser:s}):"pass-through-settings"==L?(0,r.jsx)(lL,{userID:D,userRole:e,accessToken:R,modelData:P}):"logs"==L?(0,r.jsx)(lJ,{userID:D,userRole:e,token:E,accessToken:R}):(0,r.jsx)(sf,{userID:D,userRole:e,token:E,accessToken:R,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,270,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/index.html b/litellm/proxy/_experimental/out/index.html index 234c844bb7f..df3e5ada523 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 9261bc995ab..4aac8d7b9d1 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[36733,["665","static/chunks/3014691f-6bdd9c4659caabcd.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-85111ce0453ddfcd.js","261","static/chunks/261-d96d45a1822b4dea.js","755","static/chunks/755-288e79da1358e7df.js","270","static/chunks/270-4325009e72737e70.js","250","static/chunks/250-80b974142ec97c60.js","699","static/chunks/699-1ceaf984f1f1378c.js","931","static/chunks/app/page-7a5ba6fe8c2fe4b2.js"],"default",1] +3:I[36733,["665","static/chunks/3014691f-6bdd9c4659caabcd.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-85111ce0453ddfcd.js","261","static/chunks/261-d96d45a1822b4dea.js","755","static/chunks/755-288e79da1358e7df.js","270","static/chunks/270-4325009e72737e70.js","250","static/chunks/250-80b974142ec97c60.js","699","static/chunks/699-1ceaf984f1f1378c.js","931","static/chunks/app/page-508ac4d06e0d1277.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["SyoNkMOnybMJCs1FpMdUS",[[["",{"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/b52cc8cb4b27f084.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:["SLeC9QjabwQfDLWx06pJ4",[[["",{"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/b52cc8cb4b27f084.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 cb47a272b86..9e27a690ed2 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-85111ce0453ddfcd.js","261","static/chunks/261-d96d45a1822b4dea.js","250","static/chunks/250-80b974142ec97c60.js","699","static/chunks/699-1ceaf984f1f1378c.js","418","static/chunks/app/model_hub/page-cca9fa9bc14379a7.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["SyoNkMOnybMJCs1FpMdUS",[[["",{"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/b52cc8cb4b27f084.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:["SLeC9QjabwQfDLWx06pJ4",[[["",{"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/b52cc8cb4b27f084.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 index ecec27ab73e..3934d7f72ad 100644 --- a/litellm/proxy/_experimental/out/onboarding.html +++ b/litellm/proxy/_experimental/out/onboarding.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/onboarding.txt b/litellm/proxy/_experimental/out/onboarding.txt index e214de51bff..cd697421729 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-6bdd9c4659caabcd.js","42","static/chunks/42-85111ce0453ddfcd.js","755","static/chunks/755-288e79da1358e7df.js","250","static/chunks/250-80b974142ec97c60.js","461","static/chunks/app/onboarding/page-628ddfb2d1bfc440.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["SyoNkMOnybMJCs1FpMdUS",[[["",{"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/b52cc8cb4b27f084.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:["SLeC9QjabwQfDLWx06pJ4",[[["",{"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/b52cc8cb4b27f084.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 5107c232a3a..3ce1709400a 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/SyoNkMOnybMJCs1FpMdUS/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_buildManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/SyoNkMOnybMJCs1FpMdUS/_buildManifest.js rename to ui/litellm-dashboard/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_buildManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/SyoNkMOnybMJCs1FpMdUS/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_ssgManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/SyoNkMOnybMJCs1FpMdUS/_ssgManifest.js rename to ui/litellm-dashboard/out/_next/static/SLeC9QjabwQfDLWx06pJ4/_ssgManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-508ac4d06e0d1277.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-508ac4d06e0d1277.js new file mode 100644 index 00000000000..333efeee934 --- /dev/null +++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-508ac4d06e0d1277.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,36733))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return y}});var t=s(57437),a=s(2265),r=s(99376),n=s(20831),i=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),g=s(14474),j=s(13634),f=s(73002);function y(){let[e]=j.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"),[y,Z]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,N]=(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,g.o)(s);A(s),console.log("decoded:",t),Z(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),N(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)(i.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)(n.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)(j.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",y,"token:",C,"formValues:",e),y&&C&&(e.user_email=v,S&&s&&(0,p.m_)(y,s,S,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)(j.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:v,defaultValue:v,className:"max-w-md"})}),(0,t.jsx)(j.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"})})]})]})})}},36733:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sS}});var t,a,r=s(57437),n=s(2265),i=s(99376),o=s(14474),d=s(90946),c=s(29827);let m={organization_id:null,organization_alias:"Default Organization"};var u=s(27648),h=s(92643),x=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:n,proxySettings:i,currentOrg:o=null,onOrgChange:d=()=>{},onNewOrg:c=()=>{},organizations:x=[]}=e;console.log("currentOrg: ".concat(JSON.stringify(o))),console.log("organizations: ".concat(JSON.stringify(x)));let p=(null==i?void 0:i.PROXY_LOGOUT_URL)||"",g=[{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(a)]})]})},{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=p},children:"Logout"})}],j=[{key:"header",label:"Organizations",type:"group",style:{color:"#6B7280",fontSize:"0.875rem"}},{key:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:"Default Organization"})}),onClick:()=>d(m)},...x.filter(e=>null!==e.organization_id).map(e=>{var l;return{key:null!==(l=e.organization_id)&&void 0!==l?l:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:e.organization_alias})}),onClick:()=>d(e)}}),{key:"note",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 text-gray-500 text-xs italic",children:(0,r.jsx)("span",{children:"Switching between organizations on the UI is currently in beta."})}),disabled:!0}];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)(u.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:"ml-8 flex items-center",children:[(0,r.jsx)(h.Z,{menu:{items:j,style:{width:"280px",padding:"4px",marginTop:"4px"}},trigger:["click"],placement:"bottomLeft",children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-700 hover:text-gray-900 transition-colors",children:[o?o.organization_alias:"Default Organization",(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"})})]})}),(0,r.jsx)("span",{className:"ml-2 text-[10px] bg-blue-100 text-blue-800 font-medium px-2 py-0.5 rounded",children:"BETA"})]}),(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)(h.Z,{menu:{items:g,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"})})]})})]})]})})})},p=s(19250);let g=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO,l):await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),f=s(67101),y=s(20831),Z=s(26637),_=s(87452),b=s(88829),v=s(72208),w=s(84264),S=s(96761),N=s(29233),k=s(41326),I=s(13634),C=s(41021),A=s(51369),P=s(8104),O=s(20577),E=s(56632),T=s(73002);let D=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,p.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},L=(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 F=s(15424),R=s(75957);let{Option:z}=k.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)=>L(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,p.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:i,data:o,setData:d}=e,[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,D]=(0,n.useState)(null),[L,B]=(0,n.useState)([]),[K,W]=(0,n.useState)([]),[H,G]=(0,n.useState)("you"),[Y,J]=(0,n.useState)(U(o)),[$,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(s),el=()=>{u(!1),c.resetFields()},es=()=>{u(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{l&&a&&i&&q(l,a,i,B)},[i,l,a]),(0,n.useEffect)(()=>{(async()=>{try{let e=(await (0,p.t3)(i)).guardrails.map(e=>e.guardrail_name);X(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[i]);let et=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",n=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===n).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(n,", please provide another key alias"));if(C.ZP.info("Making API Call"),u(!0),"you"===H&&(e.user_id=l),"service_account"===H){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,p.wX)(i,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),x(m.key),D(m.soft_budget),C.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),C.ZP.error("Error creating the key: ".concat(e))}};return(0,n.useEffect)(()=>{W(V(Q,L)),c.setFieldValue("models",[])},[Q,L]),(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(A.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:el,onCancel:es,children:(0,r.jsxs)(I.Z,{form:c,onFinish:et,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(P.ZP.Group,{onChange:e=>G(e.target.value),value:H,children:[(0,r.jsx)(P.ZP,{value:"you",children:"You"}),(0,r.jsx)(P.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(P.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==H,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===H,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)(I.Z.Item,{label:"you"===H||"another_user"===H?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===H?"key name":"service account ID")}],help:"you"===H?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(k.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{c.setFieldValue("team_id",e),ee((null==t?void 0:t.find(l=>l.team_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==t?void 0:t.map(e=>(0,r.jsxs)(k.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))})}),(0,r.jsx)(I.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)(k.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"),K.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)(b.Z,{children:[(0,r.jsx)(I.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)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.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)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:$.map(e=>({value:e,label:e}))})}),(0,r.jsx)(I.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)(I.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:Y})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(A.Z,{visible:m,onOk:el,onCancel:es,footer:null,children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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:()=>{C.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(w.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=s(21626),H=s(97214),G=s(28241),Y=s(58834),J=s(69552),$=s(71876),X=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,i]=(0,n.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,n.useState)(!0),[c,m]=(0,n.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!s||!t){console.log("currentOrg",s),console.log("accessToken",t);return}d(!0);let a=await (0,p.OD)(t,s.organization_id,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),i(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,n.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}},Q=s(71594),ee=s(24525);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:i=!1}=e,o=(0,Q.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,ee.sC)(),getExpandedRowModel:(0,ee.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(W.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(Y.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)($.Z,{children:e.headers.map(e=>(0,r.jsx)(J.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,Q.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(H.Z,{children:i?(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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)(n.Fragment,{children:[(0,r.jsx)($.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)(G.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,Q.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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),en=s(12485),ei=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:i,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=I.Z.useForm(),[h,x]=(0,n.useState)([]),g=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,n.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,p.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let j={...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)(I.Z,{form:u,onFinish:i,initialValues:j,layout:"vertical",children:[(0,r.jsx)(I.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[g.length>0&&(0,r.jsx)(k.default.Option,{value:"all-team-models",children:"All Team Models"}),g.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(k.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(k.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(I.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(I.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)(y.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a,onSuccess:i}=e,[o]=I.Z.useForm(),[d,c]=(0,n.useState)(null),[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(null);(0,n.useEffect)(()=>{s&&l&&o.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,o]),(0,n.useEffect)(()=>{(null==m?void 0:m.duration)?x((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}})(m.duration)):x(null)},[null==m?void 0:m.duration]);let g=async()=>{if(l&&a)try{let e=await o.validateFields(),s=await (0,p.s0)(a,l.token,e);c(s.key),i&&i({...l,key_name:s.key_name,...e}),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}},_=()=>{c(null),o.resetFields(),t()};return(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:s,onCancel:_,footer:d?[(0,r.jsx)(y.Z,{onClick:_,children:"Close"},"close")]:[(0,r.jsx)(y.Z,{onClick:_,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:g,children:"Regenerate"},"regenerate")],children:d?(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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)(w.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:d})}),(0,r.jsx)(N.CopyToClipboard,{text:d,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(I.Z,{form:o,layout:"vertical",onValuesChange:e=>{"duration"in e&&u(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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"]}),h&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",h]})]})})}function eg(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:i,userRole:o,teams:d}=e,[c,m]=(0,n.useState)(!1),[u]=I.Z.useForm(),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:"Key not found"})]});let Z=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),C.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,p.Nc)(a,e),C.ZP.success("Key updated successfully"),m(!1)}catch(e){C.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},_=async()=>{try{if(!a)return;await (0,p.I1)(a,t.token),C.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),C.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)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(S.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(y.Z,{icon:eu.Z,variant:"secondary",onClick:()=>j(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(y.Z,{icon:eh.Z,variant:"secondary",onClick:()=>x(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:g,onClose:()=>j(!1),accessToken:a,onSuccess:e=>{j(!1)}}),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)(y.Z,{onClick:_,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>x(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(w.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(w.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)(S.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(y.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:Z,teams:d,accessToken:a,userID:i,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(w.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(w.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(w.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(w.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(w.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(w.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)})]})]})]})})]})]})]})}let ej=e=>{let{teams:l,selectedTeam:s,setSelectedTeam:t}=e;return(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-600",children:"Where Team is"}),(0,r.jsxs)(es.Z,{value:(null==s?void 0:s.team_id)||"",onValueChange:e=>{t((null==l?void 0:l.find(l=>l.team_id===e))||null)},placeholder:"Team ID",className:"w-[400px]",children:[(0,r.jsx)(et.Z,{value:"team_id",children:"Team ID"}),null==l?void 0:l.map(e=>(0,r.jsxs)(et.Z,{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))]})]})})};function ef(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:i=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h}=e,[x,p]=(0,n.useState)(null),g=[{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)(y.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.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Organization",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{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:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{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:x?(0,r.jsx)(eg,{keyId:x,onClose:()=>p(null),keyData:l.find(e=>e.token===x),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",children:[(0,r.jsx)(ej,{teams:o,selectedTeam:d,setSelectedTeam:c}),(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)*i+1," - ").concat(Math.min(t.currentPage*i,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:g.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ey=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:i,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u}=e,[h,x]=(0,n.useState)(!1),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),[k,P]=(0,n.useState)(null),[E,T]=(0,n.useState)(null),[M,L]=(0,n.useState)((null==a?void 0:a.team_id)||""),[F,R]=(0,n.useState)("");(0,n.useEffect)(()=>{L((null==a?void 0:a.team_id)||"")},[a]),(0,n.useMemo)(()=>{let e={};return M&&(e.team_id=M),F&&(e.key_alias=F),e},[M,F]);let{keys:z,isLoading:U,error:V,pagination:q,refresh:B}=X({selectedTeam:a,currentOrg:u,accessToken:t}),[W,H]=(0,n.useState)(!1),[G,Y]=(0,n.useState)(!1),[J,$]=(0,n.useState)(null),[Q,ee]=(0,n.useState)([]),el=new Set,[es,et]=(0,n.useState)(!1),[ea,er]=(0,n.useState)(!1),[en,ei]=(0,n.useState)(null),[eo,ed]=(0,n.useState)(null),[ec]=I.Z.useForm(),[em,eu]=(0,n.useState)(null),[eh,ex]=(0,n.useState)(el),[ep,eg]=(0,n.useState)([]);(0,n.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",J),(null==eo?void 0:eo.duration)?eu((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}})(eo.duration)):eu(null),console.log("calculateNewExpiryTime:",em)},[J,null==eo?void 0:eo.duration]),(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await D(l,s,t);e&&ee(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ex(e)}},[c]);let ej=async()=>{if(null!=b&&null!=o){try{await (0,p.I1)(t,b);let e=o.filter(e=>e.token!==b);d(e)}catch(e){console.error("Error deleting the key:",e)}_(!1),v(null)}},ey=(e,l)=>{ed(s=>({...s,[e]:l}))},eZ=async()=>{if(!m){C.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=J)try{let e=await ec.validateFields(),l=await (0,p.s0)(t,J.token,e);if(ei(l.key),o){let s=o.map(s=>s.token===(null==J?void 0:J.token)?{...s,key_name:l.key_name,...e}:s);d(s)}er(!1),ec.resetFields(),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}};return Array.from(new Set(z.map(e=>e.key_alias?e.key_alias:"Not Set"))),(0,r.jsxs)("div",{children:[(0,r.jsx)(ef,{keys:z,isLoading:U,pagination:q,onPageChange:e=>{B({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:i,accessToken:t,userID:l,userRole:s}),g&&(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)(y.Z,{onClick:ej,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{_(!1),v(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:ea,onCancel:()=>{er(!1),ec.resetFields()},footer:[(0,r.jsx)(y.Z,{onClick:()=>{er(!1),ec.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:eZ,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(I.Z,{form:ec,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&ey("duration",e.duration)},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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==J?void 0:J.expires)!=null?new Date(J.expires).toLocaleString():"Never"]}),em&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",em]})]}):(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)(y.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"})})]})}),en&&(0,r.jsx)(A.Z,{visible:!!en,onCancel:()=>ei(null),footer:[(0,r.jsx)(y.Z,{onClick:()=>ei(null),children:"Close"},"close")],children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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==J?void 0:J.key_alias)||"No alias set"})}),(0,r.jsx)(w.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:en})}),(0,r.jsx)(N.CopyToClipboard,{text:en,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eZ=s(12011),e_=s(68060);console.log=function(){},console.log("isLocal:",!1);var eb=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,setOrganizations:x,premiumUser:y,currentOrg:Z}=e;console.log("currentOrg in user dashboard: ".concat(JSON.stringify(Z)));let[_,b]=(0,n.useState)(null),v=(0,i.useSearchParams)(),w=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=v.get("invitation_id"),[N,k]=(0,n.useState)(null),[I,C]=(0,n.useState)(null),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(w){let e=(0,o.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),k(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&&N&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);if(e)P(JSON.parse(e));else{console.log("currentOrg: ".concat(JSON.stringify(Z)));let e=async()=>{x(await (0,p.r6)(N))};(async()=>{try{let e=await (0,p.g)(N);E(e);let t=await (0,p.Br)(N,l,s,!1,null,null);b(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,p.So)(N,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),P(a),console.log("userModels:",A),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),g(N,l,s,Z,u),e()}}},[l,w,N,a,s]),(0,n.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(Z),", accessToken: ").concat(N,", userID: ").concat(l,", userRole: ").concat(s)),N&&(console.log("fetching teams"),g(N,l,s,Z,u))},[Z]),(0,n.useEffect)(()=>{if(null!==a&&null!=T&&null!==T.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))T.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===T.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),C(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;C(e)}},[T]),null!=S)return(0,r.jsx)(eZ.default,{});if(null==l||null==w){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==N)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=e_.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",T),(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,r.jsx)(f.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:T,teams:t,userRole:s,accessToken:N,data:a,setData:h},T?T.team_id:null),(0,r.jsx)(ey,{userID:l,userRole:s,accessToken:N,selectedTeam:T||null,setSelectedTeam:D,data:a,setData:h,premiumUser:y,teams:t,currentOrg:Z})]})})})},ev=s(97765),ew=s(47451),eS=s(69410),eN=()=>{let e=I.Z.useFormInstance();return(I.Z.useWatch("model",e)||[]).includes("all-wildcard")?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!1,className:"mb-0",rules:[e=>{let{getFieldValue:l}=e;return{validator:(e,s)=>!(l("model")||[]).includes("all-wildcard")||s?Promise.resolve():Promise.reject(Error('Public Model Name is required unless "All Models" is selected.'))}}],children:(0,r.jsx)(Z.Z,{placeholder:"my-gpt-4"})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})};(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 ek={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"},eI={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"},eC=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(ek).find(l=>ek[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eI[s],displayName:s}},eA=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",eP=(e,l)=>{console.log("Provider key: ".concat(e));let s=ek[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};var eO=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,n=I.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(I.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)(I.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.toString())}):s.length>0?(0,r.jsx)(k.default,{allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{e.includes("all-wildcard")&&n.setFieldsValue({model_name:void 0})},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.toString())})}),(0,r.jsx)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},eE=s(63709),eT=s(90464);let{Link:eD}=e_.default;var eM=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s}=e,[t]=I.Z.useForm(),[a,i]=n.useState(!1),[o,d]=n.useState("per_token"),c=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),m=(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)(b.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(I.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(eE.Z,{onChange:e=>{i(e),e||t.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),a&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(I.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:"per_token",onChange:e=>d(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(I.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(I.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)(eD,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(eE.Z,{onChange:e=>{let l=t.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?t.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):t.setFieldValue("litellm_extra_params","")}catch(l){e?t.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):t.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(ew.Z,{className:"mb-4",children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(eD,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})},eL=s(18502),eF=s(3632);let{Link:eR}=e_.default;var ez=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)(I.Z.Item,{label:"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)(I.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)(I.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(eL.Z,{...s,children:(0,r.jsx)(T.ZP,{icon:(0,r.jsx)(eF.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(k.default,{placeholder:"Select API Base",children:[(0,r.jsx)(k.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(k.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(I.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)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(eR,{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)(I.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)(I.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)(I.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)(I.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"})})]})};let eU=async(e,l,s,t)=>{try{if(console.log("handling submit for formValues:",e),e.model&&e.model.includes("all-wildcard")){let l=ek[e.custom_llm_provider]+"/*";e.model_name=l,e.model=l}let a=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(a)),console.log("received type of deployments: ".concat(typeof a)),a.forEach(async s=>{console.log("litellm_model: ".concat(s));let a={},r={};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),a.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=ek[s];a.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)r[l]=s;else if("custom_model_name"===l)a.model=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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))r[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){s&&(a[l]=Number(s));continue}else a[l]=s}let i={model_name:n,litellm_params:a,model_info:r},o=await (0,p.kK)(l,i);t&&t(),console.log("response for model create call: ".concat(o.data))}),s.resetFields()}catch(e){C.ZP.error("Failed to create model: "+e,10)}};var eV=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[n]=I.Z.useForm(),i={},o="",d="";if(t){var c,m;i={...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)),i.model_id=d)}return(0,r.jsx)(A.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{n.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}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(I.Z,{form:n,onFinish:a,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},eq=s(53003),eB=s(47323),eK=s(75105),eW=s(40278),eH=s(14301),eG=s(15731),eY=s(53410),eJ=s(2356),e$=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,i]=(0,n.useState)(!1),o=async()=>{try{C.ZP.info("Making API Call"),i(!0);let e=await (0,p.Og)(s,l);console.log("model delete Response:",e),C.ZP.success("Model ".concat(l," deleted successfully")),i(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eB.Z,{onClick:()=>i(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(A.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>i(!1),children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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})]})})]})})]})},eX=s(94789),eQ=s(59664),e0=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eQ.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)(eX.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)(y.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},e1=s(17906);let{Title:e2,Link:e4}=e_.default,e5={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var e3=e=>{let{accessToken:l,token:s,userRole:t,userID:i,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m}=e,[u,h]=(0,n.useState)([]),[x]=I.Z.useForm(),[g,j]=(0,n.useState)(null),[Z,_]=(0,n.useState)(""),[b,v]=(0,n.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[N,P]=(0,n.useState)([]),[E,D]=(0,n.useState)(a.OpenAI),[M,L]=(0,n.useState)(""),[F,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(null),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)([]),[el,em]=(0,n.useState)(null),[eh,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)([]),[ej,ef]=(0,n.useState)([]),[ey,eZ]=(0,n.useState)([]),[eb,ew]=(0,n.useState)([]),[eE,eT]=(0,n.useState)([]),[eD,eL]=(0,n.useState)([]),[eF,eR]=(0,n.useState)([]),[eX,eQ]=(0,n.useState)([]),[e4,e3]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e8,e6]=(0,n.useState)(null),[e7,e9]=(0,n.useState)(0),[le,ll]=(0,n.useState)({}),[ls,lt]=(0,n.useState)([]),[la,lr]=(0,n.useState)(!1),[ln,li]=(0,n.useState)(null),[lo,ld]=(0,n.useState)(null),[lc,lm]=(0,n.useState)([]),[lu,lh]=(0,n.useState)(!1),lx=e=>{let l=eP(e,g);v(l),console.log("providerModels: ".concat(l))},lp=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!i||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),em(e);let r=null==ln?void 0:ln.token;void 0===r&&(r=null);let n=lo;void 0===n&&(n=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,p.o6)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model metrics response:",o),eg(o.data),ef(o.all_api_bases);let d=await (0,p.Rg)(l,e,s.toISOString(),a.toISOString());eZ(d.data),ew(d.all_api_bases);let c=await (0,p.N8)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model exceptions response:",c),eT(c.data),eL(c.exception_types);let m=await (0,p.fP)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);if(console.log("slowResponses:",m),eQ(m),e){let t=await (0,p.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);ll(t);let r=await (0,p.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);lt(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,n.useEffect)(()=>{lp(el,e4.from,e4.to)},[ln,lo]);let lg=e=>{B(e),z(!0)},lj=e=>{B(e),V(!0)},lf=async e=>{if(console.log("handleEditSubmit:",e),null==l)return;let s={},t=null;for(let[l,a]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?s[l]=""===a?null:a:t=""===a?null:a;let a={litellm_params:Object.keys(s).length>0?s:void 0,model_info:void 0!==t?{id:t}:void 0};console.log("handleEditSubmit payload:",a);try{await (0,p.um)(l,a),C.ZP.success("Model updated successfully, restart server to see updates"),z(!1),B(null)}catch(e){console.log("Error occurred")}},ly=()=>{_(new Date().toLocaleString())},lZ=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e8);try{await (0,p.K_)(l,{router_settings:{model_group_retry_policy:e8}}),C.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),C.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!l||!s||!t||!i)return;let e=async()=>{try{var e,s,a,r,n,o,d,m,u,h,x,g;let j=await (0,p.hy)(l);P(j);let f=await (0,p.AZ)(l,i,t);console.log("Model data response:",f.data),c(f);let y=new Set;for(let e=0;e0&&(_=Z[Z.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",el);let b=await (0,p.o6)(l,i,t,_,null===(e=e4.from)||void 0===e?void 0:e.toISOString(),null===(s=e4.to)||void 0===s?void 0:s.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model metrics response:",b),eg(b.data),ef(b.all_api_bases);let v=await (0,p.Rg)(l,_,null===(a=e4.from)||void 0===a?void 0:a.toISOString(),null===(r=e4.to)||void 0===r?void 0:r.toISOString());eZ(v.data),ew(v.all_api_bases);let w=await (0,p.N8)(l,i,t,_,null===(n=e4.from)||void 0===n?void 0:n.toISOString(),null===(o=e4.to)||void 0===o?void 0:o.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model exceptions response:",w),eT(w.data),eL(w.exception_types);let S=await (0,p.fP)(l,i,t,_,null===(d=e4.from)||void 0===d?void 0:d.toISOString(),null===(m=e4.to)||void 0===m?void 0:m.toISOString(),null==ln?void 0:ln.token,lo),N=await (0,p.n$)(l,null===(u=e4.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=e4.to)||void 0===h?void 0:h.toISOString().split("T")[0],_);ll(N);let k=await (0,p.v9)(l,null===(x=e4.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(g=e4.to)||void 0===g?void 0:g.toISOString().split("T")[0],_);lt(k),console.log("dailyExceptions:",N),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",S),eQ(S);let I=await (0,p.j2)(l);lm(null==I?void 0:I.end_users);let C=(await (0,p.BL)(l,i,t)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,O=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",O),e6(A),e9(O)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&i&&e();let a=async()=>{let e=await (0,p.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),j(e)};null==g&&a(),ly()},[l,s,t,i,g,Z]),!o||!l||!s||!t||!i)return(0,r.jsx)("div",{children:"Loading..."});let l_=[],lb=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(g)),null!=g&&"object"==typeof g&&e in g)?g[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&&(n=null==a?void 0:a.input_cost_per_token,i=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=n,o.data[e].output_cost=i,o.data[e].litellm_model_name=s,lb.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===(lS=l.litellm_params)||void 0===lS?void 0:lS.api_base,o.data[e].cleanedLitellmParams=m,l_.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}=e_.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 lN=async()=>{try{C.ZP.info("Running health check..."),L("");let e=await (0,p.EY)(l);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lk=(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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:()=>{li(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:()=>{li(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{ld(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:()=>{li(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:()=>{li(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lI=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let n=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.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:[n&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),i.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(b.length));let lC=Object.keys(a).find(e=>a[e]===E);return lC&&N.find(e=>e.name===ek[lC]),(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,r.jsxs)(ei.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)(en.Z,{children:"All Models"}),(0,r.jsx)(en.Z,{children:"Add Model"}),(0,r.jsx)(en.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(en.Z,{children:"Model Analytics"}),(0,r.jsx)(en.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[Z&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",Z]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ly})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||void 0,onValueChange:e=>em("all"===e?"all":e),value:el||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(J.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(J.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)(J.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)(J.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)(J.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)(J.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:o.data.filter(e=>"all"===el||e.model_name===el||null==el||""===el).map((e,s)=>{var a;return(0,r.jsxs)($.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)(G.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,r.jsx)(G.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:eC(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)(G.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)(G.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)(G.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)(G.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)(G.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)(G.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)(G.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)(G.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(f.Z,{numItems:3,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eG.Z,size:"sm",onClick:()=>lj(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>lg(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(e$,{modelID:e.model_info.id,accessToken:l,callback:ly})})]})})]},s)})})]})})]}),(0,r.jsx)(eV,{visible:F,onCancel:()=>{z(!1),B(null)},model:q,onSubmit:lf}),(0,r.jsxs)(A.Z,{title:q&&q.model_name,visible:U,width:800,footer:null,onCancel:()=>{V(!1),B(null)},children:[(0,r.jsx)(S.Z,{children:"Model Info"}),(0,r.jsx)(e1.Z,{language:"json",children:q&&JSON.stringify(q,null,2)})]})]}),(0,r.jsxs)(ed.Z,{className:"h-full",children:[(0,r.jsx)(e2,{level:2,children:"Add new model"}),(0,r.jsx)(er.Z,{children:(0,r.jsx)(I.Z,{form:x,onFinish:()=>{x.validateFields().then(e=>{eU(e,l,x,ly)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(k.default,{showSearch:!0,value:E,onChange:e=>{D(e),lx(e),x.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(k.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eI[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)(eO,{selectedProvider:E,providerModels:b,getPlaceholder:eA}),(0,r.jsx)(eN,{}),(0,r.jsx)(ez,{selectedProvider:E,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;x.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?C.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&C.ZP.error("".concat(e.file.name," file upload failed."))}}}),(0,r.jsx)(eM,{showAdvancedSettings:lu,setShowAdvancedSettings:lh}),(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)(e_.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(y.Z,{onClick:lN,children:"Run `/health`"}),M&&(0,r.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:e4,className:"mr-2",onValueChange:e=>{e3(e),lp(el,e.from,e.to)}})]}),(0,r.jsxs)(eS.Z,{className:"ml-2",children:[(0,r.jsx)(w.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:el||K[0],value:el||K[0],children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lp(e,e4.from,e4.to),children:e},l))})]}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eH.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,r.jsx)(y.Z,{icon:eJ.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(en.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)(w.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ep&&ej&&(0,r.jsx)(eK.Z,{title:"Model Latency",className:"h-72",data:ep,showLegend:!1,index:"date",categories:ej,connectNulls:!0,customTooltip:lI})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e0,{modelMetrics:ey,modelMetricsCategories:eb,customTooltip:lI,premiumUser:m})})]})]})})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Deployment"}),(0,r.jsx)(J.Z,{children:"Success Responses"}),(0,r.jsxs)(J.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(H.Z,{children:eX.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.api_base}),(0,r.jsx)(G.Z,{children:e.total_count}),(0,r.jsx)(G.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Exceptions for ",el]}),(0,r.jsx)(eW.Z,{className:"h-60",data:eE,index:"model",categories:eD,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Up Rate Limit Errors (429) for ",el]}),(0,r.jsxs)(f.Z,{numItems:1,children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",le.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.Z,{className:"h-40",data:le.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eS.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:ls.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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:ls&&ls.length>0&&ls.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.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)(y.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)(S.Z,{children:e.api_base}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||K[0],value:el||K[0],onValueChange:e=>em(e),children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))})]}),(0,r.jsxs)(S.Z,{children:["Retry Policy for ",el]}),(0,r.jsx)(w.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),e5&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(e5).map((e,l)=>{var s;let[t,a]=e,n=null==e8?void 0:null===(s=e8[el])||void 0===s?void 0:s[a];return null==n&&(n=e7),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(O.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{e6(l=>{var s;let t=null!==(s=null==l?void 0:l[el])&&void 0!==s?s:{};return{...null!=l?l:{},[el]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(y.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})};function e8(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:n,Paragraph:i}=e_.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)(A.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(i,{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)(w.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(w.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)(w.Z,{children:"Invitation Link"}),(0,r.jsx)(w.Z,{children:(0,r.jsx)(w.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>C.ZP.success("Copied!"),children:(0,r.jsx)(y.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:e6}=k.default;var e7=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,n.useState)(null),[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)([]),[f,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),S=(0,i.useRouter)(),[N,P]=(0,n.useState)("http://localhost:4000");(0,n.useEffect)(()=>{(async()=>{try{let e=await (0,p.So)(s,l,"any"),t=[];for(let l=0;l{S&&P(new URL("/",window.location.href).toString())},[S]);let O=async e=>{try{var t;C.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,p.Ov)(s,null,e);console.log("user create Response:",a),x(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};v(e),_(!0)}else(0,p.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,v(e),_(!0)});C.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)(y.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(A.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),x(null),c.resetFields()},children:[(0,r.jsx)(w.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(I.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(k.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(e6,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(e6,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(I.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)(T.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(e8,{isInvitationLinkModalVisible:f,setIsInvitationLinkModalVisible:_,baseUrl:N,invitationLinkData:b})]})},e9=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,n.useState)(a),[c]=I.Z.useForm();(0,n.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,r.jsx)(A.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(I.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)(I.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)(I.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var le=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(1),[_,b]=n.useState(null),[v,w]=(0,n.useState)(null),[S,N]=(0,n.useState)(!1),[k,I]=(0,n.useState)(null),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{E(e),P(!0)},L=async()=>{if(O&&l)try{if(await (0,p.Eb)(l,[O]),C.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==O);h(e)}}catch(e){console.error("Error deleting user:",e),C.ZP.error("Failed to delete user")}P(!1),E(null)},F=async()=>{I(null),N(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,p.pf)(l,e,null),C.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)),I(null),N(!1)}};return((0,n.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(j));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,p.Br)(l,null,a,!0,j,25);sessionStorage.setItem("userList_".concat(j),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,p.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),D(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&i&&e()},[l,s,a,i,j]),u&&l&&s&&a&&i)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(f.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(e7,{userID:i,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)(ei.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(W.Z,{className:"mt-5",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(J.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(J.Z,{children:"API Keys"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.user_id||"-"}),(0,r.jsx)(G.Z,{children:e.user_email||"-"}),(0,r.jsx)(G.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)(G.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)(G.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(f.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)(G.Z,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,onClick:()=>{I(e),N(!0)},children:"View Keys"}),(0,r.jsx)(eB.Z,{icon:eh.Z,onClick:()=>M(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)(e9,{visible:S,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: ",O]})]})]})})}),(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{P(!1),E(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),Z(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",j," 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===j,onClick:()=>l(j-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:j===e,onClick:()=>l(j+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},ll=e=>{var l,s,t;let{visible:a,onCancel:i,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=I.Z.useForm();console.log("Initial Data:",d),(0,n.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(),C.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){C.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)(k.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(A.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:i,children:(0,r.jsxs)(I.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(I.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)(w.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(I.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)(I.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)(k.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)(k.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(k.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)(I.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)(T.ZP,{onClick:i,className:"mr-2",children:"Cancel"}),(0,r.jsx)(T.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},ls=s(7310),lt=s.n(ls),la=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:i="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]=I.Z.useForm(),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}x(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,p.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{x(!1)}},y=(0,n.useCallback)(lt()((e,l)=>f(e,l),300),[]),Z=(e,l)=>{j(l),y(e,l)},_=(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)(A.Z,{title:i,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(I.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(I.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>Z(e,"user_email"),onSelect:(e,l)=>_(e,l),options:"user_email"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>Z(e,"user_id"),onSelect:(e,l)=>_(e,l),options:"user_id"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(I.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(k.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)(T.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},lr=e=>{let{teamId:l,accessToken:s,currentAliases:t,availableModels:a,onUpdate:i}=e,[o,d]=(0,n.useState)(!1),[c]=I.Z.useForm(),m=async e=>{try{if(!s)return;let a={...t,[e.alias_name]:e.original_model};await (0,p.Gh)(s,{team_id:l,model_aliases:a}),C.ZP.success("Model alias created successfully"),d(!1),c.resetFields(),t[e.alias_name]=e.original_model}catch(e){C.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)(S.Z,{children:"Team Aliases"}),(0,r.jsx)(w.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)(y.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)(A.Z,{title:"Create Model Alias",open:o,onCancel:()=>{d(!1),c.resetFields()},footer:null,width:500,children:(0,r.jsxs)(I.Z,{form:c,onFinish:m,layout:"vertical",className:"mt-4",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Points To",name:"original_model",rules:[{required:!0,message:"Please select a model"}],children:(0,r.jsx)(k.default,{placeholder:"Select model version",className:"w-full font-mono",showSearch:!0,optionFilterProp:"children",children:a.map(e=>(0,r.jsx)(k.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)(y.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)(y.Z,{size:"md",variant:"secondary",type:"submit",children:"Create Alias"})]})]})})]})},ln=e=>{var l,s,t;let{teamId:a,onClose:i,accessToken:o,is_team_admin:d,is_proxy_admin:c,userModels:m,editTeam:u}=e,[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)(!0),[Z,_]=(0,n.useState)(!1),[b]=I.Z.useForm(),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),[D,L]=(0,n.useState)(!1);console.log("userModels in team info",m);let z=d||c,U=async()=>{try{if(j(!0),!o)return;let e=await (0,p.Xm)(o,a);x(e)}catch(e){C.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{j(!1)}};(0,n.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,p.cu)(o,a,l),C.ZP.success("Team member added successfully"),_(!1),b.resetFields(),U()}catch(e){C.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,p.sN)(o,a,l),C.ZP.success("Team member updated successfully"),N(!1),U()}catch(e){C.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},B=async e=>{try{if(null==o)return;await (0,p.Lp)(o,a,e),C.ZP.success("Team member removed successfully"),U()}catch(e){C.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,p.Gh)(o,s),C.ZP.success("Team settings updated successfully"),L(!1),U()}catch(e){C.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(g)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:X}=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)(T.ZP,{onClick:i,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:X.team_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:X.team_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:u?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",X.spend.toFixed(6)]}),(0,r.jsxs)(w.Z,{children:["of ",null===X.max_budget?"Unlimited":"$".concat(X.max_budget)]}),X.budget_duration&&(0,r.jsxs)(w.Z,{className:"text-gray-500",children:["Reset: ",X.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",X.rpm_limit||"Unlimited"]}),X.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",X.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:X.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:h.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)(G.Z,{children:z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P(e),N(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>B(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(y.Z,{onClick:()=>_(!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)(S.Z,{children:"Team Settings"}),z&&!D&&(0,r.jsx)(y.Z,{onClick:()=>L(!0),children:"Edit Settings"})]}),D?(0,r.jsxs)(I.Z,{form:b,onFinish:K,initialValues:{...X,team_alias:X.team_alias,models:X.models,tpm_limit:X.tpm_limit,rpm_limit:X.rpm_limit,max_budget:X.max_budget,budget_duration:X.budget_duration,guardrails:(null===(l=X.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),m.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>L(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:X.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:X.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(X.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:X.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",X.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==X.max_budget?"$".concat(X.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",X.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:X.blocked?"red":"green",children:X.blocked?"Blocked":"Active"})]})]})]}),(0,r.jsx)(lr,{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)(ll,{visible:v,onCancel:()=>N(!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)(la,{isVisible:Z,onCancel:()=>_(!1),onSubmit:V,accessToken:o})]})},li=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,p.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let i=async e=>{if(l&&s)try{await (0,p.cu)(l,e,{user_id:s,role:"user"}),C.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),C.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Description"}),(0,r.jsx)(J.Z,{children:"Members"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsxs)(H.Z,{children:[t.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.team_alias})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.description||"No description available"})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{size:"xs",variant:"secondary",onClick:()=>i(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(w.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};var lo=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o,currentOrg:d}=e,[c,m]=(0,n.useState)("");(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&g(t,i,o,d,a)},[l]),(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&g(t,i,o,d,a),ek()},[c]);let[u]=I.Z.useForm(),[h]=I.Z.useForm(),{Title:x,Paragraph:S}=e_.default,[N,P]=(0,n.useState)(""),[E,L]=(0,n.useState)(!1),[z,U]=(0,n.useState)(null),[V,q]=(0,n.useState)(null),[B,K]=(0,n.useState)(!1),[X,Q]=(0,n.useState)(!1),[ee,el]=(0,n.useState)(!1),[es,et]=(0,n.useState)(!1),[em,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)(!1),[ej,ef]=(0,n.useState)(null),[ey,eZ]=(0,n.useState)({}),[eb,ev]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,p.t3)(t)).guardrails.map(e=>e.guardrail_name);ev(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let ew=async e=>{ef(e),eg(!0)},eS=async()=>{if(null!=ej&&null!=l&&null!=t){try{await (0,p.rs)(t,ej);let e=l.filter(e=>e.team_id!==ej);a(e)}catch(e){console.error("Error deleting the team:",e)}eg(!1),ef(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{let e;if(null===i||null===o||null===t||null===l)return;let s={};e="Admin"!=o&&"Admin Viewer"!=o?await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO,i):await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO);for(let l=0;l{try{if(null===i||null===o||null===t)return;let e=await D(i,o,t);e&&ex(e)}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eN=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,n=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=(null==e?void 0:e.organization_id)||(null==d?void 0:d.organization_id);if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,n.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));C.ZP.info("Creating Team");let o=await (0,p.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),C.ZP.success("Team created"),Q(!1)}}catch(e){console.error("Error creating the team:",e),C.ZP.error("Error creating the team: "+e,20)}},ek=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4",children:V?(0,r.jsx)(ln,{teamId:V,onClose:()=>{q(null),K(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===V)),is_proxy_admin:"Admin"==o,userModels:em,editTeam:B}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Teams"}),(0,r.jsx)(en.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ek})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(w.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(f.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-y-auto max-h-[50vh]",children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Team ID"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"})]})}),(0,r.jsx)(H.Z,{children:l&&l.length>0?l.filter(e=>{let l=d?d.organization_id:null;return e.organization_id===l}).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(y.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:()=>{q(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)(G.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)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(w.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,r.jsxs)(w.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,r.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,r.jsxs)(G.Z,{children:[(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].keys&&ey[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].members_with_roles&&ey[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)(G.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{q(e.team_id),K(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>ew(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),ep&&(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)(y.Z,{onClick:eS,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{eg(!1),ef(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>Q(!0),children:"+ Create New Team"}),(0,r.jsx)(A.Z,{title:"Create Team",visible:X,width:800,footer:null,onOk:()=>{Q(!1),u.resetFields()},onCancel:()=>{Q(!1),u.resetFields()},children:(0,r.jsxs)(I.Z,{form:u,onFinish:eN,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),em.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,r.jsx)(Z.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eb.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(li,{accessToken:t,userID:i})})]})]})})},ld=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:i,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(!0),[g]=I.Z.useForm(),[j,Z]=(0,n.useState)(!1),[_,b]=(0,n.useState)(!1),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),D=i||o,L=async()=>{try{if(x(!0),!a)return;let e=await (0,p.t$)(a,s);u(e)}catch(e){C.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{x(!1)}};(0,n.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,p.vh)(a,s,l),C.ZP.success("Organization member added successfully"),b(!1),g.resetFields(),L()}catch(e){C.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,p.LY)(a,s,l),C.ZP.success("Organization member updated successfully"),N(!1),g.resetFields(),L()}catch(e){C.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,p.Sb)(a,s,e.user_id),C.ZP.success("Organization member deleted successfully"),N(!1),g.resetFields(),L()}catch(e){C.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");C.ZP.success("Organization settings updated successfully"),Z(!1),L()}catch(e){C.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)(T.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:m.organization_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(w.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)(w.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Created At"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)(G.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),N(!0)}}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(y.Z,{onClick:()=>{b(!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)(S.Z,{children:"Organization Settings"}),D&&!j&&(0,r.jsx)(y.Z,{onClick:()=>Z(!0),children:"Edit Settings"})]}),j?(0,r.jsxs)(I.Z,{form:g,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)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>Z(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.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)(w.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)(w.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)(w.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)(la,{isVisible:_,onCancel:()=>b(!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)(ll,{visible:v,onCancel:()=>N(!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 lc=async(e,l)=>{l(await (0,p.r6)(e))};var lm=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:i,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,x]=(0,n.useState)(null),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(null),[P,E]=(0,n.useState)(!1),[T]=I.Z.useForm();(0,n.useEffect)(()=>{0===l.length&&a&&lc(a,m)},[l,a]);let D=e=>{e&&(N(e),v(!0))},L=async()=>{if(S&&a)try{await (0,p.cq)(a,S),C.ZP.success("Organization deleted successfully"),v(!1),N(null),lc(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,p.H1)(a,e),E(!1),T.resetFields(),lc(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(ld,{organizationId:h,onClose:()=>{x(null),_(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:g}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[i&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",i]}),(0,r.jsx)(eB.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)(w.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(f.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Organization ID"}),(0,r.jsx)(J.Z,{children:"Organization Name"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsx)(H.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,n,i,o,d,c,m;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(y.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:()=>x(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)(G.Z,{children:e.organization_alias}),(0,r.jsx)(G.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{children:e.spend}),(0,r.jsx)(G.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===(n=e.litellm_budget_table)||void 0===n?void 0:n.max_budget:"No limit"}),(0,r.jsx)(G.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["TPM: ",(null===(i=e.litellm_budget_table)||void 0===i?void 0:i.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)(G.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{x(e.organization_id),_(!0)}}),(0,r.jsx)(eB.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)(y.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Organization"}),(0,r.jsx)(A.Z,{title:"Create Organization",visible:P,width:800,footer:null,onCancel:()=>{E(!1),T.resetFields()},children:(0,r.jsxs)(I.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(y.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),b?(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{v(!1),N(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(w.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 lu=()=>{let[e,l]=(0,n.useState)("http://localhost:4000");return(0,n.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lh=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=I.Z.useForm(),[d]=I.Z.useForm(),{Title:c,Paragraph:m}=e_.default,[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(!1),[v,S]=(0,n.useState)(!1),[N,k]=(0,n.useState)(!1),[P,O]=(0,n.useState)(!1),[D,M]=(0,n.useState)(!1),[L,F]=(0,n.useState)(!1),[R,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(!1),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(null);(0,i.useRouter)();let[el,es]=(0,n.useState)(null);console.log=function(){};let et=lu(),ea="All IP Addresses Allowed",en=et;en+="/fallback/login";let ei=async()=>{try{if(!0!==a){C.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,p.PT)(s);X(e&&e.length>0?e:[ea])}else X([ea])}catch(e){console.error("Error fetching allowed IPs:",e),C.ZP.error("Failed to fetch allowed IPs ".concat(e)),X([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,p.eH)(s,e.ip);let l=await (0,p.PT)(s);X(l),C.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),C.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{ee(e),B(!0)},ec=async()=>{if(Q&&s)try{await (0,p.$I)(s,Q);let e=await (0,p.PT)(s);X(e.length>0?e:[ea]),C.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),C.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),ee(null)}},em=()=>{F(!1)};(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,p.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,p.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)),g(e),es(await (0,p.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=x){var l;C.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,p.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,p.XO)(s,a).then(e=>{Z(e),b(!0)}),console.log("response for team create call: ".concat(t));let r=x.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"),x.push(t),g(x)),o.resetFields(),k(!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,p.K_)(s,l)};return console.log("admins: ".concat(null==x?void 0:x.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)(f.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)(y.Z,{onClick:()=>!0===a?M(!0):C.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(y.Z,{onClick:ei,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(A.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{M(!1),o.resetFields()},onCancel:()=>{M(!1),o.resetFields()},children:(0,r.jsxs)(I.Z,{form:o,onFinish:e=>{eu(e),eh(e),M(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.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)(I.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(A.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)(w.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(w.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)(T.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(A.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(y.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"IP Address"}),(0,r.jsx)(J.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(H.Z,{children:K.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e}),(0,r.jsx)(G.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(y.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(A.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(I.Z,{onFinish:eo,children:[(0,r.jsx)(I.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)(I.Z.Item,{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(A.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(y.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",Q,"?"]})})]}),(0,r.jsxs)(eX.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:en,target:"_blank",children:[(0,r.jsx)("b",{children:en})," "]})]})]})]})},lx=s(92858),lp=s(44643),lg=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:n}=e,[i]=I.Z.useForm();return(0,r.jsxs)(I.Z,{form:i,onFinish:()=>{console.log("INSIDE ONFINISH");let e=i.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)($.Z,{children:[(0,r.jsxs)(G.Z,{align:"center",children:[(0,r.jsx)(w.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?n?(0,r.jsx)(I.Z.Item,{name:e.field_name,children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lx.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)(G.Z,{children:(0,r.jsx)(y.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)(I.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lx.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lj=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(0,p.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lg,{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,...n}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(n)));try{(0,p.jA)(l,"alerting_args",n),"boolean"==typeof r&&(!0==r?(0,p.jA)(l,"alerting",["slack"]):(0,p.jA)(l,"alerting",[])),C.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lf=s(86582);let{Title:ly,Paragraph:lZ}=e_.default;console.log=function(){};var l_=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,n.useState)([]),[d,c]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[h]=I.Z.useForm(),[x,g]=(0,n.useState)(null),[j,_]=(0,n.useState)([]),[b,v]=(0,n.useState)(""),[S,N]=(0,n.useState)({}),[P,O]=(0,n.useState)([]),[E,D]=(0,n.useState)(!1),[M,L]=(0,n.useState)([]),[F,R]=(0,n.useState)(null),[z,U]=(0,n.useState)([]),[V,q]=(0,n.useState)(!1),[B,K]=(0,n.useState)(null),X=e=>{P.includes(e)?O(P.filter(l=>l!==e)):O([...P,e])},Q={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,n.useEffect)(()=>{l&&s&&t&&(0,p.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),O(e.active_alerts),v(s),N(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ee=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,p.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.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,p.K_)(l,{environment_variables:s}),C.ZP.success("Callback added successfully"),u(!1),h.resetFields(),g(null)}catch(e){C.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,p.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),C.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),g(null)}catch(e){C.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),g(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(i)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(en.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(en.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(en.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(f.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(J.Z,{children:"Callback Name"})})}),(0,r.jsx)(H.Z,{children:i.map((e,s)=>(0,r.jsxs)($.Z,{className:"flex justify-between",children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.name})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(Q).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)}):(0,r.jsx)(y.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)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:S&&S[s]?S[s]:b})})]},l)})})]}),(0,r.jsx)(y.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(Q).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,p.K_)(l,s)}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lj,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Email Settings"}),(0,r.jsxs)(w.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)(G.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(f.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)(w.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)(w.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)(y.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(A.Z,{title:"Add Logging Callback",visible:E,width:800,onCancel:()=>D(!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)(I.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lf.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(k.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),em(l))},children:M&&Object.values(M).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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(A.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(I.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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lb=s(92414),lv=s(46030);let{Option:lw}=k.default;var lS=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=I.Z.useForm(),[o,d]=(0,n.useState)(!1),[c,m]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(A.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,r.jsxs)(I.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,n=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:n};console.log(o);try{(0,p.K_)(s,{router_settings:o}),a(o)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lb.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lN=s(33619);async function lk(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lN.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});C.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lI={ttl:3600,lowest_latency_buffer:0},lC=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)(b.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(w.Z,{children:"No specific settings"})})]})};var lA=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)({}),[d,c]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g]=I.Z.useForm(),[_,b]=(0,n.useState)(null),[v,N]=(0,n.useState)(null),[k,A]=(0,n.useState)(null),P={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,n.useEffect)(()=>{l&&s&&t&&((0,p.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,p.YU)(l).then(e=>{u(e)}))},[l,s,t]);let E=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks));let s=i.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...i,fallbacks:s};try{await (0,p.K_)(l,{router_settings:t}),o(t),C.ZP.success("Router settings updated successfully")}catch(e){C.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))},D=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,p.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},M=(e,s)=>{if(l)try{(0,p.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,v];if("routing_strategy_args"==l&&"latency-based-routing"==v){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,p.K_)(l,{router_settings:s})}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(ei.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)(en.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(en.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(en.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(S.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(i).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)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,r.jsx)(G.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:N,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)(lC,{selectedStrategy:v,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:lI,paramExplanation:P})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>L(i),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Model Name"}),(0,r.jsx)(J.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(H.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:t}),(0,r.jsx)(G.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{onClick:()=>lk(t,l),children:"Test Fallback"})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lS,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"}),(0,r.jsx)(J.Z,{children:"Status"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.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)(G.Z,{children:"Integer"==e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:[(0,r.jsx)(y.Z,{onClick:()=>D(e.field_name,l),children:"Update"}),(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>M(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lP=s(93142),lO=s(45246),lE=s(96473),lT=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,n.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let n=[...t];n[e]=[l,r],a(n),null==s||s(Object.fromEntries(n))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lP.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)(lO.Z,{onClick:()=>i(l)})]},l)}),(0,r.jsx)(T.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lE.Z,{}),children:"Add Header"})]})};let{Option:lD}=k.default;var lM=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=I.Z.useForm(),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(A.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(I.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,p.Vt)(l,e),s(r)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.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)(I.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)(I.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)(I.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)(lT,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lL=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&s&&t&&(0,p.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,p.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),C.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(ei.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Path"}),(0,r.jsx)(J.Z,{children:"Target"}),(0,r.jsx)(J.Z,{children:"Headers"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:i.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.path})}),(0,r.jsx)(G.Z,{children:e.target}),(0,r.jsx)(G.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lM,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lF=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[n]=I.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call");let l=await (0,p.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),C.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),n.resetFields()},onCancel:()=>{t(!1),n.resetFields()},children:(0,r.jsxs)(I.Z,{form:n,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lR=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=I.Z.useForm();(0,n.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call"),t(!0);let l=await (0,p.qI)(s,e);a(e=>e?[...e,l]:[l]),C.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(I.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},lz=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)(!1),[a,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),[c,m]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&(0,p.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),i(!0))},h=async(e,s)=>{if(null==l)return;C.ZP.info("Request made"),await (0,p.NV)(l,e);let t=[...c];t.splice(s,1),m(t),C.ZP.success("Budget Deleted.")},x=async()=>{null!=l&&(0,p.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)(y.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lF,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lR,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:x}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Budget ID"}),(0,r.jsx)(J.Z,{children:"Max Budget"}),(0,r.jsx)(J.Z,{children:"TPM"}),(0,r.jsx)(J.Z,{children:"RPM"})]})}),(0,r.jsx)(H.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)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.budget_id}),(0,r.jsx)(G.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)(G.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)(G.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(w.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(en.Z,{children:"Test it (Curl)"}),(0,r.jsx)(en.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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)'})})]})]})]})]})},lU=s(77398),lV=s.n(lU),lq=s(20016);async function lB(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 lK=e=>{let{ipAddress:l}=e,[s,t]=n.useState("-");return n.useEffect(()=>{if(!l)return;let e=!0;return lB(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},lW=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"}},lH=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:lW(l)})},lG=[{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)(lH,{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)(lK,{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:eC(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)]})})})}}],lY=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,p.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 lJ(e){var l,s,t;let{accessToken:a,token:i,userRole:o,userID:d}=e,[m,u]=(0,n.useState)(""),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1),[f,y]=(0,n.useState)(1),[Z]=(0,n.useState)(50),_=(0,n.useRef)(null),b=(0,n.useRef)(null),v=(0,n.useRef)(null),[w,S]=(0,n.useState)(lV()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[N,k]=(0,n.useState)(lV()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,n.useState)(!1),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(""),[T,D]=(0,n.useState)(""),[M,L]=(0,n.useState)(""),[F,R]=(0,n.useState)(""),[z,U]=(0,n.useState)("Team ID"),V=(0,c.NL)();(0,n.useEffect)(()=>{function e(e){_.current&&!_.current.contains(e.target)&&j(!1),b.current&&!b.current.contains(e.target)&&x(!1),v.current&&!v.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,lq.a)({queryKey:["logs","table",f,Z,w,N,M,F],queryFn:async()=>{if(!a||!i||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:Z,total_pages:0};let e=lV()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?lV()(N).utc().format("YYYY-MM-DD HH:mm:ss"):lV()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,p.h3)(a,F||void 0,M||void 0,void 0,e,l,f,Z);return await lY(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&&!!i&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!i||!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(lV()(w).format("MMM D, h:mm A")," - ").concat(lV()(N).format("MMM D, h:mm A"));let e=lV()(),l=lV()(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:b,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:()=>x(!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:()=>j(!g),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"})})]}),g&&(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),j(!1),"Team ID"===e?D(""):E("")},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?O:T,onChange:e=>{"Team ID"===z?E(e.target.value):D(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{E(""),D("")},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:()=>{E(""),D(""),x(!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(O),R(T),y(1),x(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:v,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(lV()().format("YYYY-MM-DDTHH:mm")),S(lV()().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=>{S(e.target.value),y(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:N,onChange:e=>{k(e.target.value),y(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)*Z+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*Z,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:()=>y(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:()=>y(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:lG,data:B,renderSubComponent:l$,getRowCanExpand:()=>!0})]})]})}function l$(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 lX=s(92699),lQ=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)(f.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)(w.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(en.Z,{children:"LlamaIndex"}),(0,r.jsx)(en.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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 ')})})]})]})]})})})},l0=s(243),l1=s(94263);async function l2(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lN.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var l4=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,n.useState)(i?"custom":"session"),[c,m]=(0,n.useState)(""),[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)([]),[_,b]=(0,n.useState)(void 0),[v,S]=(0,n.useState)([]),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,p.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)),S(s),b(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,n.useEffect)(()=>{N.current&&setTimeout(()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[x]);let I=(e,l,s)=>{g(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){C.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},n=[...x.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];g([...x,r]);try{_&&await l2(n,(e,l)=>I("assistant",e,l),_,e)}catch(e){console.error("Error fetching model response",e),I("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=e_.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)(f.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(en.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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"API Key Source"}),(0,r.jsx)(k.default,{disabled:i,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)(w.Z,{children:"Select Model:"}),(0,r.jsx)(k.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),b(e)},options:v,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(y.Z,{onClick:()=>{g([]),C.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(W.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{})})}),(0,r.jsxs)(H.Z,{children:[x.map((e,l)=>(0,r.jsx)($.Z,{children:(0,r.jsxs)(G.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)(l0.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...n}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,r.jsx)(e1.Z,{style:l1.Z,language:i[1],PreTag:"div",...n,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...n,children:a})}},children:e.content})})]})},l)),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{ref:N,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)(y.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},l5=s(19226),l3=s(61787),l8=s(92403),l6=s(28595),l7=s(68208),l9=s(9775),se=s(41361),sl=s(37527),ss=s(15883),st=s(12660),sa=s(88009),sr=s(48231),sn=s(41169),si=s(44625),so=s(57400),sd=s(55322);let{Sider:sc}=l5.default,sm=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],su=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(l8.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(l6.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(l7.Z,{}),roles:sm},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(l9.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(se.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(ss.Z,{}),roles:sm},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(st.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sa.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sr.Z,{}),roles:sm},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sn.Z,{}),roles:sm,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(si.Z,{}),roles:sm},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(so.Z,{}),roles:sm}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(st.Z,{}),roles:sm},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm}]}];var sh=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=su.find(l=>l.page===e);if(l)return l.key;for(let l of su)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),n=su.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(l5.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sc,{theme:"light",width:220,children:(0,r.jsx)(l3.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:n.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)}}})})})})},sx=s(96889);console.log=function(){};var sp=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,n.useState)(null!==a?a:0),[m,u]=(0,n.useState)(o?o.max_budget:null);(0,n.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(i);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,i]);let[h,x]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,p.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,n.useEffect)(()=>{null!==a&&c(a)},[a]);let g=[];o&&o.models&&(g=o.models),g&&g.includes("all-proxy-models")?(console.log("user models:",h),g=h):g&&g.includes("all-team-models")?g=o.models:g&&0===g.length&&(g=h);let j=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:["$",j]})]}),(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"})]})]})})},sg=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sj=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sf=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[b,v]=(0,n.useState)([]),[N,k]=(0,n.useState)([]),[I,C]=(0,n.useState)([]),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)([]),[T,D]=(0,n.useState)([]),[M,L]=(0,n.useState)({}),[F,R]=(0,n.useState)([]),[z,U]=(0,n.useState)(""),[V,q]=(0,n.useState)(["all-tags"]),[B,K]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[X,Q]=(0,n.useState)(null),[ee,el]=(0,n.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",i),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,p.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,n.useEffect)(()=>{ej(B.from,B.to)},[B,V]);let eg=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,p.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),_(a)},ej=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,p.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 ey=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eZ=(e,l,s,t)=>{let a=[],r=new Date(l),n=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]}},i=new Map(e.map(e=>{let l=n(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(i.has(e))a.push(i.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},e_=async()=>{if(l)try{let e=await (0,p.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=eZ(e,t,a,[]),n=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(n),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},eb=()=>ey(()=>l&&s?(0,p.OU)(l,s,eu,eh):Promise.reject("No access token or token"),D,"Error fetching provider spend"),ew=async()=>{l&&await ey(async()=>(await (0,p.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")},eS=async()=>{l&&await ey(async()=>(await (0,p.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),g,"Error fetching top models")},eN=async()=>{l&&await ey(async()=>{let e=await (0,p.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return v(eZ(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)}))},E,"Error fetching team spend")},ek=()=>{l&&ey(async()=>(await (0,p.X)(l)).tag_names,C,"Error fetching tag names")},eI=()=>{l&&ey(()=>{var e,s;return(0,p.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&&ey(()=>(0,p.b1)(l,null,void 0,void 0),_,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,p.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=eZ(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,p.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:eZ(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,n.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(Q(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",X),e_(),eb(),ew(),eS(),eA(),eP(),sj(t)&&(eN(),ek(),eI(),eC()))}})()},[l,s,t,a,eu,eh]),null==X?void 0:X.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(w.Z,{className:"mt-4",children:["SpendLogs in DB has ",X.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)(y.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(en.Z,{children:"All Up"}),sj(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(en.Z,{children:"Team Based Usage"}),(0,r.jsx)(en.Z,{children:"Customer Usage"}),(0,r.jsx)(en.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(en.Z,{children:"Cost"}),(0,r.jsx)(en.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(w.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)(sp,{userID:a,userRole:t,accessToken:l,userSpend:ee,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Monthly Spend"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top API Keys"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top Models"}),(0,r.jsx)(eW.Z,{className:"mt-4 h-40",data:x,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)(S.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sg.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Provider"}),(0,r.jsx)(J.Z,{children:"Spend"})]})}),(0,r.jsx)(H.Z,{children:T.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.provider}),(0,r.jsx)(G.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)(f.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"All Up"}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(M.sum_api_requests)]}),(0,r.jsx)(eK.Z,{className:"h-40",data:M.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(M.sum_total_tokens)]}),(0,r.jsx)(eW.Z,{className:"h-40",data:M.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)(S.Z,{children:e.model}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(eK.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eW.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)(f.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)(S.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sx.Z,{data:O})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eW.Z,{className:"h-72",data:b,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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{eg(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{eg(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(W.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Customer"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Total Events"})]})}),(0,r.jsx)(H.Z,{children:null==Z?void 0:Z.map((e,l)=>{var s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.end_user}),(0,r.jsx)(G.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)(G.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eq.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(lv.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(f.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)(S.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(w.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)(eW.Z,{className:"h-72",data:N,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sy=e=>{if(e)return e.toISOString().split("T")[0]};function sZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var s_=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,n.useState)([]),[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)("0"),[b,v]=(0,n.useState)("0"),[S,N]=(0,n.useState)("0"),[k,I]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,n.useState)(""),[O,E]=(0,n.useState)("");(0,n.useEffect)(()=>{l&&k&&((async()=>{g(await (0,p.zg)(l,sy(k.from),sy(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),D=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let M=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),g(await (0,p.zg)(l,sy(e),sy(s))))};(0,n.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",x);let e=x;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},[]);_(sZ(s)),v(sZ(t));let r=s+l;r>0?N((s/r*100).toFixed(2)):N("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,x]);let L=async()=>{try{C.ZP.info("Running cache health check..."),E("");let e=await (0,p.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),E(e)}catch(e){console.error("Error running health check:",e),E("Error running health check")}};return(0,r.jsxs)(ei.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)(en.Z,{children:"Cache Analytics"}),(0,r.jsx)(en.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)(w.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eB.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)(f.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:D.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eq.Z,{enableSelect:!0,value:k,onValueChange:e=>{I(e),M(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:[S,"%"]})})]}),(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:Z})})]}),(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:b})})]})]}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eW.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eW.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sZ,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)(w.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(y.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),O&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(O,null,2)})]})})]})]})},sb=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(async()=>{try{let e=await (0,p.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)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Guardrail Name"}),(0,r.jsx)(J.Z,{children:"Mode"}),(0,r.jsx)(J.Z,{children:"Status"})]})}),(0,r.jsx)(H.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.guardrail_name}),(0,r.jsx)(G.Z,{children:e.litellm_params.mode}),(0,r.jsx)(G.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)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};function sv(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"}}let sw=new d.S;function sS(){let[e,l]=(0,n.useState)(""),[s,t]=(0,n.useState)(!1),[a,d]=(0,n.useState)(!1),[u,h]=(0,n.useState)(null),[g,j]=(0,n.useState)(null),[f,y]=(0,n.useState)(null),[Z,_]=(0,n.useState)(m),[b,v]=(0,n.useState)([]),[w,S]=(0,n.useState)([]),[N,k]=(0,n.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[I,C]=(0,n.useState)(!0),A=(0,i.useSearchParams)(),[P,O]=(0,n.useState)({data:[]}),[E,T]=(0,n.useState)(null),D=A.get("userID"),M=A.get("invitation_id"),[L,F]=(0,n.useState)(()=>A.get("page")||"api-keys"),[R,z]=(0,n.useState)(null);return(0,n.useEffect)(()=>{T(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,n.useEffect)(()=>{if(!E)return;let e=(0,o.o)(E);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),z(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=sv(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&F("usage")}else console.log("User role not defined");e.user_email?h(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?C("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,p.K8)(e.auth_header_name)}},[E]),(0,n.useEffect)(()=>{R&&D&&e&&q(D,e,R,S)},[R,D,e]),(0,r.jsx)(n.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sw,children:M?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(x,{userID:D,userRole:e,userEmail:u,premiumUser:s,setProxySettings:k,proxySettings:N,currentOrg:Z,organizations:b,onOrgChange:s=>{if(_(s),console.log("org: ".concat(JSON.stringify(s))),s.members&&"Admin"!=e)for(let e of s.members)console.log("member: ".concat(JSON.stringify(e))),e.user_id==D&&(console.log("member.user_role: ".concat(e.user_role)),l(sv(e.user_role)));j(null)}}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sh,{setPage:e=>{let l=new URLSearchParams(A);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),F(e)},userRole:e,defaultSelectedKey:L})}),"api-keys"==L?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):"models"==L?(0,r.jsx)(e3,{userID:D,userRole:e,token:E,keys:f,accessToken:R,modelData:P,setModelData:O,premiumUser:s}):"llm-playground"==L?(0,r.jsx)(l4,{userID:D,userRole:e,token:E,accessToken:R,disabledPersonalKeyCreation:a}):"users"==L?(0,r.jsx)(le,{userID:D,userRole:e,token:E,keys:f,teams:g,accessToken:R,setKeys:y}):"teams"==L?(0,r.jsx)(lo,{teams:g,setTeams:j,searchParams:A,accessToken:R,userID:D,userRole:e,currentOrg:Z}):"organizations"==L?(0,r.jsx)(lm,{organizations:b,setOrganizations:v,userModels:w,accessToken:R,userRole:e,premiumUser:s}):"admin-panel"==L?(0,r.jsx)(lh,{setTeams:j,searchParams:A,accessToken:R,showSSOBanner:I,premiumUser:s}):"api_ref"==L?(0,r.jsx)(lQ,{proxySettings:N}):"settings"==L?(0,r.jsx)(l_,{userID:D,userRole:e,accessToken:R,premiumUser:s}):"budgets"==L?(0,r.jsx)(lz,{accessToken:R}):"guardrails"==L?(0,r.jsx)(sb,{accessToken:R}):"general-settings"==L?(0,r.jsx)(lA,{userID:D,userRole:e,accessToken:R,modelData:P}):"model-hub"==L?(0,r.jsx)(lX.Z,{accessToken:R,publicPage:!1,premiumUser:s}):"caching"==L?(0,r.jsx)(s_,{userID:D,userRole:e,token:E,accessToken:R,premiumUser:s}):"pass-through-settings"==L?(0,r.jsx)(lL,{userID:D,userRole:e,accessToken:R,modelData:P}):"logs"==L?(0,r.jsx)(lJ,{userID:D,userRole:e,token:E,accessToken:R}):(0,r.jsx)(sf,{userID:D,userRole:e,token:E,accessToken:R,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,270,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-7a5ba6fe8c2fe4b2.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.js deleted file mode 100644 index 7c4b4beb9a8..00000000000 --- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-7a5ba6fe8c2fe4b2.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,36733))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return y}});var t=s(57437),a=s(2265),r=s(99376),n=s(20831),i=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),g=s(14474),j=s(13634),f=s(73002);function y(){let[e]=j.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"),[y,Z]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,N]=(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,g.o)(s);A(s),console.log("decoded:",t),Z(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),N(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)(i.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)(n.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)(j.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",y,"token:",C,"formValues:",e),y&&C&&(e.user_email=v,S&&s&&(0,p.m_)(y,s,S,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)(j.Z.Item,{label:"Email Address",name:"user_email",children:(0,t.jsx)(u.Z,{type:"email",disabled:!0,value:v,defaultValue:v,className:"max-w-md"})}),(0,t.jsx)(j.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"})})]})]})})}},36733:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return sS}});var t,a,r=s(57437),n=s(2265),i=s(99376),o=s(14474),d=s(90946),c=s(29827);let m={organization_id:null,organization_alias:"Default Organization"};var u=s(27648),h=s(92643),x=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:n,proxySettings:i,currentOrg:o=null,onOrgChange:d=()=>{},onNewOrg:c=()=>{},organizations:x=[]}=e;console.log("currentOrg: ".concat(JSON.stringify(o))),console.log("organizations: ".concat(JSON.stringify(x)));let p=(null==i?void 0:i.PROXY_LOGOUT_URL)||"",g=[{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(a)]})]})},{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=p},children:"Logout"})}],j=[{key:"header",label:"Organizations",type:"group",style:{color:"#6B7280",fontSize:"0.875rem"}},{key:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:"Default Organization"})}),onClick:()=>d(m)},...x.filter(e=>null!==e.organization_id).map(e=>{var l;return{key:null!==(l=e.organization_id)&&void 0!==l?l:"default",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1",children:(0,r.jsx)("span",{className:"text-sm",children:e.organization_alias})}),onClick:()=>d(e)}}),{key:"note",label:(0,r.jsx)("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 text-gray-500 text-xs italic",children:(0,r.jsx)("span",{children:"Switching between organizations on the UI is currently in beta."})}),disabled:!0}];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)(u.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:"ml-8 flex items-center",children:[(0,r.jsx)(h.Z,{menu:{items:j,style:{width:"280px",padding:"4px",marginTop:"4px"}},trigger:["click"],placement:"bottomLeft",children:(0,r.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-700 hover:text-gray-900 transition-colors",children:[o?o.organization_alias:"Default Organization",(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"})})]})}),(0,r.jsx)("span",{className:"ml-2 text-[10px] bg-blue-100 text-blue-800 font-medium px-2 py-0.5 rounded",children:"BETA"})]}),(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)(h.Z,{menu:{items:g,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"})})]})})]})]})})})},p=s(19250);let g=async(e,l,s,t,a)=>{let r;r="Admin"!=s&&"Admin Viewer"!=s?await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO,l):await (0,p.It)(e,(null==t?void 0:t.organization_id)||p.lO),console.log("givenTeams: ".concat(r)),a(r)};var j=s(49804),f=s(67101),y=s(20831),Z=s(26637),_=s(87452),b=s(88829),v=s(72208),w=s(84264),S=s(96761),N=s(29233),k=s(41326),I=s(13634),C=s(41021),A=s(51369),P=s(8104),O=s(20577),E=s(56632),T=s(73002);let D=async(e,l,s)=>{try{if(null===e||null===l)return;if(null!==s){let t=(await (0,p.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},L=(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 F=s(15424),R=s(75957);let{Option:z}=k.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)=>L(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,p.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:i,data:o,setData:d}=e,[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,D]=(0,n.useState)(null),[L,B]=(0,n.useState)([]),[K,W]=(0,n.useState)([]),[H,G]=(0,n.useState)("you"),[Y,J]=(0,n.useState)(U(o)),[$,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(s),el=()=>{u(!1),c.resetFields()},es=()=>{u(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{l&&a&&i&&q(l,a,i,B)},[i,l,a]),(0,n.useEffect)(()=>{(async()=>{try{let e=(await (0,p.t3)(i)).guardrails.map(e=>e.guardrail_name);X(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[i]);let et=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",n=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===n).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(n,", please provide another key alias"));if(C.ZP.info("Making API Call"),u(!0),"you"===H&&(e.user_id=l),"service_account"===H){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,p.wX)(i,l,e);console.log("key create Response:",m),d(e=>e?[...e,m]:[m]),x(m.key),D(m.soft_budget),C.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),C.ZP.error("Error creating the key: ".concat(e))}};return(0,n.useEffect)(()=>{W(V(Q,L)),c.setFieldValue("models",[])},[Q,L]),(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,r.jsx)(A.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:el,onCancel:es,children:(0,r.jsxs)(I.Z,{form:c,onFinish:et,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Owned By",className:"mb-4",children:(0,r.jsxs)(P.ZP.Group,{onChange:e=>G(e.target.value),value:H,children:[(0,r.jsx)(P.ZP,{value:"you",children:"You"}),(0,r.jsx)(P.ZP,{value:"service_account",children:"Service Account"}),"Admin"===a&&(0,r.jsx)(P.ZP,{value:"another_user",children:"Another User"})]})}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==H,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===H,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)(I.Z.Item,{label:"you"===H||"another_user"===H?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===H?"key name":"service account ID")}],help:"you"===H?"required":"IDs can include letters, numbers, and hyphens",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"Team",name:"team_id",initialValue:s?s.team_id:null,className:"mt-8",children:(0,r.jsx)(k.default,{showSearch:!0,placeholder:"Search or select a team",onChange:e=>{c.setFieldValue("team_id",e),ee((null==t?void 0:t.find(l=>l.team_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==t?void 0:t.map(e=>(0,r.jsxs)(k.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))})}),(0,r.jsx)(I.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)(k.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"),K.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)(b.Z,{children:[(0,r.jsx)(I.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)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.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)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.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)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:$.map(e=>({value:e,label:e}))})}),(0,r.jsx)(I.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)(I.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:Y})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Key"})})]})}),h&&(0,r.jsx)(A.Z,{visible:m,onOk:el,onCancel:es,footer:null,children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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:()=>{C.ZP.success("API Key copied to clipboard")},children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,r.jsx)(w.Z,{children:"Key being created, this might take 30s"})})]})})]})},K=s(7366),W=s(21626),H=s(97214),G=s(28241),Y=s(58834),J=s(69552),$=s(71876),X=e=>{let{selectedTeam:l,currentOrg:s,accessToken:t,currentPage:a=1}=e,[r,i]=(0,n.useState)({keys:[],total_count:0,current_page:1,total_pages:0}),[o,d]=(0,n.useState)(!0),[c,m]=(0,n.useState)(null),u=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(console.log("calling fetchKeys"),!s||!t){console.log("currentOrg",s),console.log("accessToken",t);return}d(!0);let a=await (0,p.OD)(t,s.organization_id,(null==l?void 0:l.team_id)||"",e.page||1,50);console.log("data",a),i(a),m(null)}catch(e){m(e instanceof Error?e:Error("An error occurred"))}finally{d(!1)}};return(0,n.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}},Q=s(71594),ee=s(24525);function el(e){let{data:l=[],columns:s,getRowCanExpand:t,renderSubComponent:a,isLoading:i=!1}=e,o=(0,Q.b7)({data:l,columns:s,getRowCanExpand:t,getCoreRowModel:(0,ee.sC)(),getExpandedRowModel:(0,ee.rV)()});return(0,r.jsx)("div",{className:"rounded-lg custom-border",children:(0,r.jsxs)(W.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(Y.Z,{children:o.getHeaderGroups().map(e=>(0,r.jsx)($.Z,{children:e.headers.map(e=>(0,r.jsx)(J.Z,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,Q.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,r.jsx)(H.Z,{children:i?(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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)(n.Fragment,{children:[(0,r.jsx)($.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)(G.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,Q.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),e.getIsExpanded()&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:e.getVisibleCells().length,children:a({row:e})})})]},e.id)):(0,r.jsx)($.Z,{children:(0,r.jsx)(G.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),en=s(12485),ei=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:i,teams:o,accessToken:d,userID:c,userRole:m}=e,[u]=I.Z.useForm(),[h,x]=(0,n.useState)([]),g=V(null==o?void 0:o.find(e=>e.team_id===t.team_id),h);(0,n.useEffect)(()=>{(async()=>{try{if(d&&c&&m){let e=(await (0,p.So)(d,c,m)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[]);let j={...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)(I.Z,{form:u,onFinish:i,initialValues:j,layout:"vertical",children:[(0,r.jsx)(I.Z.Item,{label:"Key Alias",name:"key_alias",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[g.length>0&&(0,r.jsx)(k.default.Option,{value:"all-team-models",children:"All Team Models"}),g.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:e},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"daily",children:"Daily"}),(0,r.jsx)(k.default.Option,{value:"weekly",children:"Weekly"}),(0,r.jsx)(k.default.Option,{value:"monthly",children:"Monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"TPM Limit",name:"tpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"RPM Limit",name:"rpm_limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Guardrails",name:"guardrails",children:(0,r.jsx)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails"})}),(0,r.jsx)(I.Z.Item,{label:"Metadata",name:"metadata",children:(0,r.jsx)(E.Z.TextArea,{rows:10})}),(0,r.jsx)(I.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)(y.Z,{variant:"light",onClick:a,children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]})}function ep(e){let{selectedToken:l,visible:s,onClose:t,accessToken:a,onSuccess:i}=e,[o]=I.Z.useForm(),[d,c]=(0,n.useState)(null),[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(null);(0,n.useEffect)(()=>{s&&l&&o.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,o]),(0,n.useEffect)(()=>{(null==m?void 0:m.duration)?x((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}})(m.duration)):x(null)},[null==m?void 0:m.duration]);let g=async()=>{if(l&&a)try{let e=await o.validateFields(),s=await (0,p.s0)(a,l.token,e);c(s.key),i&&i({...l,key_name:s.key_name,...e}),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}},_=()=>{c(null),o.resetFields(),t()};return(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:s,onCancel:_,footer:d?[(0,r.jsx)(y.Z,{onClick:_,children:"Close"},"close")]:[(0,r.jsx)(y.Z,{onClick:_,className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:g,children:"Regenerate"},"regenerate")],children:d?(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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)(w.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:d})}),(0,r.jsx)(N.CopyToClipboard,{text:d,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]}):(0,r.jsxs)(I.Z,{form:o,layout:"vertical",onValuesChange:e=>{"duration"in e&&u(l=>({...l,duration:e.duration}))},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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"]}),h&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",h]})]})})}function eg(e){let{keyId:l,onClose:s,keyData:t,accessToken:a,userID:i,userRole:o,teams:d}=e,[c,m]=(0,n.useState)(!1),[u]=I.Z.useForm(),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1);if(!t)return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(w.Z,{children:"Key not found"})]});let Z=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),C.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,p.Nc)(a,e),C.ZP.success("Key updated successfully"),m(!1)}catch(e){C.ZP.error("Failed to update key"),console.error("Error updating key:",e)}},_=async()=>{try{if(!a)return;await (0,p.I1)(a,t.token),C.ZP.success("Key deleted successfully"),s()}catch(e){console.error("Error deleting the key:",e),C.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)(y.Z,{icon:em.Z,variant:"light",onClick:s,className:"mb-4",children:"Back to Keys"}),(0,r.jsx)(S.Z,{children:t.key_alias||"API Key"}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:t.token})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(y.Z,{icon:eu.Z,variant:"secondary",onClick:()=>j(!0),className:"flex items-center",children:"Regenerate Key"}),(0,r.jsx)(y.Z,{icon:eh.Z,variant:"secondary",onClick:()=>x(!0),className:"flex items-center",children:"Delete Key"})]})]}),(0,r.jsx)(ep,{selectedToken:t,visible:g,onClose:()=>j(!1),accessToken:a,onSuccess:e=>{j(!1)}}),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)(y.Z,{onClick:_,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>x(!1),children:"Cancel"})]})]})]})}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Spend"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",Number(t.spend).toFixed(4)]}),(0,r.jsxs)(w.Z,{children:["of ",null!==t.max_budget?"$".concat(t.max_budget):"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(w.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)(S.Z,{children:"Key Settings"}),!c&&(0,r.jsx)(y.Z,{variant:"light",onClick:()=>m(!0),children:"Edit Settings"})]}),c?(0,r.jsx)(ex,{keyData:t,onCancel:()=>m(!1),onSubmit:Z,teams:d,accessToken:a,userID:i,userRole:o}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key ID"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.token})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Key Alias"}),(0,r.jsx)(w.Z,{children:t.key_alias||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Secret Key"}),(0,r.jsx)(w.Z,{className:"font-mono",children:t.key_name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)(w.Z,{children:t.team_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization"}),(0,r.jsx)(w.Z,{children:t.organization_id||"Not Set"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created"}),(0,r.jsx)(w.Z,{children:new Date(t.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Expires"}),(0,r.jsx)(w.Z,{children:t.expires?new Date(t.expires).toLocaleString():"Never"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Spend"}),(0,r.jsxs)(w.Z,{children:["$",Number(t.spend).toFixed(4)," USD"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsx)(w.Z,{children:null!==t.max_budget?"$".concat(t.max_budget," USD"):"Unlimited"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.Z,{children:"No models specified"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)(w.Z,{children:["TPM: ",null!==t.tpm_limit?t.tpm_limit:"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",null!==t.rpm_limit?t.rpm_limit:"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)})]})]})]})})]})]})]})}let ej=e=>{let{teams:l,selectedTeam:s,setSelectedTeam:t}=e;return(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-600",children:"Where Team is"}),(0,r.jsxs)(es.Z,{value:(null==s?void 0:s.team_id)||"",onValueChange:e=>{t((null==l?void 0:l.find(l=>l.team_id===e))||null)},placeholder:"Team ID",className:"w-[400px]",children:[(0,r.jsx)(et.Z,{value:"team_id",children:"Team ID"}),null==l?void 0:l.map(e=>(0,r.jsxs)(et.Z,{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))]})]})})};function ef(e){let{keys:l,isLoading:s=!1,pagination:t,onPageChange:a,pageSize:i=50,teams:o,selectedTeam:d,setSelectedTeam:c,accessToken:m,userID:u,userRole:h}=e,[x,p]=(0,n.useState)(null),g=[{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)(y.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.getValue()),children:e.getValue()?"".concat(e.getValue().slice(0,7),"..."):"Not Set"})})})},{header:"Organization",accessorKey:"organization_id",cell:e=>e.getValue()?e.renderValue():"Not Set"},{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:"Secret Key",accessorKey:"key_name",cell:e=>(0,r.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{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:x?(0,r.jsx)(eg,{keyId:x,onClose:()=>p(null),keyData:l.find(e=>e.token===x),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",children:[(0,r.jsx)(ej,{teams:o,selectedTeam:d,setSelectedTeam:c}),(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)*i+1," - ").concat(Math.min(t.currentPage*i,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:g.filter(e=>"expander"!==e.id),data:l,isLoading:s,getRowCanExpand:()=>!1,renderSubComponent:()=>(0,r.jsx)(r.Fragment,{})})})]})})}console.log=function(){};var ey=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,setSelectedTeam:i,data:o,setData:d,teams:c,premiumUser:m,currentOrg:u}=e,[h,x]=(0,n.useState)(!1),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),[k,P]=(0,n.useState)(null),[E,T]=(0,n.useState)(null),[M,L]=(0,n.useState)((null==a?void 0:a.team_id)||""),[F,R]=(0,n.useState)("");(0,n.useEffect)(()=>{L((null==a?void 0:a.team_id)||"")},[a]),(0,n.useMemo)(()=>{let e={};return M&&(e.team_id=M),F&&(e.key_alias=F),e},[M,F]);let{keys:z,isLoading:U,error:V,pagination:q,refresh:B}=X({selectedTeam:a,currentOrg:u,accessToken:t}),[W,H]=(0,n.useState)(!1),[G,Y]=(0,n.useState)(!1),[J,$]=(0,n.useState)(null),[Q,ee]=(0,n.useState)([]),el=new Set,[es,et]=(0,n.useState)(!1),[ea,er]=(0,n.useState)(!1),[en,ei]=(0,n.useState)(null),[eo,ed]=(0,n.useState)(null),[ec]=I.Z.useForm(),[em,eu]=(0,n.useState)(null),[eh,ex]=(0,n.useState)(el),[ep,eg]=(0,n.useState)([]);(0,n.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",J),(null==eo?void 0:eo.duration)?eu((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}})(eo.duration)):eu(null),console.log("calculateNewExpiryTime:",em)},[J,null==eo?void 0:eo.duration]),(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s||null===t)return;let e=await D(l,s,t);e&&ee(e)}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,s)=>{let t=l.team_id;e.add(t)}),ex(e)}},[c]);let ej=async()=>{if(null!=b&&null!=o){try{await (0,p.I1)(t,b);let e=o.filter(e=>e.token!==b);d(e)}catch(e){console.error("Error deleting the key:",e)}_(!1),v(null)}},ey=(e,l)=>{ed(s=>({...s,[e]:l}))},eZ=async()=>{if(!m){C.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=J)try{let e=await ec.validateFields(),l=await (0,p.s0)(t,J.token,e);if(ei(l.key),o){let s=o.map(s=>s.token===(null==J?void 0:J.token)?{...s,key_name:l.key_name,...e}:s);d(s)}er(!1),ec.resetFields(),C.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),C.ZP.error("Failed to regenerate API Key")}};return Array.from(new Set(z.map(e=>e.key_alias?e.key_alias:"Not Set"))),(0,r.jsxs)("div",{children:[(0,r.jsx)(ef,{keys:z,isLoading:U,pagination:q,onPageChange:e=>{B({page:e})},pageSize:50,teams:c,selectedTeam:a,setSelectedTeam:i,accessToken:t,userID:l,userRole:s}),g&&(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)(y.Z,{onClick:ej,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{_(!1),v(null)},children:"Cancel"})]})]})]})}),(0,r.jsx)(A.Z,{title:"Regenerate API Key",visible:ea,onCancel:()=>{er(!1),ec.resetFields()},footer:[(0,r.jsx)(y.Z,{onClick:()=>{er(!1),ec.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,r.jsx)(y.Z,{onClick:eZ,disabled:!m,children:m?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:m?(0,r.jsxs)(I.Z,{form:ec,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&ey("duration",e.duration)},children:[(0,r.jsx)(I.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,r.jsx)(Z.Z,{disabled:!0})}),(0,r.jsx)(I.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,r.jsx)(O.Z,{style:{width:"100%"}})}),(0,r.jsx)(I.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==J?void 0:J.expires)!=null?new Date(J.expires).toLocaleString():"Never"]}),em&&(0,r.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",em]})]}):(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)(y.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"})})]})}),en&&(0,r.jsx)(A.Z,{visible:!!en,onCancel:()=>ei(null),footer:[(0,r.jsx)(y.Z,{onClick:()=>ei(null),children:"Close"},"close")],children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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)(w.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==J?void 0:J.key_alias)||"No alias set"})}),(0,r.jsx)(w.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:en})}),(0,r.jsx)(N.CopyToClipboard,{text:en,onCopy:()=>C.ZP.success("API Key copied to clipboard"),children:(0,r.jsx)(y.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})},eZ=s(12011),e_=s(68060);console.log=function(){},console.log("isLocal:",!1);var eb=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:d,userEmail:c,setUserEmail:m,setTeams:u,setKeys:h,setOrganizations:x,premiumUser:y,currentOrg:Z}=e;console.log("currentOrg in user dashboard: ".concat(JSON.stringify(Z)));let[_,b]=(0,n.useState)(null),v=(0,i.useSearchParams)(),w=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=v.get("invitation_id"),[N,k]=(0,n.useState)(null),[I,C]=(0,n.useState)(null),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)(null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(w){let e=(0,o.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),k(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&&N&&s&&!a&&!_){let e=sessionStorage.getItem("userModels"+l);if(e)P(JSON.parse(e));else{console.log("currentOrg: ".concat(JSON.stringify(Z)));let e=async()=>{x(await (0,p.r6)(N))};(async()=>{try{let e=await (0,p.g)(N);E(e);let t=await (0,p.Br)(N,l,s,!1,null,null);b(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,p.So)(N,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),P(a),console.log("userModels:",A),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})(),g(N,l,s,Z,u),e()}}},[l,w,N,a,s]),(0,n.useEffect)(()=>{console.log("currentOrg: ".concat(JSON.stringify(Z),", accessToken: ").concat(N,", userID: ").concat(l,", userRole: ").concat(s)),N&&(console.log("fetching teams"),g(N,l,s,Z,u))},[Z]),(0,n.useEffect)(()=>{if(null!==a&&null!=T&&null!==T.team_id){let e=0;for(let l of(console.log("keys: ".concat(JSON.stringify(a))),a))T.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===T.team_id&&(e+=l.spend);console.log("sum: ".concat(e)),C(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;C(e)}},[T]),null!=S)return(0,r.jsx)(eZ.default,{});if(null==l||null==w){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==N)return null;if(null==s&&d("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=e_.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",T),(0,r.jsx)("div",{className:"w-full mx-4 overflow-hidden h-[75vh]",children:(0,r.jsx)(f.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:T,teams:t,userRole:s,accessToken:N,data:a,setData:h},T?T.team_id:null),(0,r.jsx)(ey,{userID:l,userRole:s,accessToken:N,selectedTeam:T||null,setSelectedTeam:D,data:a,setData:h,premiumUser:y,teams:t,currentOrg:Z})]})})})},ev=s(97765),ew=s(47451),eS=s(69410),eN=()=>{let e=I.Z.useFormInstance();return(I.Z.useWatch("model",e)||[]).includes("all-wildcard")?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",required:!1,className:"mb-0",rules:[e=>{let{getFieldValue:l}=e;return{validator:(e,s)=>!(l("model")||[]).includes("all-wildcard")||s?Promise.resolve():Promise.reject(Error('Public Model Name is required unless "All Models" is selected.'))}}],children:(0,r.jsx)(Z.Z,{placeholder:"my-gpt-4"})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-2",children:"Model name your users will pass in."})})]})]})};(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 ek={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"},eI={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"},eC=e=>{if(!e)return{logo:"",displayName:"-"};let l=Object.keys(ek).find(l=>ek[l].toLowerCase()===e.toLowerCase());if(!l)return{logo:"",displayName:e};let s=a[l];return{logo:eI[s],displayName:s}},eA=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",eP=(e,l)=>{console.log("Provider key: ".concat(e));let s=ek[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};var eO=e=>{let{selectedProvider:l,providerModels:s,getPlaceholder:t}=e,n=I.Z.useFormInstance();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(I.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)(I.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.toString())}):s.length>0?(0,r.jsx)(k.default,{allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{e.includes("all-wildcard")&&n.setFieldsValue({model_name:void 0})},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.toString())})}),(0,r.jsx)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.Z,{className:"mb-3 mt-1",children:"Actual model name used for making litellm.completion() call. We loadbalance models with the same public name"})})]})]})},eE=s(63709),eT=s(90464);let{Link:eD}=e_.default;var eM=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:s}=e,[t]=I.Z.useForm(),[a,i]=n.useState(!1),[o,d]=n.useState("per_token"),c=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve(),m=(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)(b.Z,{children:(0,r.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,r.jsx)(I.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,r.jsx)(eE.Z,{onChange:e=>{i(e),e||t.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),a&&(0,r.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,r.jsx)(I.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:"per_token",onChange:e=>d(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}):(0,r.jsx)(I.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:c}],className:"mb-4",children:(0,r.jsx)(Z.Z,{})})]}),(0,r.jsx)(I.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)(eD,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,r.jsx)(eE.Z,{onChange:e=>{let l=t.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?t.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):t.setFieldValue("litellm_extra_params","")}catch(l){e?t.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):t.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,r.jsxs)(ew.Z,{className:"mb-4",children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,r.jsx)(eD,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,r.jsx)(I.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:m}],children:(0,r.jsx)(eT.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})},eL=s(18502),eF=s(3632);let{Link:eR}=e_.default;var ez=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)(I.Z.Item,{label:"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)(I.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)(I.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,r.jsx)(eL.Z,{...s,children:(0,r.jsx)(T.ZP,{icon:(0,r.jsx)(eF.Z,{}),children:"Click to Upload"})})}),(0,r.jsxs)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsx)(w.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)(I.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,r.jsxs)(k.default,{placeholder:"Select API Base",children:[(0,r.jsx)(k.default.Option,{value:"https://api.assemblyai.com",children:"https://api.assemblyai.com"}),(0,r.jsx)(k.default.Option,{value:"https://api.eu.assemblyai.com",children:"https://api.eu.assemblyai.com"})]})}),(t===a.Azure||t===a.OpenAI_Compatible)&&(0,r.jsx)(I.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)(I.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)(I.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)(ew.Z,{children:[(0,r.jsx)(eS.Z,{span:10}),(0,r.jsx)(eS.Z,{span:10,children:(0,r.jsxs)(w.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,r.jsx)(eR,{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)(I.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)(I.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)(I.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)(I.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"})})]})};let eU=async(e,l,s,t)=>{try{if(console.log("handling submit for formValues:",e),e.model&&e.model.includes("all-wildcard")){let l=ek[e.custom_llm_provider]+"/*";e.model_name=l,e.model=l}let a=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(a)),console.log("received type of deployments: ".concat(typeof a)),a.forEach(async s=>{console.log("litellm_model: ".concat(s));let a={},r={};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),a.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s&&"custom_pricing"!==l&&"pricing_model"!==l){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=ek[s];a.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)r[l]=s;else if("custom_model_name"===l)a.model=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw C.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))r[l]=s}}else if("input_cost_per_token"===l||"output_cost_per_token"===l||"input_cost_per_second"===l){s&&(a[l]=Number(s));continue}else a[l]=s}let i={model_name:n,litellm_params:a,model_info:r},o=await (0,p.kK)(l,i);t&&t(),console.log("response for model create call: ".concat(o.data))}),s.resetFields()}catch(e){C.ZP.error("Failed to create model: "+e,10)}};var eV=e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[n]=I.Z.useForm(),i={},o="",d="";if(t){var c,m;i={...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)),i.model_id=d)}return(0,r.jsx)(A.Z,{title:"Edit '"+o+"' LiteLLM Params",visible:l,width:800,footer:null,onOk:()=>{n.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}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,r.jsxs)(I.Z,{form:n,onFinish:a,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"api_key",name:"api_key",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"custom_llm_provider",name:"custom_llm_provider",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"model",name:"model",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"max_retries",name:"max_retries",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,r.jsx)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},eq=s(53003),eB=s(47323),eK=s(75105),eW=s(40278),eH=s(14301),eG=s(15731),eY=s(53410),eJ=s(2356),e$=e=>{let{modelID:l,accessToken:s,callback:t}=e,[a,i]=(0,n.useState)(!1),o=async()=>{try{C.ZP.info("Making API Call"),i(!0);let e=await (0,p.Og)(s,l);console.log("model delete Response:",e),C.ZP.success("Model ".concat(l," deleted successfully")),i(!1),t&&setTimeout(t,4e3)}catch(e){console.error("Error deleting the model:",e)}};return(0,r.jsxs)("div",{children:[(0,r.jsx)(eB.Z,{onClick:()=>i(!0),icon:eh.Z,size:"sm"}),(0,r.jsx)(A.Z,{open:a,onOk:o,okType:"danger",onCancel:()=>i(!1),children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full",children:[(0,r.jsx)(S.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})]})})]})})]})},eX=s(94789),eQ=s(59664),e0=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,r.jsx)(eQ.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)(eX.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)(y.Z,{variant:"primary",children:(0,r.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},e1=s(17906);let{Title:e2,Link:e4}=e_.default,e5={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var e3=e=>{let{accessToken:l,token:s,userRole:t,userID:i,modelData:o={data:[]},keys:d,setModelData:c,premiumUser:m}=e,[u,h]=(0,n.useState)([]),[x]=I.Z.useForm(),[g,j]=(0,n.useState)(null),[Z,_]=(0,n.useState)(""),[b,v]=(0,n.useState)([]);Object.values(a).filter(e=>isNaN(Number(e)));let[N,P]=(0,n.useState)([]),[E,D]=(0,n.useState)(a.OpenAI),[M,L]=(0,n.useState)(""),[F,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(null),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)([]),[el,em]=(0,n.useState)(null),[eh,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)([]),[ej,ef]=(0,n.useState)([]),[ey,eZ]=(0,n.useState)([]),[eb,ew]=(0,n.useState)([]),[eE,eT]=(0,n.useState)([]),[eD,eL]=(0,n.useState)([]),[eF,eR]=(0,n.useState)([]),[eX,eQ]=(0,n.useState)([]),[e4,e3]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e8,e6]=(0,n.useState)(null),[e7,e9]=(0,n.useState)(0),[le,ll]=(0,n.useState)({}),[ls,lt]=(0,n.useState)([]),[la,lr]=(0,n.useState)(!1),[ln,li]=(0,n.useState)(null),[lo,ld]=(0,n.useState)(null),[lc,lm]=(0,n.useState)([]),[lu,lh]=(0,n.useState)(!1),lx=e=>{let l=eP(e,g);v(l),console.log("providerModels: ".concat(l))},lp=async(e,s,a)=>{if(console.log("Updating model metrics for group:",e),!l||!i||!t||!s||!a)return;console.log("inside updateModelMetrics - startTime:",s,"endTime:",a),em(e);let r=null==ln?void 0:ln.token;void 0===r&&(r=null);let n=lo;void 0===n&&(n=null),s.setHours(0),s.setMinutes(0),s.setSeconds(0),a.setHours(23),a.setMinutes(59),a.setSeconds(59);try{let o=await (0,p.o6)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model metrics response:",o),eg(o.data),ef(o.all_api_bases);let d=await (0,p.Rg)(l,e,s.toISOString(),a.toISOString());eZ(d.data),ew(d.all_api_bases);let c=await (0,p.N8)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);console.log("Model exceptions response:",c),eT(c.data),eL(c.exception_types);let m=await (0,p.fP)(l,i,t,e,s.toISOString(),a.toISOString(),r,n);if(console.log("slowResponses:",m),eQ(m),e){let t=await (0,p.n$)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);ll(t);let r=await (0,p.v9)(l,null==s?void 0:s.toISOString().split("T")[0],null==a?void 0:a.toISOString().split("T")[0],e);lt(r)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,n.useEffect)(()=>{lp(el,e4.from,e4.to)},[ln,lo]);let lg=e=>{B(e),z(!0)},lj=e=>{B(e),V(!0)},lf=async e=>{if(console.log("handleEditSubmit:",e),null==l)return;let s={},t=null;for(let[l,a]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?s[l]=""===a?null:a:t=""===a?null:a;let a={litellm_params:Object.keys(s).length>0?s:void 0,model_info:void 0!==t?{id:t}:void 0};console.log("handleEditSubmit payload:",a);try{await (0,p.um)(l,a),C.ZP.success("Model updated successfully, restart server to see updates"),z(!1),B(null)}catch(e){console.log("Error occurred")}},ly=()=>{_(new Date().toLocaleString())},lZ=async()=>{if(!l){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e8);try{await (0,p.K_)(l,{router_settings:{model_group_retry_policy:e8}}),C.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),C.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!l||!s||!t||!i)return;let e=async()=>{try{var e,s,a,r,n,o,d,m,u,h,x,g;let j=await (0,p.hy)(l);P(j);let f=await (0,p.AZ)(l,i,t);console.log("Model data response:",f.data),c(f);let y=new Set;for(let e=0;e0&&(_=Z[Z.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",el);let b=await (0,p.o6)(l,i,t,_,null===(e=e4.from)||void 0===e?void 0:e.toISOString(),null===(s=e4.to)||void 0===s?void 0:s.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model metrics response:",b),eg(b.data),ef(b.all_api_bases);let v=await (0,p.Rg)(l,_,null===(a=e4.from)||void 0===a?void 0:a.toISOString(),null===(r=e4.to)||void 0===r?void 0:r.toISOString());eZ(v.data),ew(v.all_api_bases);let w=await (0,p.N8)(l,i,t,_,null===(n=e4.from)||void 0===n?void 0:n.toISOString(),null===(o=e4.to)||void 0===o?void 0:o.toISOString(),null==ln?void 0:ln.token,lo);console.log("Model exceptions response:",w),eT(w.data),eL(w.exception_types);let S=await (0,p.fP)(l,i,t,_,null===(d=e4.from)||void 0===d?void 0:d.toISOString(),null===(m=e4.to)||void 0===m?void 0:m.toISOString(),null==ln?void 0:ln.token,lo),N=await (0,p.n$)(l,null===(u=e4.from)||void 0===u?void 0:u.toISOString().split("T")[0],null===(h=e4.to)||void 0===h?void 0:h.toISOString().split("T")[0],_);ll(N);let k=await (0,p.v9)(l,null===(x=e4.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(g=e4.to)||void 0===g?void 0:g.toISOString().split("T")[0],_);lt(k),console.log("dailyExceptions:",N),console.log("dailyExceptionsPerDeplyment:",k),console.log("slowResponses:",S),eQ(S);let I=await (0,p.j2)(l);lm(null==I?void 0:I.end_users);let C=(await (0,p.BL)(l,i,t)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,O=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",O),e6(A),e9(O)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&t&&i&&e();let a=async()=>{let e=await (0,p.qm)(l);console.log("received model cost map data: ".concat(Object.keys(e))),j(e)};null==g&&a(),ly()},[l,s,t,i,g,Z]),!o||!l||!s||!t||!i)return(0,r.jsx)("div",{children:"Loading..."});let l_=[],lb=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(g)),null!=g&&"object"==typeof g&&e in g)?g[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&&(n=null==a?void 0:a.input_cost_per_token,i=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=n,o.data[e].output_cost=i,o.data[e].litellm_model_name=s,lb.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===(lS=l.litellm_params)||void 0===lS?void 0:lS.api_base,o.data[e].cleanedLitellmParams=m,l_.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}=e_.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 lN=async()=>{try{C.ZP.info("Running health check..."),L("");let e=await (0,p.EY)(l);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lk=(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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:()=>{li(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:()=>{li(e)},children:e.key_alias},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>{ld(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:()=>{li(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:()=>{li(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,r.jsx)(w.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:()=>{ld(null)},children:"All Customers"},"all-customers"),null==lc?void 0:lc.map((e,l)=>(0,r.jsxs)(et.Z,{value:e,disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lI=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let n=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.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:[n&&(0,r.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),i.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(b.length));let lC=Object.keys(a).find(e=>a[e]===E);return lC&&N.find(e=>e.name===ek[lC]),(0,r.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,r.jsxs)(ei.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)(en.Z,{children:"All Models"}),(0,r.jsx)(en.Z,{children:"Add Model"}),(0,r.jsx)(en.Z,{children:(0,r.jsx)("pre",{children:"/health Models"})}),(0,r.jsx)(en.Z,{children:"Model Analytics"}),(0,r.jsx)(en.Z,{children:"Model Retry Settings"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[Z&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",Z]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ly})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsxs)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||void 0,onValueChange:e=>em("all"===e?"all":e),value:el||void 0,children:[(0,r.jsx)(et.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))]})]}),(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,r.jsx)(J.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===t&&(0,r.jsx)(J.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,r.jsxs)(J.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)(J.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)(J.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)(J.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)(J.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:o.data.filter(e=>"all"===el||e.model_name===el||null==el||""===el).map((e,s)=>{var a;return(0,r.jsxs)($.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,r.jsx)(G.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,r.jsx)(G.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:eC(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)(G.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)(G.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)(G.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)(G.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)(G.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)(G.Z,{children:(0,r.jsx)("p",{className:"text-xs",children:m&&e.model_info.created_by||"-"})}),(0,r.jsx)(G.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)(G.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,r.jsxs)(f.Z,{numItems:3,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eG.Z,size:"sm",onClick:()=>lj(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>lg(e)})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(e$,{modelID:e.model_info.id,accessToken:l,callback:ly})})]})})]},s)})})]})})]}),(0,r.jsx)(eV,{visible:F,onCancel:()=>{z(!1),B(null)},model:q,onSubmit:lf}),(0,r.jsxs)(A.Z,{title:q&&q.model_name,visible:U,width:800,footer:null,onCancel:()=>{V(!1),B(null)},children:[(0,r.jsx)(S.Z,{children:"Model Info"}),(0,r.jsx)(e1.Z,{language:"json",children:q&&JSON.stringify(q,null,2)})]})]}),(0,r.jsxs)(ed.Z,{className:"h-full",children:[(0,r.jsx)(e2,{level:2,children:"Add new model"}),(0,r.jsx)(er.Z,{children:(0,r.jsx)(I.Z,{form:x,onFinish:()=>{x.validateFields().then(e=>{eU(e,l,x,ly)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(k.default,{showSearch:!0,value:E,onChange:e=>{D(e),lx(e),x.setFieldsValue({model:[],model_name:void 0})},children:Object.entries(a).map(e=>{let[l,s]=e;return(0,r.jsx)(k.default.Option,{value:l,children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:eI[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)(eO,{selectedProvider:E,providerModels:b,getPlaceholder:eA}),(0,r.jsx)(eN,{}),(0,r.jsx)(ez,{selectedProvider:E,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;x.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?C.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&C.ZP.error("".concat(e.file.name," file upload failed."))}}}),(0,r.jsx)(eM,{showAdvancedSettings:lu,setShowAdvancedSettings:lh}),(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)(e_.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Model"})]})]})})})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,r.jsx)(y.Z,{onClick:lN,children:"Run `/health`"}),M&&(0,r.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:e4,className:"mr-2",onValueChange:e=>{e3(e),lp(el,e.from,e.to)}})]}),(0,r.jsxs)(eS.Z,{className:"ml-2",children:[(0,r.jsx)(w.Z,{children:"Select Model Group"}),(0,r.jsx)(es.Z,{defaultValue:el||K[0],value:el||K[0],children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>lp(e,e4.from,e4.to),children:e},l))})]}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(eH.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,r.jsx)(y.Z,{icon:eJ.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Avg. Latency per Token"}),(0,r.jsx)(en.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)(w.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ep&&ej&&(0,r.jsx)(eK.Z,{title:"Model Latency",className:"h-72",data:ep,showLegend:!1,index:"date",categories:ej,connectNulls:!0,customTooltip:lI})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e0,{modelMetrics:ey,modelMetricsCategories:eb,customTooltip:lI,premiumUser:m})})]})]})})}),(0,r.jsx)(eS.Z,{children:(0,r.jsx)(er.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Deployment"}),(0,r.jsx)(J.Z,{children:"Success Responses"}),(0,r.jsxs)(J.Z,{children:["Slow Responses ",(0,r.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,r.jsx)(H.Z,{children:eX.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.api_base}),(0,r.jsx)(G.Z,{children:e.total_count}),(0,r.jsx)(G.Z,{children:e.slow_count})]},l))})]})})})]}),(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Exceptions for ",el]}),(0,r.jsx)(eW.Z,{className:"h-60",data:eE,index:"model",categories:eD,stack:!0,yAxisWidth:30})]})}),(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(S.Z,{children:["All Up Rate Limit Errors (429) for ",el]}),(0,r.jsxs)(f.Z,{numItems:1,children:[(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",le.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.Z,{className:"h-40",data:le.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,r.jsx)(eS.Z,{})]})]}),m?(0,r.jsx)(r.Fragment,{children:ls.map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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:ls&&ls.length>0&&ls.slice(0,1).map((e,l)=>(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.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)(y.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)(S.Z,{children:e.api_base}),(0,r.jsx)(f.Z,{numItems:1,children:(0,r.jsxs)(eS.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,r.jsx)(eW.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)(w.Z,{children:"Filter by Public Model Name"}),(0,r.jsx)(es.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:el||K[0],value:el||K[0],onValueChange:e=>em(e),children:K.map((e,l)=>(0,r.jsx)(et.Z,{value:e,onClick:()=>em(e),children:e},l))})]}),(0,r.jsxs)(S.Z,{children:["Retry Policy for ",el]}),(0,r.jsx)(w.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),e5&&(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:Object.entries(e5).map((e,l)=>{var s;let[t,a]=e,n=null==e8?void 0:null===(s=e8[el])||void 0===s?void 0:s[a];return null==n&&(n=e7),(0,r.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("td",{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)("td",{children:(0,r.jsx)(O.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{e6(l=>{var s;let t=null!==(s=null==l?void 0:l[el])&&void 0!==s?s:{};return{...null!=l?l:{},[el]:{...t,[a]:e}}})}})})]},l)})})}),(0,r.jsx)(y.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})};function e8(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:n,Paragraph:i}=e_.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)(A.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,r.jsx)(i,{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)(w.Z,{className:"text-base",children:"User ID"}),(0,r.jsx)(w.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)(w.Z,{children:"Invitation Link"}),(0,r.jsx)(w.Z,{children:(0,r.jsx)(w.Z,{children:o()})})]}),(0,r.jsx)("div",{className:"flex justify-end mt-5",children:(0,r.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>C.ZP.success("Copied!"),children:(0,r.jsx)(y.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:e6}=k.default;var e7=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,n.useState)(null),[c]=I.Z.useForm(),[m,u]=(0,n.useState)(!1),[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)([]),[f,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(null),S=(0,i.useRouter)(),[N,P]=(0,n.useState)("http://localhost:4000");(0,n.useEffect)(()=>{(async()=>{try{let e=await (0,p.So)(s,l,"any"),t=[];for(let l=0;l{S&&P(new URL("/",window.location.href).toString())},[S]);let O=async e=>{try{var t;C.ZP.info("Making API Call"),u(!0),console.log("formValues in create user:",e);let a=await (0,p.Ov)(s,null,e);console.log("user create Response:",a),x(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};v(e),_(!0)}else(0,p.XO)(s,r).then(e=>{e.has_user_setup_sso=!1,v(e),_(!0)});C.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)(y.Z,{className:"mx-auto mb-0",onClick:()=>u(!0),children:"+ Invite User"}),(0,r.jsxs)(A.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{u(!1),c.resetFields()},onCancel:()=>{u(!1),x(null),c.resetFields()},children:[(0,r.jsx)(w.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,r.jsxs)(I.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.Z.Item,{label:"User Email",name:"user_email",children:(0,r.jsx)(Z.Z,{placeholder:""})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.Z.Item,{label:"Team ID",name:"team_id",children:(0,r.jsx)(k.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,r.jsx)(e6,{value:e.team_id,children:e.team_alias},e.team_id)):(0,r.jsx)(e6,{value:null,children:"Default Team"},"default")})}),(0,r.jsx)(I.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)(T.ZP,{htmlType:"submit",children:"Create User"})})]})]}),h&&(0,r.jsx)(e8,{isInvitationLinkModalVisible:f,setIsInvitationLinkModalVisible:_,baseUrl:N,invitationLinkData:b})]})},e9=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,n.useState)(a),[c]=I.Z.useForm();(0,n.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,r.jsx)(A.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,r.jsx)(I.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)(I.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)(I.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,r.jsx)(Z.Z,{})}),(0,r.jsx)(I.Z.Item,{label:"User Role",name:"user_role",children:(0,r.jsx)(k.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)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)(I.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)(O.Z,{min:0,step:1})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var le=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(1),[_,b]=n.useState(null),[v,w]=(0,n.useState)(null),[S,N]=(0,n.useState)(!1),[k,I]=(0,n.useState)(null),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(null),[T,D]=(0,n.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{E(e),P(!0)},L=async()=>{if(O&&l)try{if(await (0,p.Eb)(l,[O]),C.ZP.success("User deleted successfully"),u){let e=u.filter(e=>e.user_id!==O);h(e)}}catch(e){console.error("Error deleting user:",e),C.ZP.error("Failed to delete user")}P(!1),E(null)},F=async()=>{I(null),N(!1)},R=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,p.pf)(l,e,null),C.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)),I(null),N(!1)}};return((0,n.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(j));if(e){let l=JSON.parse(e);m(l),h(l.users||[])}else{let e=await (0,p.Br)(l,null,a,!0,j,25);sessionStorage.setItem("userList_".concat(j),JSON.stringify(e)),m(e),h(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,p.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),D(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&a&&i&&e()},[l,s,a,i,j]),u&&l&&s&&a&&i)?(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsxs)(f.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,r.jsx)(e7,{userID:i,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)(ei.Z,{children:(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(W.Z,{className:"mt-5",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"User Spend ($ USD)"}),(0,r.jsx)(J.Z,{children:"User Max Budget ($ USD)"}),(0,r.jsx)(J.Z,{children:"API Keys"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:u.map(e=>{var l,s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.user_id||"-"}),(0,r.jsx)(G.Z,{children:e.user_email||"-"}),(0,r.jsx)(G.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)(G.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,r.jsx)(G.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(f.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)(G.Z,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,onClick:()=>{I(e),N(!0)},children:"View Keys"}),(0,r.jsx)(eB.Z,{icon:eh.Z,onClick:()=>M(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)(e9,{visible:S,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: ",O]})]})]})})}),(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{P(!1),E(null)},children:"Cancel"})]})]})]})})]}),function(){if(!u)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{h([]),Z(e)};return(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{children:["Showing Page ",j," 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===j,onClick:()=>l(j-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:j===e,onClick:()=>l(j+1),children:"Next →"})]})]})}()]})}):(0,r.jsx)("div",{children:"Loading..."})},ll=e=>{var l,s,t;let{visible:a,onCancel:i,onSubmit:o,initialData:d,mode:c,config:m}=e,[u]=I.Z.useForm();console.log("Initial Data:",d),(0,n.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(),C.ZP.success("Successfully ".concat("add"===c?"added":"updated"," member"))}catch(e){C.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)(k.default,{children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,r.jsx)(k.default.Option,{value:e.value,children:e.label},e.value))});default:return null}};return(0,r.jsx)(A.Z,{title:m.title||("add"===c?"Add Member":"Edit Member"),open:a,width:800,footer:null,onCancel:i,children:(0,r.jsxs)(I.Z,{form:u,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[m.showEmail&&(0,r.jsx)(I.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)(w.Z,{children:"OR"})}),m.showUserId&&(0,r.jsx)(I.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)(I.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)(k.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)(k.default.Option,{value:e.value,children:e.label},e.value)):m.roleOptions.map(e=>(0,r.jsx)(k.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)(I.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)(T.ZP,{onClick:i,className:"mr-2",children:"Cancel"}),(0,r.jsx)(T.ZP,{type:"default",htmlType:"submit",children:"add"===c?"Add Member":"Save Changes"})]})]})})},ls=s(7310),lt=s.n(ls),la=e=>{let{isVisible:l,onCancel:s,onSubmit:t,accessToken:a,title:i="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]=I.Z.useForm(),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)("user_email"),f=async(e,l)=>{if(!e){u([]);return}x(!0);try{let s=new URLSearchParams;if(s.append(l,e),null==a)return;let t=(await (0,p.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{x(!1)}},y=(0,n.useCallback)(lt()((e,l)=>f(e,l),300),[]),Z=(e,l)=>{j(l),y(e,l)},_=(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)(A.Z,{title:i,open:l,onCancel:()=>{c.resetFields(),u([]),s()},footer:null,width:800,children:(0,r.jsxs)(I.Z,{form:c,onFinish:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:d},children:[(0,r.jsx)(I.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by email",filterOption:!1,onSearch:e=>Z(e,"user_email"),onSelect:(e,l)=>_(e,l),options:"user_email"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,r.jsx)(I.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,r.jsx)(k.default,{showSearch:!0,className:"w-full",placeholder:"Search by user ID",filterOption:!1,onSearch:e=>Z(e,"user_id"),onSelect:(e,l)=>_(e,l),options:"user_id"===g?m:[],loading:h,allowClear:!0})}),(0,r.jsx)(I.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,r.jsx)(k.default,{defaultValue:d,children:o.map(e=>(0,r.jsx)(k.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)(T.ZP,{type:"default",htmlType:"submit",children:"Add Member"})})]})})},lr=e=>{let{teamId:l,accessToken:s,currentAliases:t,availableModels:a,onUpdate:i}=e,[o,d]=(0,n.useState)(!1),[c]=I.Z.useForm(),m=async e=>{try{if(!s)return;let a={...t,[e.alias_name]:e.original_model};await (0,p.Gh)(s,{team_id:l,model_aliases:a}),C.ZP.success("Model alias created successfully"),d(!1),c.resetFields(),t[e.alias_name]=e.original_model}catch(e){C.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)(S.Z,{children:"Team Aliases"}),(0,r.jsx)(w.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)(y.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)(A.Z,{title:"Create Model Alias",open:o,onCancel:()=>{d(!1),c.resetFields()},footer:null,width:500,children:(0,r.jsxs)(I.Z,{form:c,onFinish:m,layout:"vertical",className:"mt-4",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Points To",name:"original_model",rules:[{required:!0,message:"Please select a model"}],children:(0,r.jsx)(k.default,{placeholder:"Select model version",className:"w-full font-mono",showSearch:!0,optionFilterProp:"children",children:a.map(e=>(0,r.jsx)(k.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)(y.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)(y.Z,{size:"md",variant:"secondary",type:"submit",children:"Create Alias"})]})]})})]})},ln=e=>{var l,s,t;let{teamId:a,onClose:i,accessToken:o,is_team_admin:d,is_proxy_admin:c,userModels:m,editTeam:u}=e,[h,x]=(0,n.useState)(null),[g,j]=(0,n.useState)(!0),[Z,_]=(0,n.useState)(!1),[b]=I.Z.useForm(),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),[D,L]=(0,n.useState)(!1);console.log("userModels in team info",m);let z=d||c,U=async()=>{try{if(j(!0),!o)return;let e=await (0,p.Xm)(o,a);x(e)}catch(e){C.ZP.error("Failed to load team information"),console.error("Error fetching team info:",e)}finally{j(!1)}};(0,n.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,p.cu)(o,a,l),C.ZP.success("Team member added successfully"),_(!1),b.resetFields(),U()}catch(e){C.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,p.sN)(o,a,l),C.ZP.success("Team member updated successfully"),N(!1),U()}catch(e){C.ZP.error("Failed to update team member"),console.error("Error updating team member:",e)}},B=async e=>{try{if(null==o)return;await (0,p.Lp)(o,a,e),C.ZP.success("Team member removed successfully"),U()}catch(e){C.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,p.Gh)(o,s),C.ZP.success("Team settings updated successfully"),L(!1),U()}catch(e){C.ZP.error("Failed to update team settings"),console.error("Error updating team:",e)}};if(g)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:X}=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)(T.ZP,{onClick:i,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:X.team_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:X.team_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:u?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",X.spend.toFixed(6)]}),(0,r.jsxs)(w.Z,{children:["of ",null===X.max_budget?"Unlimited":"$".concat(X.max_budget)]}),X.budget_duration&&(0,r.jsxs)(w.Z,{className:"text-gray-500",children:["Reset: ",X.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",X.rpm_limit||"Unlimited"]}),X.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",X.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Models"}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:X.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"User Email"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:h.team_info.members_with_roles.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_email})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.role})}),(0,r.jsx)(G.Z,{children:z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P(e),N(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>B(e),icon:eh.Z,size:"sm"})]})})]},l))})]})}),(0,r.jsx)(y.Z,{onClick:()=>_(!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)(S.Z,{children:"Team Settings"}),z&&!D&&(0,r.jsx)(y.Z,{onClick:()=>L(!0),children:"Edit Settings"})]}),D?(0,r.jsxs)(I.Z,{form:b,onFinish:K,initialValues:{...X,team_alias:X.team_alias,models:X.models,tpm_limit:X.tpm_limit,rpm_limit:X.rpm_limit,max_budget:X.max_budget,budget_duration:X.budget_duration,guardrails:(null===(l=X.metadata)||void 0===l?void 0:l.guardrails)||[]},layout:"vertical",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),m.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",placeholder:"Select or enter guardrails"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>L(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team Name"}),(0,r.jsx)("div",{children:X.team_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Team ID"}),(0,r.jsx)("div",{className:"font-mono",children:X.team_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Created At"}),(0,r.jsx)("div",{children:new Date(X.created_at).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Models"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:X.models.map((e,l)=>(0,r.jsx)(ea.Z,{color:"red",children:e},l))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Rate Limits"}),(0,r.jsxs)("div",{children:["TPM: ",X.tpm_limit||"Unlimited"]}),(0,r.jsxs)("div",{children:["RPM: ",X.rpm_limit||"Unlimited"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Budget"}),(0,r.jsxs)("div",{children:["Max: ",null!==X.max_budget?"$".concat(X.max_budget):"No Limit"]}),(0,r.jsxs)("div",{children:["Reset: ",X.budget_duration||"Never"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Status"}),(0,r.jsx)(ea.Z,{color:X.blocked?"red":"green",children:X.blocked?"Blocked":"Active"})]})]})]}),(0,r.jsx)(lr,{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)(ll,{visible:v,onCancel:()=>N(!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)(la,{isVisible:Z,onCancel:()=>_(!1),onSubmit:V,accessToken:o})]})},li=e=>{let{accessToken:l,userID:s}=e,[t,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{if(l&&s)try{let e=await (0,p.a6)(l);a(e)}catch(e){console.error("Error fetching available teams:",e)}})()},[l,s]);let i=async e=>{if(l&&s)try{await (0,p.cu)(l,e,{user_id:s,role:"user"}),C.ZP.success("Successfully joined team"),a(l=>l.filter(l=>l.team_id!==e))}catch(e){console.error("Error joining team:",e),C.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Description"}),(0,r.jsx)(J.Z,{children:"Members"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsxs)(H.Z,{children:[t.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.team_alias})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.description||"No description available"})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[e.members_with_roles.length," members"]})}),(0,r.jsx)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})})})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{size:"xs",variant:"secondary",onClick:()=>i(e.team_id),children:"Join Team"})})]},e.team_id)),0===t.length&&(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:5,className:"text-center",children:(0,r.jsx)(w.Z,{children:"No available teams to join"})})})]})]})})};console.log=function(){};var lo=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o,currentOrg:d}=e,[c,m]=(0,n.useState)("");(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&g(t,i,o,d,a)},[l]),(0,n.useEffect)(()=>{console.log("inside useeffect - ".concat(c)),t&&g(t,i,o,d,a),ek()},[c]);let[u]=I.Z.useForm(),[h]=I.Z.useForm(),{Title:x,Paragraph:S}=e_.default,[N,P]=(0,n.useState)(""),[E,L]=(0,n.useState)(!1),[z,U]=(0,n.useState)(null),[V,q]=(0,n.useState)(null),[B,K]=(0,n.useState)(!1),[X,Q]=(0,n.useState)(!1),[ee,el]=(0,n.useState)(!1),[es,et]=(0,n.useState)(!1),[em,ex]=(0,n.useState)([]),[ep,eg]=(0,n.useState)(!1),[ej,ef]=(0,n.useState)(null),[ey,eZ]=(0,n.useState)({}),[eb,ev]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null==t)return;let e=(await (0,p.t3)(t)).guardrails.map(e=>e.guardrail_name);ev(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})()},[t]);let ew=async e=>{ef(e),eg(!0)},eS=async()=>{if(null!=ej&&null!=l&&null!=t){try{await (0,p.rs)(t,ej);let e=l.filter(e=>e.team_id!==ej);a(e)}catch(e){console.error("Error deleting the team:",e)}eg(!1),ef(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{let e;if(null===i||null===o||null===t||null===l)return;let s={};e="Admin"!=o&&"Admin Viewer"!=o?await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO,i):await (0,p.It)(t,(null==d?void 0:d.organization_id)||p.lO);for(let l=0;l{try{if(null===i||null===o||null===t)return;let e=await D(i,o,t);e&&ex(e)}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eN=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let r=null==e?void 0:e.team_alias,n=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=(null==e?void 0:e.organization_id)||(null==d?void 0:d.organization_id);if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),e.metadata={...e.guardrails?{guardrails:e.guardrails}:{}},delete e.guardrails,n.includes(r))throw Error("Team alias ".concat(r," already exists, please pick another alias"));C.ZP.info("Creating Team");let o=await (0,p.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),C.ZP.success("Team created"),Q(!1)}}catch(e){console.error("Error creating the team:",e),C.ZP.error("Error creating the team: "+e,20)}},ek=()=>{m(new Date().toLocaleString())};return(0,r.jsx)("div",{className:"w-full mx-4",children:V?(0,r.jsx)(ln,{teamId:V,onClose:()=>{q(null),K(!1)},accessToken:t,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let l=0;le.team_id===V)),is_proxy_admin:"Admin"==o,userModels:em,editTeam:B}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Teams"}),(0,r.jsx)(en.Z,{children:"Available Teams"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[c&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",c]}),(0,r.jsx)(eB.Z,{icon:eu.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ek})]})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(w.Z,{children:["Click on “Team ID” to view team details ",(0,r.jsx)("b",{children:"and"})," manage team members."]}),(0,r.jsxs)(f.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-y-auto max-h-[50vh]",children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Team Name"}),(0,r.jsx)(J.Z,{children:"Team ID"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"})]})}),(0,r.jsx)(H.Z,{children:l&&l.length>0?l.filter(e=>{let l=d?d.organization_id:null;return e.organization_id===l}).sort((e,l)=>new Date(l.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.team_id,children:(0,r.jsxs)(y.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:()=>{q(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})})}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,r.jsx)(G.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)(G.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)(w.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)(w.Z,{children:"All Proxy Models"})},l):(0,r.jsx)(ea.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,r.jsx)(w.Z,{children:e.length>30?"".concat(M(e).slice(0,30),"..."):M(e)})},l))}):null}),(0,r.jsx)(G.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,r.jsxs)(w.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,r.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,r.jsxs)(G.Z,{children:[(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].keys&&ey[e.team_id].keys.length," ","Keys"]}),(0,r.jsxs)(w.Z,{children:[ey&&e.team_id&&ey[e.team_id]&&ey[e.team_id].members_with_roles&&ey[e.team_id].members_with_roles.length," ","Members"]})]}),(0,r.jsx)(G.Z,{children:"Admin"==o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{q(e.team_id),K(!0)}}),(0,r.jsx)(eB.Z,{onClick:()=>ew(e.team_id),icon:eh.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),ep&&(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)(y.Z,{onClick:eS,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{eg(!1),ef(null)},children:"Cancel"})]})]})]})})]})}),"Admin"==o||"Org Admin"==o?(0,r.jsxs)(j.Z,{numColSpan:1,children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>Q(!0),children:"+ Create New Team"}),(0,r.jsx)(A.Z,{title:"Create Team",visible:X,width:800,footer:null,onOk:()=>{Q(!1),u.resetFields()},onCancel:()=>{Q(!1),u.resetFields()},children:(0,r.jsxs)(I.Z,{form:u,onFinish:eN,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),em.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,r.jsx)(Z.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,r.jsx)(I.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)(k.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:eb.map(e=>({value:e,label:e}))})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null]})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(li,{accessToken:t,userID:i})})]})]})})},ld=e=>{var l;let{organizationId:s,onClose:t,accessToken:a,is_org_admin:i,is_proxy_admin:o,userModels:d,editOrg:c}=e,[m,u]=(0,n.useState)(null),[h,x]=(0,n.useState)(!0),[g]=I.Z.useForm(),[j,Z]=(0,n.useState)(!1),[_,b]=(0,n.useState)(!1),[v,N]=(0,n.useState)(!1),[A,P]=(0,n.useState)(null),D=i||o,L=async()=>{try{if(x(!0),!a)return;let e=await (0,p.t$)(a,s);u(e)}catch(e){C.ZP.error("Failed to load organization information"),console.error("Error fetching organization info:",e)}finally{x(!1)}};(0,n.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,p.vh)(a,s,l),C.ZP.success("Organization member added successfully"),b(!1),g.resetFields(),L()}catch(e){C.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,p.LY)(a,s,l),C.ZP.success("Organization member updated successfully"),N(!1),g.resetFields(),L()}catch(e){C.ZP.error("Failed to update organization member"),console.error("Error updating organization member:",e)}},z=async e=>{try{if(!a)return;await (0,p.Sb)(a,s,e.user_id),C.ZP.success("Organization member deleted successfully"),N(!1),g.resetFields(),L()}catch(e){C.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");C.ZP.success("Organization settings updated successfully"),Z(!1),L()}catch(e){C.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)(T.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,r.jsx)(S.Z,{children:m.organization_alias}),(0,r.jsx)(w.Z,{className:"text-gray-500 font-mono",children:m.organization_id})]})}),(0,r.jsxs)(ei.Z,{defaultIndex:c?2:0,children:[(0,r.jsxs)(eo.Z,{className:"mb-4",children:[(0,r.jsx)(en.Z,{children:"Overview"}),(0,r.jsx)(en.Z,{children:"Members"}),(0,r.jsx)(en.Z,{children:"Settings"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Organization Details"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["Created: ",new Date(m.created_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Updated: ",new Date(m.updated_at).toLocaleDateString()]}),(0,r.jsxs)(w.Z,{children:["Created By: ",m.created_by]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Budget Status"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(S.Z,{children:["$",m.spend.toFixed(6)]}),(0,r.jsxs)(w.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)(w.Z,{className:"text-gray-500",children:["Reset: ",m.litellm_budget_table.budget_duration]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Rate Limits"}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)(w.Z,{children:["TPM: ",m.litellm_budget_table.tpm_limit||"Unlimited"]}),(0,r.jsxs)(w.Z,{children:["RPM: ",m.litellm_budget_table.rpm_limit||"Unlimited"]}),m.litellm_budget_table.max_parallel_requests&&(0,r.jsxs)(w.Z,{children:["Max Parallel Requests: ",m.litellm_budget_table.max_parallel_requests]})]})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"User ID"}),(0,r.jsx)(J.Z,{children:"Role"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Created At"}),(0,r.jsx)(J.Z,{})]})}),(0,r.jsx)(H.Z,{children:null===(l=m.members)||void 0===l?void 0:l.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_id})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{className:"font-mono",children:e.user_role})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["$",e.spend.toFixed(6)]})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:new Date(e.created_at).toLocaleString()})}),(0,r.jsx)(G.Z,{children:D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{P({role:e.user_role,user_email:e.user_email,user_id:e.user_id}),N(!0)}}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>{z(e)}})]})})]},l))})]})}),D&&(0,r.jsx)(y.Z,{onClick:()=>{b(!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)(S.Z,{children:"Organization Settings"}),D&&!j&&(0,r.jsx)(y.Z,{onClick:()=>Z(!0),children:"Edit Settings"})]}),j?(0,r.jsxs)(I.Z,{form:g,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)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),d.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,style:{width:"100%"}})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,r.jsx)(T.ZP,{onClick:()=>Z(!1),children:"Cancel"}),(0,r.jsx)(y.Z,{type:"submit",children:"Save Changes"})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(w.Z,{className:"font-medium",children:"Organization Name"}),(0,r.jsx)("div",{children:m.organization_alias})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(w.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)(w.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)(w.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)(w.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)(w.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)(la,{isVisible:_,onCancel:()=>b(!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)(ll,{visible:v,onCancel:()=>N(!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 lc=async(e,l)=>{l(await (0,p.r6)(e))};var lm=e=>{let{organizations:l,userRole:s,userModels:t,accessToken:a,lastRefreshed:i,handleRefreshClick:o,currentOrg:d,guardrailsList:c=[],setOrganizations:m,premiumUser:u}=e,[h,x]=(0,n.useState)(null),[g,_]=(0,n.useState)(!1),[b,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(null),[P,E]=(0,n.useState)(!1),[T]=I.Z.useForm();(0,n.useEffect)(()=>{0===l.length&&a&&lc(a,m)},[l,a]);let D=e=>{e&&(N(e),v(!0))},L=async()=>{if(S&&a)try{await (0,p.cq)(a,S),C.ZP.success("Organization deleted successfully"),v(!1),N(null),lc(a,m)}catch(e){console.error("Error deleting organization:",e)}},F=async e=>{try{if(!a)return;await (0,p.H1)(a,e),E(!1),T.resetFields(),lc(a,m)}catch(e){console.error("Error creating organization:",e)}};return u?h?(0,r.jsx)(ld,{organizationId:h,onClose:()=>{x(null),_(!1)},accessToken:a,is_org_admin:!0,is_proxy_admin:"Admin"===s,userModels:t,editOrg:g}):(0,r.jsxs)(ei.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)(en.Z,{children:"Your Organizations"})}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[i&&(0,r.jsxs)(w.Z,{children:["Last Refreshed: ",i]}),(0,r.jsx)(eB.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)(w.Z,{children:"Click on “Organization ID” to view organization details."}),(0,r.jsxs)(f.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Organization ID"}),(0,r.jsx)(J.Z,{children:"Organization Name"}),(0,r.jsx)(J.Z,{children:"Created"}),(0,r.jsx)(J.Z,{children:"Spend (USD)"}),(0,r.jsx)(J.Z,{children:"Budget (USD)"}),(0,r.jsx)(J.Z,{children:"Models"}),(0,r.jsx)(J.Z,{children:"TPM / RPM Limits"}),(0,r.jsx)(J.Z,{children:"Info"}),(0,r.jsx)(J.Z,{children:"Actions"})]})}),(0,r.jsx)(H.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,n,i,o,d,c,m;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{className:"overflow-hidden",children:(0,r.jsx)(R.Z,{title:e.organization_id,children:(0,r.jsxs)(y.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:()=>x(e.organization_id),children:[null===(l=e.organization_id)||void 0===l?void 0:l.slice(0,7),"..."]})})})}),(0,r.jsx)(G.Z,{children:e.organization_alias}),(0,r.jsx)(G.Z,{children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,r.jsx)(G.Z,{children:e.spend}),(0,r.jsx)(G.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===(n=e.litellm_budget_table)||void 0===n?void 0:n.max_budget:"No limit"}),(0,r.jsx)(G.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:["TPM: ",(null===(i=e.litellm_budget_table)||void 0===i?void 0:i.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)(G.Z,{children:(0,r.jsxs)(w.Z,{children:[(null===(m=e.members)||void 0===m?void 0:m.length)||0," Members"]})}),(0,r.jsx)(G.Z,{children:"Admin"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{x(e.organization_id),_(!0)}}),(0,r.jsx)(eB.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)(y.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Organization"}),(0,r.jsx)(A.Z,{title:"Create Organization",visible:P,width:800,footer:null,onCancel:()=>{E(!1),T.resetFields()},children:(0,r.jsxs)(I.Z,{form:T,onFinish:F,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Models",name:"models",children:(0,r.jsxs)(k.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,r.jsx)(k.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),t&&t.length>0&&t.map(e=>(0,r.jsx)(k.default.Option,{value:e,children:M(e)},e))]})}),(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})}),(0,r.jsx)(I.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)(I.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,r.jsx)(O.Z,{step:1,width:400})}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(y.Z,{type:"submit",children:"Create Organization"})})]})})]})]})]})}),b?(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)(y.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,r.jsx)(y.Z,{onClick:()=>{v(!1),N(null)},children:"Cancel"})]})]})]})}):(0,r.jsx)(r.Fragment,{})]}):(0,r.jsx)("div",{children:(0,r.jsxs)(w.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 lu=()=>{let[e,l]=(0,n.useState)("http://localhost:4000");return(0,n.useEffect)(()=>{{let{protocol:e,host:s}=window.location;l("".concat(e,"//").concat(s))}},[]),e};var lh=e=>{let{searchParams:l,accessToken:s,showSSOBanner:t,premiumUser:a}=e,[o]=I.Z.useForm(),[d]=I.Z.useForm(),{Title:c,Paragraph:m}=e_.default,[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)(null),[j,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(!1),[v,S]=(0,n.useState)(!1),[N,k]=(0,n.useState)(!1),[P,O]=(0,n.useState)(!1),[D,M]=(0,n.useState)(!1),[L,F]=(0,n.useState)(!1),[R,z]=(0,n.useState)(!1),[U,V]=(0,n.useState)(!1),[q,B]=(0,n.useState)(!1),[K,X]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(null);(0,i.useRouter)();let[el,es]=(0,n.useState)(null);console.log=function(){};let et=lu(),ea="All IP Addresses Allowed",en=et;en+="/fallback/login";let ei=async()=>{try{if(!0!==a){C.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(s){let e=await (0,p.PT)(s);X(e&&e.length>0?e:[ea])}else X([ea])}catch(e){console.error("Error fetching allowed IPs:",e),C.ZP.error("Failed to fetch allowed IPs ".concat(e)),X([ea])}finally{!0===a&&z(!0)}},eo=async e=>{try{if(s){await (0,p.eH)(s,e.ip);let l=await (0,p.PT)(s);X(l),C.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),C.ZP.error("Failed to add IP address ".concat(e))}finally{V(!1)}},ed=async e=>{ee(e),B(!0)},ec=async()=>{if(Q&&s)try{await (0,p.$I)(s,Q);let e=await (0,p.PT)(s);X(e.length>0?e:[ea]),C.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),C.ZP.error("Failed to delete IP address ".concat(e))}finally{B(!1),ee(null)}},em=()=>{F(!1)};(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await (0,p.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,p.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)),g(e),es(await (0,p.lg)(s))}})()},[s]);let eu=async e=>{try{if(null!=s&&null!=x){var l;C.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await (0,p.pf)(s,e,"proxy_admin"),a=(null===(l=t.data)||void 0===l?void 0:l.user_id)||t.user_id;(0,p.XO)(s,a).then(e=>{Z(e),b(!0)}),console.log("response for team create call: ".concat(t));let r=x.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"),x.push(t),g(x)),o.resetFields(),k(!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,p.K_)(s,l)};return console.log("admins: ".concat(null==x?void 0:x.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)(f.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)(y.Z,{onClick:()=>!0===a?M(!0):C.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,r.jsx)("div",{children:(0,r.jsx)(y.Z,{onClick:ei,children:"Allowed IPs"})})]})]}),(0,r.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,r.jsx)(A.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{M(!1),o.resetFields()},onCancel:()=>{M(!1),o.resetFields()},children:(0,r.jsxs)(I.Z,{form:o,onFinish:e=>{eu(e),eh(e),M(!1),F(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.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)(I.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)(I.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,r.jsxs)(A.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)(w.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,r.jsx)(w.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,r.jsx)(w.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)(T.ZP,{onClick:em,children:"Done"})})]}),(0,r.jsx)(A.Z,{title:"Manage Allowed IP Addresses",width:800,visible:R,onCancel:()=>z(!1),footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>V(!0),children:"Add IP Address"},"add"),(0,r.jsx)(y.Z,{onClick:()=>z(!1),children:"Close"},"close")],children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"IP Address"}),(0,r.jsx)(J.Z,{className:"text-right",children:"Action"})]})}),(0,r.jsx)(H.Z,{children:K.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e}),(0,r.jsx)(G.Z,{className:"text-right",children:e!==ea&&(0,r.jsx)(y.Z,{onClick:()=>ed(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,r.jsx)(A.Z,{title:"Add Allowed IP Address",visible:U,onCancel:()=>V(!1),footer:null,children:(0,r.jsxs)(I.Z,{onFinish:eo,children:[(0,r.jsx)(I.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)(I.Z.Item,{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,r.jsx)(A.Z,{title:"Confirm Delete",visible:q,onCancel:()=>B(!1),onOk:ec,footer:[(0,r.jsx)(y.Z,{className:"mx-1",onClick:()=>ec(),children:"Yes"},"delete"),(0,r.jsx)(y.Z,{onClick:()=>B(!1),children:"Close"},"close")],children:(0,r.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",Q,"?"]})})]}),(0,r.jsxs)(eX.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,r.jsxs)("a",{href:en,target:"_blank",children:[(0,r.jsx)("b",{children:en})," "]})]})]})]})},lx=s(92858),lp=s(44643),lg=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:n}=e,[i]=I.Z.useForm();return(0,r.jsxs)(I.Z,{form:i,onFinish:()=>{console.log("INSIDE ONFINISH");let e=i.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)($.Z,{children:[(0,r.jsxs)(G.Z,{align:"center",children:[(0,r.jsx)(w.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?n?(0,r.jsx)(I.Z.Item,{name:e.field_name,children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,r.jsx)(lx.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)(G.Z,{children:(0,r.jsx)(y.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)(I.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,r.jsx)(G.Z,{children:"Integer"===e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,r.jsx)(lx.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,r.jsx)(E.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,r.jsx)("div",{children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Update Settings"})})]})},lj=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(0,p.RQ)(l).then(e=>{a(e)})},[l]),(0,r.jsx)(lg,{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,...n}=a;console.log("slack_alerting: ".concat(r,", alertingArgs: ").concat(JSON.stringify(n)));try{(0,p.jA)(l,"alerting_args",n),"boolean"==typeof r&&(!0==r?(0,p.jA)(l,"alerting",["slack"]):(0,p.jA)(l,"alerting",[])),C.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},lf=s(86582);let{Title:ly,Paragraph:lZ}=e_.default;console.log=function(){};var l_=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,n.useState)([]),[d,c]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[h]=I.Z.useForm(),[x,g]=(0,n.useState)(null),[j,_]=(0,n.useState)([]),[b,v]=(0,n.useState)(""),[S,N]=(0,n.useState)({}),[P,O]=(0,n.useState)([]),[E,D]=(0,n.useState)(!1),[M,L]=(0,n.useState)([]),[F,R]=(0,n.useState)(null),[z,U]=(0,n.useState)([]),[V,q]=(0,n.useState)(!1),[B,K]=(0,n.useState)(null),X=e=>{P.includes(e)?O(P.filter(l=>l!==e)):O([...P,e])},Q={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,n.useEffect)(()=>{l&&s&&t&&(0,p.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),O(e.active_alerts),v(s),N(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ee=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,p.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.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,p.K_)(l,{environment_variables:s}),C.ZP.success("Callback added successfully"),u(!1),h.resetFields(),g(null)}catch(e){C.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,p.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),C.ZP.success("Callback ".concat(s," added successfully")),u(!1),h.resetFields(),g(null)}catch(e){C.ZP.error("Failed to add callback: "+e,20)}},em=e=>{console.log("inside handleSelectedCallbackChange",e),g(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(U(e.litellm_callback_params),console.log("selectedCallbackParams",z)):U([])};return l?(console.log("callbacks: ".concat(i)),(0,r.jsxs)("div",{className:"w-full mx-4",children:[(0,r.jsx)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"line",defaultValue:"1",children:[(0,r.jsx)(en.Z,{value:"1",children:"Logging Callbacks"}),(0,r.jsx)(en.Z,{value:"2",children:"Alerting Types"}),(0,r.jsx)(en.Z,{value:"3",children:"Alerting Settings"}),(0,r.jsx)(en.Z,{value:"4",children:"Email Alerts"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsxs)(ed.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Active Logging Callbacks"}),(0,r.jsx)(f.Z,{numItems:2,children:(0,r.jsx)(er.Z,{className:"max-h-[50vh]",children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(J.Z,{children:"Callback Name"})})}),(0,r.jsx)(H.Z,{children:i.map((e,s)=>(0,r.jsxs)($.Z,{className:"flex justify-between",children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.name})}),(0,r.jsx)(G.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"flex justify-between",children:[(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>{K(e),q(!0)}}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{}),(0,r.jsx)(J.Z,{children:"Slack Webhook URL"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(Q).map((e,l)=>{let[s,t]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:"region_outage_alerts"==s?a?(0,r.jsx)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)}):(0,r.jsx)(y.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)(lx.Z,{id:"switch",name:"switch",checked:ee(s),onChange:()=>X(s)})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:t})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:s,type:"password",defaultValue:S&&S[s]?S[s]:b})})]},l)})})]}),(0,r.jsx)(y.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(Q).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,p.K_)(l,s)}catch(e){C.ZP.error("Failed to update alerts: "+e,20)}C.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(lj,{accessToken:l,premiumUser:a})}),(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(ly,{level:4,children:"Email Settings"}),(0,r.jsxs)(w.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)(G.Z,{children:(0,r.jsx)("ul",{children:(0,r.jsx)(f.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)(w.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)(w.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)(y.Z,{className:"mt-2",onClick:()=>el(),children:"Save Changes"}),(0,r.jsx)(y.Z,{onClick:()=>(0,p.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,r.jsxs)(A.Z,{title:"Add Logging Callback",visible:E,width:800,onCancel:()=>D(!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)(I.Z,{form:h,onFinish:ea,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lf.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,r.jsx)(k.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),em(l))},children:M&&Object.values(M).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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,r.jsx)(A.Z,{visible:V,width:800,title:"Edit ".concat(null==B?void 0:B.name," Settings"),onCancel:()=>q(!1),footer:null,children:(0,r.jsxs)(I.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)(lf.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)(T.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null},lb=s(92414),lv=s(46030);let{Option:lw}=k.default;var lS=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=I.Z.useForm(),[o,d]=(0,n.useState)(!1),[c,m]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,r.jsx)(A.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,r.jsxs)(I.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:r}=e,n=[...t.fallbacks||[],{[l]:r}],o={...t,fallbacks:n};console.log(o);try{(0,p.K_)(s,{router_settings:o}),a(o)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,r.jsx)(lb.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lN=s(33619);async function lk(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new lN.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});C.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lI={ttl:3600,lowest_latency_buffer:0},lC=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)(b.Z,{children:"latency-based-routing"==l?(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(Z.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,r.jsx)(w.Z,{children:"No specific settings"})})]})};var lA=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)({}),[d,c]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[h,x]=(0,n.useState)(!1),[g]=I.Z.useForm(),[_,b]=(0,n.useState)(null),[v,N]=(0,n.useState)(null),[k,A]=(0,n.useState)(null),P={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,n.useEffect)(()=>{l&&s&&t&&((0,p.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,p.YU)(l).then(e=>{u(e)}))},[l,s,t]);let E=async e=>{if(!l)return;console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks));let s=i.fallbacks.map(l=>(e in l&&delete l[e],l)).filter(e=>Object.keys(e).length>0),t={...i,fallbacks:s};try{await (0,p.K_)(l,{router_settings:t}),o(t),C.ZP.success("Router settings updated successfully")}catch(e){C.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))},D=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,p.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(s)}catch(e){}},M=(e,s)=>{if(l)try{(0,p.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,v];if("routing_strategy_args"==l&&"latency-based-routing"==v){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,p.K_)(l,{router_settings:s})}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.ZP.success("router settings updated successfully")};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsxs)(ei.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)(en.Z,{value:"1",children:"Loadbalancing"}),(0,r.jsx)(en.Z,{value:"2",children:"Fallbacks"}),(0,r.jsx)(en.Z,{value:"3",children:"General"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,r.jsx)(S.Z,{children:"Router Settings"}),(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"})]})}),(0,r.jsx)(H.Z,{children:Object.entries(i).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)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.Z,{children:l}),(0,r.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,r.jsx)(G.Z,{children:"routing_strategy"==l?(0,r.jsxs)(es.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:N,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)(lC,{selectedStrategy:v,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:lI,paramExplanation:P})]}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(y.Z,{className:"mt-2",onClick:()=>L(i),children:"Save Changes"})})]})}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Model Name"}),(0,r.jsx)(J.Z,{children:"Fallbacks"})]})}),(0,r.jsx)(H.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:t}),(0,r.jsx)(G.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(y.Z,{onClick:()=>lk(t,l),children:"Test Fallback"})}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,r.jsx)(lS,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,r.jsx)(ed.Z,{children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Setting"}),(0,r.jsx)(J.Z,{children:"Value"}),(0,r.jsx)(J.Z,{children:"Status"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsxs)(G.Z,{children:[(0,r.jsx)(w.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)(G.Z,{children:"Integer"==e.field_type?(0,r.jsx)(O.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,r.jsx)(G.Z,{children:!0==e.stored_in_db?(0,r.jsx)(ea.Z,{icon:lp.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)(G.Z,{children:[(0,r.jsx)(y.Z,{onClick:()=>D(e.field_name,l),children:"Update"}),(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>M(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lP=s(93142),lO=s(45246),lE=s(96473),lT=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,n.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);a(l),null==s||s(Object.fromEntries(l))},o=(e,l,r)=>{let n=[...t];n[e]=[l,r],a(n),null==s||s(Object.fromEntries(n))};return(0,r.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,r.jsxs)(lP.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)(lO.Z,{onClick:()=>i(l)})]},l)}),(0,r.jsx)(T.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,r.jsx)(lE.Z,{}),children:"Add Header"})]})};let{Option:lD}=k.default;var lM=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=I.Z.useForm(),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)("");return(0,r.jsxs)("div",{children:[(0,r.jsx)(y.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,r.jsx)(A.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,r.jsxs)(I.Z,{form:a,onFinish:e=>{console.log(e);let r=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,p.Vt)(l,e),s(r)}catch(e){C.ZP.error("Failed to update router settings: "+e,20)}C.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)(I.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)(I.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)(I.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)(lT,{})})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},lL=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&s&&t&&(0,p.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,p.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),C.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,r.jsx)("div",{className:"w-full mx-4",children:(0,r.jsx)(ei.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Path"}),(0,r.jsx)(J.Z,{children:"Target"}),(0,r.jsx)(J.Z,{children:"Headers"}),(0,r.jsx)(J.Z,{children:"Action"})]})}),(0,r.jsx)(H.Z,{children:i.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:(0,r.jsx)(w.Z,{children:e.path})}),(0,r.jsx)(G.Z,{children:e.target}),(0,r.jsx)(G.Z,{children:JSON.stringify(e.headers)}),(0,r.jsx)(G.Z,{children:(0,r.jsx)(eB.Z,{icon:eh.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,r.jsx)(lM,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lF=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[n]=I.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call");let l=await (0,p.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),C.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),n.resetFields()},onCancel:()=>{t(!1),n.resetFields()},children:(0,r.jsxs)(I.Z,{form:n,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lR=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=I.Z.useForm();(0,n.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{C.ZP.info("Making API Call"),t(!0);let l=await (0,p.qI)(s,e);a(e=>e?[...e,l]:[l]),C.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),C.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.jsx)(A.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,r.jsxs)(I.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I.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)(I.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.Z,{step:1,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(O.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)(b.Z,{children:[(0,r.jsx)(I.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(O.Z,{step:.01,precision:2,width:200})}),(0,r.jsx)(I.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(k.default,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(k.default.Option,{value:"24h",children:"daily"}),(0,r.jsx)(k.default.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(k.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(T.ZP,{htmlType:"submit",children:"Save"})})]})})},lz=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)(!1),[a,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),[c,m]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&(0,p.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),i(!0))},h=async(e,s)=>{if(null==l)return;C.ZP.info("Request made"),await (0,p.NV)(l,e);let t=[...c];t.splice(s,1),m(t),C.ZP.success("Budget Deleted.")},x=async()=>{null!=l&&(0,p.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)(y.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,r.jsx)(lF,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,r.jsx)(lR,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:x}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(w.Z,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Budget ID"}),(0,r.jsx)(J.Z,{children:"Max Budget"}),(0,r.jsx)(J.Z,{children:"TPM"}),(0,r.jsx)(J.Z,{children:"RPM"})]})}),(0,r.jsx)(H.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)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.budget_id}),(0,r.jsx)(G.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)(G.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)(G.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(eB.Z,{icon:eY.Z,size:"sm",onClick:()=>u(e.budget_id,l)}),(0,r.jsx)(eB.Z,{icon:eh.Z,size:"sm",onClick:()=>h(e.budget_id,l)})]},l))})]})]}),(0,r.jsxs)("div",{className:"mt-5",children:[(0,r.jsx)(w.Z,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"Assign Budget to Customer"}),(0,r.jsx)(en.Z,{children:"Test it (Curl)"}),(0,r.jsx)(en.Z,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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)'})})]})]})]})]})},lU=s(77398),lV=s.n(lU),lq=s(20016);async function lB(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 lK=e=>{let{ipAddress:l}=e,[s,t]=n.useState("-");return n.useEffect(()=>{if(!l)return;let e=!0;return lB(l).then(l=>{e&&t(l)}).catch(()=>{e&&t("-")}),()=>{e=!1}},[l]),(0,r.jsx)("span",{children:s})},lW=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"}},lH=e=>{let{utcTime:l}=e;return(0,r.jsx)("span",{style:{fontFamily:"monospace",width:"180px",display:"inline-block"},children:lW(l)})},lG=[{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)(lH,{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)(lK,{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:eC(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)]})})})}}],lY=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,p.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 lJ(e){var l,s,t;let{accessToken:a,token:i,userRole:o,userID:d}=e,[m,u]=(0,n.useState)(""),[h,x]=(0,n.useState)(!1),[g,j]=(0,n.useState)(!1),[f,y]=(0,n.useState)(1),[Z]=(0,n.useState)(50),_=(0,n.useRef)(null),b=(0,n.useRef)(null),v=(0,n.useRef)(null),[w,S]=(0,n.useState)(lV()().subtract(24,"hours").format("YYYY-MM-DDTHH:mm")),[N,k]=(0,n.useState)(lV()().format("YYYY-MM-DDTHH:mm")),[I,C]=(0,n.useState)(!1),[A,P]=(0,n.useState)(!1),[O,E]=(0,n.useState)(""),[T,D]=(0,n.useState)(""),[M,L]=(0,n.useState)(""),[F,R]=(0,n.useState)(""),[z,U]=(0,n.useState)("Team ID"),V=(0,c.NL)();(0,n.useEffect)(()=>{function e(e){_.current&&!_.current.contains(e.target)&&j(!1),b.current&&!b.current.contains(e.target)&&x(!1),v.current&&!v.current.contains(e.target)&&P(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let q=(0,lq.a)({queryKey:["logs","table",f,Z,w,N,M,F],queryFn:async()=>{if(!a||!i||!o||!d)return console.log("Missing required auth parameters"),{data:[],total:0,page:1,page_size:Z,total_pages:0};let e=lV()(w).utc().format("YYYY-MM-DD HH:mm:ss"),l=I?lV()(N).utc().format("YYYY-MM-DD HH:mm:ss"):lV()().utc().format("YYYY-MM-DD HH:mm:ss"),s=await (0,p.h3)(a,F||void 0,M||void 0,void 0,e,l,f,Z);return await lY(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&&!!i&&!!o&&!!d,refetchInterval:5e3,refetchIntervalInBackground:!0});if(!a||!i||!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(lV()(w).format("MMM D, h:mm A")," - ").concat(lV()(N).format("MMM D, h:mm A"));let e=lV()(),l=lV()(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:b,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:()=>x(!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:()=>j(!g),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"})})]}),g&&(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),j(!1),"Team ID"===e?D(""):E("")},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?O:T,onChange:e=>{"Team ID"===z?E(e.target.value):D(e.target.value)}}),(0,r.jsx)("button",{className:"p-1 hover:bg-gray-100 rounded-md",onClick:()=>{E(""),D("")},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:()=>{E(""),D(""),x(!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(O),R(T),y(1),x(!1)},children:"Apply Filters"})]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative",ref:v,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(lV()().format("YYYY-MM-DDTHH:mm")),S(lV()().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=>{S(e.target.value),y(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:N,onChange:e=>{k(e.target.value),y(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)*Z+1:0," ","-"," ",q.isLoading?"...":q.data?Math.min(f*Z,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:()=>y(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:()=>y(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:lG,data:B,renderSubComponent:l$,getRowCanExpand:()=>!0})]})]})}function l$(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 lX=s(92699),lQ=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)(f.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)(w.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{children:[(0,r.jsx)(en.Z,{children:"OpenAI Python SDK"}),(0,r.jsx)(en.Z,{children:"LlamaIndex"}),(0,r.jsx)(en.Z,{children:"Langchain Py"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsx)(e1.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)(e1.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)(e1.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 ')})})]})]})]})})})},l0=s(243),l1=s(94263);async function l2(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,r=new lN.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){C.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var l4=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,n.useState)(i?"custom":"session"),[c,m]=(0,n.useState)(""),[u,h]=(0,n.useState)(""),[x,g]=(0,n.useState)([]),[_,b]=(0,n.useState)(void 0),[v,S]=(0,n.useState)([]),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,p.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)),S(s),b(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,n.useEffect)(()=>{N.current&&setTimeout(()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[x]);let I=(e,l,s)=>{g(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){C.ZP.error("Please provide an API key or select Current UI Session");return}let r={role:"user",content:u},n=[...x.map(e=>{let{role:l,content:s}=e;return{role:l,content:s}}),r];g([...x,r]);try{_&&await l2(n,(e,l)=>I("assistant",e,l),_,e)}catch(e){console.error("Error fetching model response",e),I("assistant","Error fetching model response")}h("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=e_.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)(f.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,r.jsx)(er.Z,{children:(0,r.jsxs)(ei.Z,{children:[(0,r.jsx)(eo.Z,{children:(0,r.jsx)(en.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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"API Key Source"}),(0,r.jsx)(k.default,{disabled:i,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)(w.Z,{children:"Select Model:"}),(0,r.jsx)(k.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),b(e)},options:v,style:{width:"350px"},showSearch:!0})]})]}),(0,r.jsx)(y.Z,{onClick:()=>{g([]),C.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,r.jsxs)(W.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,r.jsx)(Y.Z,{children:(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{})})}),(0,r.jsxs)(H.Z,{children:[x.map((e,l)=>(0,r.jsx)($.Z,{children:(0,r.jsxs)(G.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)(l0.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...n}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,r.jsx)(e1.Z,{style:l1.Z,language:i[1],PreTag:"div",...n,children:String(a).replace(/\n$/,"")}):(0,r.jsx)("code",{className:t,...n,children:a})}},children:e.content})})]})},l)),(0,r.jsx)($.Z,{children:(0,r.jsx)(G.Z,{children:(0,r.jsx)("div",{ref:N,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)(y.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},l5=s(19226),l3=s(61787),l8=s(92403),l6=s(28595),l7=s(68208),l9=s(9775),se=s(41361),sl=s(37527),ss=s(15883),st=s(12660),sa=s(88009),sr=s(48231),sn=s(41169),si=s(44625),so=s(57400),sd=s(55322);let{Sider:sc}=l5.default,sm=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],su=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,r.jsx)(l8.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,r.jsx)(l6.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,r.jsx)(l7.Z,{}),roles:sm},{key:"4",page:"usage",label:"Usage",icon:(0,r.jsx)(l9.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,r.jsx)(se.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"5",page:"users",label:"Internal Users",icon:(0,r.jsx)(ss.Z,{}),roles:sm},{key:"14",page:"api_ref",label:"API Reference",icon:(0,r.jsx)(st.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,r.jsx)(sa.Z,{})},{key:"15",page:"logs",label:"Logs",icon:(0,r.jsx)(sr.Z,{}),roles:sm},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,r.jsx)(sn.Z,{}),roles:sm,children:[{key:"9",page:"caching",label:"Caching",icon:(0,r.jsx)(si.Z,{}),roles:sm},{key:"10",page:"budgets",label:"Budgets",icon:(0,r.jsx)(sl.Z,{}),roles:sm},{key:"11",page:"guardrails",label:"Guardrails",icon:(0,r.jsx)(so.Z,{}),roles:sm}]},{key:"settings",page:"settings",label:"Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,r.jsx)(st.Z,{}),roles:sm},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,r.jsx)(sd.Z,{}),roles:sm},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,r.jsx)(sd.Z,{}),roles:sm}]}];var sh=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=su.find(l=>l.page===e);if(l)return l.key;for(let l of su)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),n=su.filter(e=>!e.roles||e.roles.includes(s));return(0,r.jsx)(l5.default,{style:{minHeight:"100vh"},children:(0,r.jsx)(sc,{theme:"light",width:220,children:(0,r.jsx)(l3.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:n.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)}}})})})})},sx=s(96889);console.log=function(){};var sp=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,n.useState)(null!==a?a:0),[m,u]=(0,n.useState)(o?o.max_budget:null);(0,n.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)u(i);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,i]);let[h,x]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,p.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,n.useEffect)(()=>{null!==a&&c(a)},[a]);let g=[];o&&o.models&&(g=o.models),g&&g.includes("all-proxy-models")?(console.log("user models:",h),g=h):g&&g.includes("all-team-models")?g=o.models:g&&0===g.length&&(g=h);let j=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:["$",j]})]}),(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"})]})]})})},sg=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let sj=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var sf=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[b,v]=(0,n.useState)([]),[N,k]=(0,n.useState)([]),[I,C]=(0,n.useState)([]),[A,P]=(0,n.useState)([]),[O,E]=(0,n.useState)([]),[T,D]=(0,n.useState)([]),[M,L]=(0,n.useState)({}),[F,R]=(0,n.useState)([]),[z,U]=(0,n.useState)(""),[V,q]=(0,n.useState)(["all-tags"]),[B,K]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[X,Q]=(0,n.useState)(null),[ee,el]=(0,n.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",i),console.log("premium user in usage",o);let ep=async()=>{if(l)try{let e=await (0,p.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,n.useEffect)(()=>{ej(B.from,B.to)},[B,V]);let eg=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,p.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),_(a)},ej=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,p.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 ey=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eZ=(e,l,s,t)=>{let a=[],r=new Date(l),n=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]}},i=new Map(e.map(e=>{let l=n(e.date);return[l,{...e,date:l}]}));for(;r<=s;){let e=r.toISOString().split("T")[0];if(i.has(e))a.push(i.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},e_=async()=>{if(l)try{let e=await (0,p.FC)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0),r=eZ(e,t,a,[]),n=Number(r.reduce((e,l)=>e+(l.spend||0),0).toFixed(2));el(n),m(r)}catch(e){console.error("Error fetching overall spend:",e)}},eb=()=>ey(()=>l&&s?(0,p.OU)(l,s,eu,eh):Promise.reject("No access token or token"),D,"Error fetching provider spend"),ew=async()=>{l&&await ey(async()=>(await (0,p.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")},eS=async()=>{l&&await ey(async()=>(await (0,p.Au)(l)).map(e=>({key:e.model,spend:Number(e.total_spend.toFixed(2))})),g,"Error fetching top models")},eN=async()=>{l&&await ey(async()=>{let e=await (0,p.mR)(l),s=new Date,t=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return v(eZ(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)}))},E,"Error fetching team spend")},ek=()=>{l&&ey(async()=>(await (0,p.X)(l)).tag_names,C,"Error fetching tag names")},eI=()=>{l&&ey(()=>{var e,s;return(0,p.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&&ey(()=>(0,p.b1)(l,null,void 0,void 0),_,"Error fetching top end users")},eA=async()=>{if(l)try{let e=await (0,p.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=eZ(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,p.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:eZ(e.daily_data||[],t,a,["api_requests","total_tokens"])}));R(r)}catch(e){console.error("Error fetching global activity per model:",e)}};return((0,n.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ep();e&&(Q(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",X),e_(),eb(),ew(),eS(),eA(),eP(),sj(t)&&(eN(),ek(),eI(),eC()))}})()},[l,s,t,a,eu,eh]),null==X?void 0:X.DISABLE_EXPENSIVE_DB_QUERIES)?(0,r.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Database Query Limit Reached"}),(0,r.jsxs)(w.Z,{className:"mt-4",children:["SpendLogs in DB has ",X.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)(y.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{className:"mt-2",children:[(0,r.jsx)(en.Z,{children:"All Up"}),sj(t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(en.Z,{children:"Team Based Usage"}),(0,r.jsx)(en.Z,{children:"Customer Usage"}),(0,r.jsx)(en.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)(ei.Z,{children:[(0,r.jsxs)(eo.Z,{variant:"solid",className:"mt-1",children:[(0,r.jsx)(en.Z,{children:"Cost"}),(0,r.jsx)(en.Z,{children:"Activity"})]}),(0,r.jsxs)(ec.Z,{children:[(0,r.jsx)(ed.Z,{children:(0,r.jsxs)(f.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,r.jsxs)(j.Z,{numColSpan:2,children:[(0,r.jsxs)(w.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)(sp,{userID:a,userRole:t,accessToken:l,userSpend:ee,selectedTeam:null,userMaxBudget:null})]}),(0,r.jsx)(j.Z,{numColSpan:2,children:(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Monthly Spend"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top API Keys"}),(0,r.jsx)(eW.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)(S.Z,{children:"Top Models"}),(0,r.jsx)(eW.Z,{className:"mt-4 h-40",data:x,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)(S.Z,{children:"Spend by Provider"}),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(sg.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Provider"}),(0,r.jsx)(J.Z,{children:"Spend"})]})}),(0,r.jsx)(H.Z,{children:T.map(e=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.provider}),(0,r.jsx)(G.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)(f.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"All Up"}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(M.sum_api_requests)]}),(0,r.jsx)(eK.Z,{className:"h-40",data:M.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(M.sum_total_tokens)]}),(0,r.jsx)(eW.Z,{className:"h-40",data:M.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)(S.Z,{children:e.model}),(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsxs)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ex(e.sum_api_requests)]}),(0,r.jsx)(eK.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)(ev.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ex(e.sum_total_tokens)]}),(0,r.jsx)(eW.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)(f.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)(S.Z,{children:"Total Spend Per Team"}),(0,r.jsx)(sx.Z,{data:O})]}),(0,r.jsxs)(er.Z,{children:[(0,r.jsx)(S.Z,{children:"Daily Spend Per Team"}),(0,r.jsx)(eW.Z,{className:"h-72",data:b,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)(f.Z,{numItems:2,children:[(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Time Range"}),(0,r.jsx)(eq.Z,{enableSelect:!0,value:B,onValueChange:e=>{K(e),eg(e.from,e.to,null)}})]}),(0,r.jsxs)(j.Z,{children:[(0,r.jsx)(w.Z,{children:"Select Key"}),(0,r.jsxs)(es.Z,{defaultValue:"all-keys",children:[(0,r.jsx)(et.Z,{value:"all-keys",onClick:()=>{eg(B.from,B.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,r.jsx)(et.Z,{value:String(l),onClick:()=>{eg(B.from,B.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,r.jsx)(er.Z,{className:"mt-4",children:(0,r.jsxs)(W.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Customer"}),(0,r.jsx)(J.Z,{children:"Spend"}),(0,r.jsx)(J.Z,{children:"Total Events"})]})}),(0,r.jsx)(H.Z,{children:null==Z?void 0:Z.map((e,l)=>{var s;return(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.end_user}),(0,r.jsx)(G.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,r.jsx)(G.Z,{children:e.total_count})]},l)})})]})})]}),(0,r.jsxs)(ed.Z,{children:[(0,r.jsxs)(f.Z,{numItems:2,children:[(0,r.jsx)(j.Z,{numColSpan:1,children:(0,r.jsx)(eq.Z,{className:"mb-4",enableSelect:!0,value:B,onValueChange:e=>{K(e),ej(e.from,e.to)}})}),(0,r.jsx)(j.Z,{children:o?(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(lv.Z,{value:String(e),children:e},e))]})}):(0,r.jsx)("div",{children:(0,r.jsxs)(lb.Z,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(lv.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)(f.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)(S.Z,{children:"Spend Per Tag"}),(0,r.jsxs)(w.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)(eW.Z,{className:"h-72",data:N,index:"name",categories:["spend"],colors:["cyan"]})]})}),(0,r.jsx)(j.Z,{numColSpan:2})]})]})]})]})})};let sy=e=>{if(e)return e.toISOString().split("T")[0]};function sZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var s_=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,n.useState)([]),[c,m]=(0,n.useState)([]),[u,h]=(0,n.useState)([]),[x,g]=(0,n.useState)([]),[Z,_]=(0,n.useState)("0"),[b,v]=(0,n.useState)("0"),[S,N]=(0,n.useState)("0"),[k,I]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[A,P]=(0,n.useState)(""),[O,E]=(0,n.useState)("");(0,n.useEffect)(()=>{l&&k&&((async()=>{g(await (0,p.zg)(l,sy(k.from),sy(k.to)))})(),P(new Date().toLocaleString()))},[l]);let T=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),D=Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(x.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let M=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),g(await (0,p.zg)(l,sy(e),sy(s))))};(0,n.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",x);let e=x;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},[]);_(sZ(s)),v(sZ(t));let r=s+l;r>0?N((s/r*100).toFixed(2)):N("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,u,k,x]);let L=async()=>{try{C.ZP.info("Running cache health check..."),E("");let e=await (0,p.Tj)(null!==l?l:"");console.log("CACHING HEALTH CHECK RESPONSE",e),E(e)}catch(e){console.error("Error running health check:",e),E("Error running health check")}};return(0,r.jsxs)(ei.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)(en.Z,{children:"Cache Analytics"}),(0,r.jsx)(en.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)(w.Z,{children:["Last Refreshed: ",A]}),(0,r.jsx)(eB.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)(f.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:T.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(lb.Z,{placeholder:"Select Models",value:u,onValueChange:h,children:D.map(e=>(0,r.jsx)(lv.Z,{value:e,children:e},e))})}),(0,r.jsx)(j.Z,{children:(0,r.jsx)(eq.Z,{enableSelect:!0,value:k,onValueChange:e=>{I(e),M(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:[S,"%"]})})]}),(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:Z})})]}),(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:b})})]})]}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,r.jsx)(eW.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:sZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,r.jsx)(ev.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,r.jsx)(eW.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:sZ,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)(w.Z,{children:"Cache health will run a very small request through API /cache/ping configured on litellm"}),(0,r.jsx)(y.Z,{onClick:L,className:"mt-4",children:"Run cache health"}),O&&(0,r.jsx)("pre",{className:"mt-4",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxWidth:"100%"},children:JSON.stringify(O,null,2)})]})})]})]})},sb=e=>{let{accessToken:l}=e,[s,t]=(0,n.useState)([]);return(0,n.useEffect)(()=>{l&&(async()=>{try{let e=await (0,p.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)(w.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)(W.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)($.Z,{children:[(0,r.jsx)(J.Z,{children:"Guardrail Name"}),(0,r.jsx)(J.Z,{children:"Mode"}),(0,r.jsx)(J.Z,{children:"Status"})]})}),(0,r.jsx)(H.Z,{children:s&&0!==s.length?null==s?void 0:s.map((e,l)=>(0,r.jsxs)($.Z,{children:[(0,r.jsx)(G.Z,{children:e.guardrail_name}),(0,r.jsx)(G.Z,{children:e.litellm_params.mode}),(0,r.jsx)(G.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)($.Z,{children:(0,r.jsx)(G.Z,{colSpan:3,className:"mt-4 text-gray-500 text-center py-4",children:"No guardrails configured"})})})]})})]})};function sv(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"}}let sw=new d.S;function sS(){let[e,l]=(0,n.useState)(""),[s,t]=(0,n.useState)(!1),[a,d]=(0,n.useState)(!1),[u,h]=(0,n.useState)(null),[g,j]=(0,n.useState)(null),[f,y]=(0,n.useState)(null),[Z,_]=(0,n.useState)(m),[b,v]=(0,n.useState)([]),[w,S]=(0,n.useState)([]),[N,k]=(0,n.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[I,C]=(0,n.useState)(!0),A=(0,i.useSearchParams)(),[P,O]=(0,n.useState)({data:[]}),[E,T]=(0,n.useState)(null),D=A.get("userID"),M=A.get("invitation_id"),[L,F]=(0,n.useState)(()=>A.get("page")||"api-keys"),[R,z]=(0,n.useState)(null);return(0,n.useEffect)(()=>{T(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,n.useEffect)(()=>{if(!E)return;let e=(0,o.o)(E);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),z(e.key),d(e.disabled_non_admin_personal_key_creation),e.user_role){let s=sv(e.user_role);console.log("Decoded user_role:",s),l(s),"Admin Viewer"==s&&F("usage")}else console.log("User role not defined");e.user_email?h(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?C("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,p.K8)(e.auth_header_name)}},[E]),(0,n.useEffect)(()=>{R&&D&&e&&q(D,e,R,S)},[R,D,e]),(0,r.jsx)(n.Suspense,{fallback:(0,r.jsx)("div",{children:"Loading..."}),children:(0,r.jsx)(c.aH,{client:sw,children:M?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):(0,r.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,r.jsx)(x,{userID:D,userRole:e,userEmail:u,premiumUser:s,setProxySettings:k,proxySettings:N,currentOrg:Z,organizations:b,onOrgChange:s=>{if(_(s),console.log("org: ".concat(JSON.stringify(s))),s.members&&"Admin"!=e)for(let e of s.members)console.log("member: ".concat(JSON.stringify(e))),e.user_id==D&&(console.log("member.user_role: ".concat(e.user_role)),l(sv(e.user_role)));j(null)}}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(sh,{setPage:e=>{let l=new URLSearchParams(A);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),F(e)},userRole:e,defaultSelectedKey:L})}),"api-keys"==L?(0,r.jsx)(eb,{userID:D,userRole:e,premiumUser:s,teams:g,keys:f,setUserRole:l,userEmail:u,setUserEmail:h,setTeams:j,setKeys:y,setOrganizations:v,currentOrg:Z}):"models"==L?(0,r.jsx)(e3,{userID:D,userRole:e,token:E,keys:f,accessToken:R,modelData:P,setModelData:O,premiumUser:s}):"llm-playground"==L?(0,r.jsx)(l4,{userID:D,userRole:e,token:E,accessToken:R,disabledPersonalKeyCreation:a}):"users"==L?(0,r.jsx)(le,{userID:D,userRole:e,token:E,keys:f,teams:g,accessToken:R,setKeys:y}):"teams"==L?(0,r.jsx)(lo,{teams:g,setTeams:j,searchParams:A,accessToken:R,userID:D,userRole:e,currentOrg:Z}):"organizations"==L?(0,r.jsx)(lm,{organizations:b,setOrganizations:v,userModels:w,accessToken:R,userRole:e,premiumUser:s}):"admin-panel"==L?(0,r.jsx)(lh,{setTeams:j,searchParams:A,accessToken:R,showSSOBanner:I,premiumUser:s}):"api_ref"==L?(0,r.jsx)(lQ,{proxySettings:N}):"settings"==L?(0,r.jsx)(l_,{userID:D,userRole:e,accessToken:R,premiumUser:s}):"budgets"==L?(0,r.jsx)(lz,{accessToken:R}):"guardrails"==L?(0,r.jsx)(sb,{accessToken:R}):"general-settings"==L?(0,r.jsx)(lA,{userID:D,userRole:e,accessToken:R,modelData:P}):"model-hub"==L?(0,r.jsx)(lX.Z,{accessToken:R,publicPage:!1,premiumUser:s}):"caching"==L?(0,r.jsx)(s_,{userID:D,userRole:e,token:E,accessToken:R,premiumUser:s}):"pass-through-settings"==L?(0,r.jsx)(lL,{userID:D,userRole:e,accessToken:R,modelData:P}):"logs"==L?(0,r.jsx)(lJ,{userID:D,userRole:e,token:E,accessToken:R}):(0,r.jsx)(sf,{userID:D,userRole:e,token:E,accessToken:R,keys:f,premiumUser:s})]})]})})})}}},function(e){e.O(0,[665,990,42,261,755,270,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/index.html b/ui/litellm-dashboard/out/index.html index 234c844bb7f..df3e5ada523 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 9261bc995ab..4aac8d7b9d1 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[36733,["665","static/chunks/3014691f-6bdd9c4659caabcd.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-85111ce0453ddfcd.js","261","static/chunks/261-d96d45a1822b4dea.js","755","static/chunks/755-288e79da1358e7df.js","270","static/chunks/270-4325009e72737e70.js","250","static/chunks/250-80b974142ec97c60.js","699","static/chunks/699-1ceaf984f1f1378c.js","931","static/chunks/app/page-7a5ba6fe8c2fe4b2.js"],"default",1] +3:I[36733,["665","static/chunks/3014691f-6bdd9c4659caabcd.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-85111ce0453ddfcd.js","261","static/chunks/261-d96d45a1822b4dea.js","755","static/chunks/755-288e79da1358e7df.js","270","static/chunks/270-4325009e72737e70.js","250","static/chunks/250-80b974142ec97c60.js","699","static/chunks/699-1ceaf984f1f1378c.js","931","static/chunks/app/page-508ac4d06e0d1277.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["SyoNkMOnybMJCs1FpMdUS",[[["",{"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/b52cc8cb4b27f084.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:["SLeC9QjabwQfDLWx06pJ4",[[["",{"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/b52cc8cb4b27f084.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 cfade6cc55d..73ee8153ef1 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 cb47a272b86..9e27a690ed2 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-85111ce0453ddfcd.js","261","static/chunks/261-d96d45a1822b4dea.js","250","static/chunks/250-80b974142ec97c60.js","699","static/chunks/699-1ceaf984f1f1378c.js","418","static/chunks/app/model_hub/page-cca9fa9bc14379a7.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["SyoNkMOnybMJCs1FpMdUS",[[["",{"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/b52cc8cb4b27f084.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:["SLeC9QjabwQfDLWx06pJ4",[[["",{"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/b52cc8cb4b27f084.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 ecec27ab73e..3934d7f72ad 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 e214de51bff..cd697421729 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-6bdd9c4659caabcd.js","42","static/chunks/42-85111ce0453ddfcd.js","755","static/chunks/755-288e79da1358e7df.js","250","static/chunks/250-80b974142ec97c60.js","461","static/chunks/app/onboarding/page-628ddfb2d1bfc440.js"],"default",1] 4:I[4707,[],""] 5:I[36423,[],""] -0:["SyoNkMOnybMJCs1FpMdUS",[[["",{"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/b52cc8cb4b27f084.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:["SLeC9QjabwQfDLWx06pJ4",[[["",{"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/b52cc8cb4b27f084.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