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/litellm/proxy/_experimental/out/_next/static/mtFU-WaJL2V39gBiXh0cn/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_buildManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/mtFU-WaJL2V39gBiXh0cn/_buildManifest.js
rename to litellm/proxy/_experimental/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_buildManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/mtFU-WaJL2V39gBiXh0cn/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_ssgManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/mtFU-WaJL2V39gBiXh0cn/_ssgManifest.js
rename to litellm/proxy/_experimental/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_ssgManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-f3fef89bb008195a.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-7af065b71201666b.js
similarity index 83%
rename from litellm/proxy/_experimental/out/_next/static/chunks/app/page-f3fef89bb008195a.js
rename to litellm/proxy/_experimental/out/_next/static/chunks/app/page-7af065b71201666b.js
index a5d8fc51861..134dbea855c 100644
--- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-f3fef89bb008195a.js
+++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-7af065b71201666b.js
@@ -1 +1 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,69623))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),n=s(99376),r=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),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,n.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,y]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,k]=(0,a.useState)(null),[N,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),y(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),k(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)(r.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=v,S&&s&&(0,p.m_)(Z,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)(g.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)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},69623:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l$}});var t,a,n=s(57437),r=s(2265),i=s(99376),o=s(27648),d=s(92643),c=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",a),console.log=function(){};let c="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(c=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",c);let m=[{key:"1",label:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{children:["Role: ",s]}),(0,n.jsxs)("p",{children:["ID: ",l]}),(0,n.jsxs)("p",{children:["Premium User: ",String(a)]})]})},{key:"2",label:(0,n.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=c},children:"Logout"})}];return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,n.jsx)("div",{className:"w-full px-4",children:(0,n.jsxs)("div",{className:"flex justify-between items-center h-14",children:[(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)(o.default,{href:"/",className:"flex items-center",children:[(0,n.jsx)("span",{className:"text-xl",children:"\uD83D\uDE85"}),(0,n.jsx)("span",{className:"ml-2 text-base font-medium text-gray-700",children:"LiteLLM"})]})}),(0,n.jsxs)("div",{className:"flex items-center space-x-6",children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-gray-600 hover:text-gray-800",children:"Docs"}),(0,n.jsx)(d.Z,{menu:{items:m},children:(0,n.jsxs)("button",{className:"flex items-center text-sm text-gray-600 hover:text-gray-800",children:["Admin",(0,n.jsx)("svg",{className:"ml-1 w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})})},m=s(19250),u=s(49804),h=s(67101),x=s(20831),p=s(26637),j=s(87452),g=s(88829),f=s(72208),Z=s(84264),y=s(96761),_=s(29233),b=s(41326),v=s(13634),w=s(41021),S=s(51369),k=s(8104),N=s(20577),I=s(56632),C=s(73002);let{Option:A}=b.default,P=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};var E=e=>{let{userID:l,team:s,userRole:t,accessToken:a,data:i,setData:o}=e,[d]=v.Z.useForm(),[c,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(null),[R,D]=(0,r.useState)(null),[M,F]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[z,V]=(0,r.useState)("you"),[B,q]=(0,r.useState)(P(i)),K=()=>{E(!1),d.resetFields()},W=()=>{E(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==a){let e=(await (0,m.So)(a,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,t]);let H=async e=>{try{var s,t,n;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(n=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==n?n:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(w.ZP.info("Making API Call"),E(!0),"service_account"===z){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 u=await (0,m.wX)(a,l,e);console.log("key create Response:",u),o(e=>e?[...e,u]:[u]),T(u.key),D(u.soft_budget),w.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),w.ZP.error("Error creating the key: ".concat(e))}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Key"}),(0,n.jsx)(S.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,n.jsxs)(v.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Owned By",className:"mb-4",children:(0,n.jsxs)(k.ZP.Group,{onChange:e=>V(e.target.value),value:z,children:[(0,n.jsx)(k.ZP,{value:"you",children:"You"}),(0,n.jsx)(k.ZP,{value:"service_account",children:"Service Account"}),"Admin"===t&&(0,n.jsx)(k.ZP,{value:"another_user",children:"Another User"})]})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==z,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===z,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,n.jsx)(p.Z,{placeholder:"User ID",onChange:e=>d.setFieldValue("user_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"you"===z||"another_user"===z?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===z?"key name":"service account ID")}],help:"you"===z?"required":"IDs can include letters, numbers, and hyphens",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",hidden:"another_user"!==z,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,n.jsx)(p.Z,{defaultValue:s?s.team_id:null,onChange:e=>d.setFieldValue("team_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,n.jsx)(A,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,n.jsx)(A,{value:e,children:e},e))]})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.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,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)(v.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,n.jsx)(b.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:B})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),O&&(0,n.jsx)(S.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Save your Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,n.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,n.jsx)(u.Z,{numColSpan:1,children:null!=O?(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:O})}),(0,n.jsx)(_.CopyToClipboard,{text:O,onCopy:()=>{w.ZP.success("API Key copied to clipboard")},children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,n.jsx)(Z.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(7366),T=s(15731),R=s(53410),D=s(23628),M=s(74998),F=s(41649),L=s(12514),U=s(47323),z=s(21626),V=s(97214),B=s(28241),q=s(58834),K=s(69552),W=s(71876),H=s(27281),G=s(57365),J=s(90464);let{Option:Y}=b.default;console.log=function(){};var X=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,data:i,setData:o,teams:d,premiumUser:c}=e,[j,g]=(0,r.useState)(!1),[f,k]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[X,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)([]),ed=new Set,[ec,em]=(0,r.useState)(!1),[eu,eh]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)(null),[ej,eg]=(0,r.useState)(null),[ef]=v.Z.useForm(),[eZ,ey]=(0,r.useState)(null),[e_,eb]=(0,r.useState)(ed),ev=e=>!!e.members_with_roles&&e.members_with_roles.some(e=>"admin"===e.role&&e.user_id===l),ew=r.useMemo(()=>{let e=[];return d&&0!==d.length?(d.forEach(l=>{"default-team"!==l.team_id&&ev(l)?ev(l)&&a&&a.team_id===l.team_id&&(e=[...e,...l.keys||[]]):a&&a.team_id===l.team_id&&i&&(e=[...e,...i.filter(e=>e.team_id===l.team_id)])}),!a&&i&&(e=[...i.filter(e=>!e.team_id||"default-team"===e.team_id),...d.filter(e=>ev(e)).flatMap(e=>e.keys||[])]),Array.from(new Map((e=e.filter(e=>"litellm-dashboard"!==e.team_id)).map(e=>[e.token,e])).values())):i},[i,d,a,l]);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",en),(null==ej?void 0:ej.duration)?ey((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,O.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,O.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,O.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}})(ej.duration)):ey(null),console.log("calculateNewExpiryTime:",eZ)},[en,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),eo(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]);let eS=e=>{er(e),em(!0)},ek=async e=>{if(null==t||null==en)return;let l={...en,metadata:e,key:en.token};try{let e=await (0,m.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===en.token?e:l);o(l)}w.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),w.ZP.error("Failed to update model-specific limits")}em(!1),er(null)};(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),eb(e)}},[d]);let eN=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id);let l=null;if(e.budget_duration)switch(e.budget_duration){case"24h":l="daily";break;case"7d":l="weekly";break;case"30d":l="monthly";break;default:l="None"}er({...e,budget_duration:l}),es(!0)},eI=async e=>{if(null==t)return;let l=e.token;if(e.key=l,e.metadata&&"string"==typeof e.metadata)try{e.metadata=JSON.parse(e.metadata)}catch(l){console.error("Error parsing metadata JSON:",l),w.ZP.error("Invalid metadata JSON for formValue "+e.metadata);return}if(e.budget_duration)switch(e.budget_duration){case"daily":e.budget_duration="24h";break;case"weekly":e.budget_duration="7d";break;case"monthly":e.budget_duration="30d"}console.log("handleEditSubmit:",e);let s=await (0,m.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),w.ZP.success("Key updated successfully"),es(!1),er(null)},eC=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(A(e.token),localStorage.removeItem("userData"+l),k(!0))},eA=async()=>{if(null!=I&&null!=i){try{await (0,m.I1)(t,I);let e=i.filter(e=>e.token!==I);o(e)}catch(e){console.error("Error deleting the key:",e)}k(!1),A(null)}},eP=e=>{er(e),ey(null),ef.setFieldsValue({key_alias:e.key_alias,max_budget:e.max_budget,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,duration:e.duration||""}),eh(!0)},eE=(e,l)=>{eg(s=>({...s,[e]:l}))},eO=async()=>{if(!c){w.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=en)try{let e=await ef.validateFields(),l=await (0,m.s0)(t,en.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==en?void 0:en.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),ef.resetFields(),w.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),w.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,n.jsxs)("div",{children:[(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,n.jsxs)(z.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Key Alias"}),(0,n.jsx)(K.Z,{children:"Secret Key"}),(0,n.jsx)(K.Z,{children:"Created"}),(0,n.jsx)(K.Z,{children:"Expires"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Budget Reset"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"Rate Limits"}),(0,n.jsx)(K.Z,{children:"Rate Limits per model"})]})}),(0,n.jsx)(V.Z,{children:ew&&ew.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(a){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(e_.has(e.team_id),", selectedTeam id: ").concat(a.team_id)),(null!=a.team_id||null===e.team_id||e_.has(e.team_id))&&e.team_id!=a.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,n.jsx)(Z.Z,{children:e.key_alias}):(0,n.jsx)(Z.Z,{children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.key_name})}),(0,n.jsx)(B.Z,{children:null!=e.created_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,n.jsx)(B.Z,{children:null!=e.expires?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,n.jsx)(B.Z,{children:null!=e.max_budget?(0,n.jsx)(Z.Z,{children:e.max_budget}):(0,n.jsx)(Z.Z,{children:"Unlimited"})}),(0,n.jsx)(B.Z,{children:null!=e.budget_reset_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(n.Fragment,{children:a&&a.models&&a.models.length>0?a.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{size:"xs",onClick:()=>eS(e),children:"Edit Limits"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{onClick:()=>{er(e),ea(!0)},icon:T.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:et,onCancel:()=>{ea(!1),er(null)},footer:null,width:800,children:en&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(en.spend).toFixed(4)}catch(e){return en.spend}})()})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.max_budget?(0,n.jsxs)(n.Fragment,{children:[en.max_budget,en.budget_duration&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("br",{}),"Budget will be reset at ",en.budget_reset_at?new Date(en.budget_reset_at).toLocaleString():"Never"]})]}):(0,n.jsx)(n.Fragment,{children:"Unlimited"})})})]},e.name),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.expires?(0,n.jsx)(n.Fragment,{children:new Date(en.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,n.jsx)(n.Fragment,{children:"Never"})})})]},e.name)]}),(0,n.jsxs)(L.Z,{className:"my-4",children:[(0,n.jsx)(y.Z,{children:"Token Name"}),(0,n.jsx)(Z.Z,{className:"my-1",children:en.key_alias?en.key_alias:en.key_name}),(0,n.jsx)(y.Z,{children:"Token ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.token}),(0,n.jsx)(y.Z,{children:"User ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.user_id}),(0,n.jsx)(y.Z,{children:"Metadata"}),(0,n.jsx)(Z.Z,{className:"my-1",children:(0,n.jsxs)("pre",{children:[JSON.stringify(en.metadata)," "]})})]}),(0,n.jsx)(x.Z,{className:"mx-auto flex items-center",onClick:()=>{ea(!1),er(null)},children:"Close"})]})}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>eN(e)}),(0,n.jsx)(U.Z,{onClick:()=>eP(e),icon:D.Z,size:"sm"}),(0,n.jsx)(U.Z,{onClick:()=>eC(e),icon:M.Z,size:"sm"})]})]},e.token)})})]}),f&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:eA,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{k(!1),A(null)},children:"Cancel"})]})]})]})})]}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=v.Z.useForm(),[c,m]=(0,r.useState)(a),[u,h]=(0,r.useState)([]),[x,j]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let f=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,n.jsx)(S.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:o,onFinish:eI,initialValues:f,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(Y,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ei.filter(e=>"all-proxy-models"!==e).map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):c.models.map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):ei.map(e=>(0,n.jsx)(Y,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Current Reset Budget: ".concat(t.budget_duration,", budget will be reset: ").concat(t.budget_reset_at?new Date(t.budget_reset_at).toLocaleString():"Never"),children:(0,n.jsxs)(b.default,{placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"daily",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"weekly",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"monthly",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"token",name:"token",hidden:!0}),(0,n.jsx)(v.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,n.jsx)(H.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,n.jsx)(G.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"TPM Limit (tokens per minute)",name:"tpm_limit",help:"tpm_limit cannot exceed team tpm_limit ".concat((null==c?void 0:c.tpm_limit)!==null&&(null==c?void 0:c.tpm_limit)!==void 0?null==c?void 0:c.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.tpm_limit&&l>c.tpm_limit)throw console.log("keyTeam.tpm_limit: ".concat(c.tpm_limit)),Error("tpm_limit cannot exceed team max tpm_limit: $".concat(c.tpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max rpm_limit: ".concat((null==c?void 0:c.rpm_limit)!==null&&(null==c?void 0:c.rpm_limit)!==void 0?null==c?void 0:c.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.rpm_limit&&l>c.rpm_limit)throw console.log("keyTeam.rpm_limit: ".concat(c.rpm_limit)),Error("rpm_limit cannot exceed team max rpm_limit: $".concat(c.rpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,n.jsx)(J.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:en,onSubmit:eI}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:a,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,u]=(0,r.useState)([]),[h,p]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(t.metadata){let e=t.metadata.model_tpm_limit||{},l=t.metadata.model_rpm_limit||{},s={};Object.keys({...e,...l}).forEach(t=>{s[t]={tpm:e[t]||0,rpm:l[t]||0}}),d(s)}(async()=>{try{let e=await (0,m.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));u(l)}catch(e){console.error("Error fetching model data:",e),w.ZP.error("Failed to fetch available models")}})()},[t,i]);let j=(e,l,s)=>{d(t=>({...t,[e]:{...t[e],[l]:s||0}}))},g=e=>{d(l=>{let{[e]:s,...t}=l;return t})};return(0,n.jsxs)(S.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model"}),(0,n.jsx)(K.Z,{children:"TPM Limit"}),(0,n.jsx)(K.Z,{children:"RPM Limit"}),(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsxs)(V.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:l}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(b.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),p(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,n.jsx)(Y,{value:e,children:e},e))})}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>p(null),children:"Cancel"})})]})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{p("")},disabled:null!==h,children:"Add Limit"})]}),(0,n.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,n.jsx)(x.Z,{onClick:s,children:"Cancel"}),(0,n.jsx)(x.Z,{onClick:()=>{a({...t.metadata,model_tpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.tpm]})),model_rpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.rpm]}))})},children:"Save"})]})]})},{visible:ec,onCancel:()=>em(!1),token:en,onSubmit:ek,accessToken:t}),(0,n.jsx)(S.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),ef.resetFields()},footer:[(0,n.jsx)(x.Z,{onClick:()=>{eh(!1),ef.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,n.jsx)(x.Z,{onClick:eO,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,n.jsxs)(v.Z,{form:ef,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eE("duration",e.duration)},children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{disabled:!0})}),(0,n.jsx)(v.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,n.jsx)(N.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==en?void 0:en.expires)!=null?new Date(en.expires).toLocaleString():"Never"]}),eZ&&(0,n.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eZ]})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,n.jsx)(S.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,n.jsx)(x.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Regenerated Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,n.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,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"Key Alias:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==en?void 0:en.key_alias)||"No alias set"})}),(0,n.jsx)(Z.Z,{className:"mt-3",children:"New API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,n.jsx)(_.CopyToClipboard,{text:ex,onCopy:()=>w.ZP.success("API Key copied to clipboard"),children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,r.useState)(null!==a?a:0),[u,h]=(0,r.useState)(o?o.max_budget:null);(0,r.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)h(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&&(h(s.litellm_budget_table.max_budget),e=!0);e||h(o.max_budget)}}},[o,i]);let[x,p]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",x),j=x):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=x);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,n.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==u?"$".concat(u," limit"):"No limit"})]})]})})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==a){let e=(await (0,m.So)(a,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==t?void 0:t.team_alias}),(null==t?void 0:t.team_id)&&(0,n.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},ee=e=>{let l,{teams:s,setSelectedTeam:t,userRole:a,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let u={models:(null==d?void 0:d.models)||[],team_id:null,team_alias:"Default Team",max_budget:(null==d?void 0:d.max_budget)||null},h=async()=>{null===i&&c&&o(await (0,m.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(u);return console.log("userRole: ".concat(a)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===a?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[u]:s?[...s,u]:[u],(0,n.jsxs)("div",{className:"mt-5 mb-5",children:[(0,n.jsx)(y.Z,{children:"Select Team"}),(0,n.jsx)(Z.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,n.jsxs)(Z.Z,{className:"mt-3 mb-3",children:[(0,n.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,n.jsxs)(Z.Z,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]})},el=s(12011),es=s(14474),et=s(68060);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:x,setKeys:p,premiumUser:j}=e,[g,f]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let y=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),_=Z.get("invitation_id"),[b,v]=(0,r.useState)(null),[w,S]=(0,r.useState)(null),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)(null),A={models:[],team_alias:"Default Team",team_id:null},[P,O]=(0,r.useState)(t?t[0]:A);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,es.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!a&&!g){let e=sessionStorage.getItem("userModels"+l);if(e)N(JSON.parse(e));else{let e=async()=>{let e;e="Admin"!=s&&"Admin Viewer"!=s?await (0,m.It)(b,l):await (0,m.It)(b),console.log("givenTeams: ".concat(e)),x(e)};(async()=>{try{let e=await (0,m.g)(b);C(e);let t=await (0,m.Br)(b,l,s,!1,null,null);console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),f(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys);let a=[...t.teams];a.length>0?(console.log("response['teams']: ".concat(a)),O(a[0])):O(A),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let n=(await (0,m.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),N(n),console.log("userModels:",k),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})(),e()}}},[l,y,b,a,s]),(0,r.useEffect)(()=>{if(null!==a&&null!=P&&null!==P.team_id){let e=0;for(let l of a)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);S(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;S(e)}},[P]),null!=_)return(0,n.jsx)(el.default,{});if(null==l||null==y){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==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Q,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,n.jsx)($,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:w,selectedTeam:P||null}),(0,n.jsx)(X,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:a,setData:p,premiumUser:j,teams:t}),(0,n.jsx)(E,{userID:l,team:P||null,userRole:s,accessToken:b,data:a,setData:p},P?P.team_id:null),(0,n.jsx)(ee,{teams:t,setSelectedTeam:O,userRole:s,proxySettings:I,setProxySettings:C,userInfo:g,accessToken:b})]})})})},en=s(97765),er=s(53003),ei=s(12485),eo=s(18135),ed=s(35242),ec=s(29706),em=s(77991),eu=s(92414),eh=s(46030),ex=s(75105),ep=s(40278),ej=s(75957),eg=s(69410),ef=s(47451),eZ=s(14301),ey=s(2356),e_=e=>{let{modelID:l,accessToken:s}=e,[t,a]=(0,r.useState)(!1),i=async()=>{try{w.ZP.info("Making API Call"),a(!0);let e=await (0,m.Og)(s,l);console.log("model delete Response:",e),w.ZP.success("Model ".concat(l," deleted successfully")),a(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(U.Z,{onClick:()=>a(!0),icon:M.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>a(!1),children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Delete Model"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Model ID: ",(0,n.jsx)("b",{children:l})]})})]})})]})},eb=s(3632),ev=s(18502),ew=s(94789),eS=s(59664),ek=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,n.jsx)(eS.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,n.jsxs)("div",{children:[(0,n.jsx)(ew.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,n.jsx)(x.Z,{variant:"primary",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eN=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,n.jsx)(n.Fragment,{children:l.map(e=>(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,n.jsx)(p.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eI=s(17906);let{Title:eC,Link:eA}=et.default;(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",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.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI";let eP={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"},eE={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eO=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},a={};t.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eP[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=s;else if("custom_model_name"===l)t.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 w.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw w.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 t[l]=s}let r={model_name:n,litellm_params:t,model_info:a},i=await (0,m.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){w.ZP.error("Failed to create model: "+e,10)}};var eT=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:u,premiumUser:j}=e,[g,f]=(0,r.useState)([]),[_]=v.Z.useForm(),[b,k]=(0,r.useState)(null),[I,A]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),O=Object.values(a).filter(e=>isNaN(Number(e))),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[ea,ew]=(0,r.useState)(!1),[eS,eT]=(0,r.useState)(null),[eR,eD]=(0,r.useState)([]),[eM,eF]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[ez,eV]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[eK,eW]=(0,r.useState)([]),[eH,eG]=(0,r.useState)([]),[eJ,eY]=(0,r.useState)([]),[eX,e$]=(0,r.useState)([]),[eQ,e0]=(0,r.useState)([]),[e1,e2]=(0,r.useState)([]),[e4,e5]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e7]=(0,r.useState)(null),[e9,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,la]=(0,r.useState)([]),[ln,lr]=(0,r.useState)(!1),[li,lo]=(0,r.useState)(null),[ld,lc]=(0,r.useState)(null),[lm,lu]=(0,r.useState)([]),lh=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),!s||!o||!i||!l||!t)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),eU(e);let a=null==li?void 0:li.token;void 0===a&&(a=null);let n=ld;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,m.o6)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,m.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,m.N8)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let u=await (0,m.fP)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);if(console.log("slowResponses:",u),e5(u),e){let a=await (0,m.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(a);let n=await (0,m.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{eT(e),es(!0)},lp=e=>{eT(e),ew(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,a]of(e.input_cost_per_million_tokens&&(e.input_cost_per_token=e.input_cost_per_million_tokens/1e6,delete e.input_cost_per_million_tokens),e.output_cost_per_million_tokens&&(e.output_cost_per_token=e.output_cost_per_million_tokens/1e6,delete e.output_cost_per_million_tokens),Object.entries(e)))"model_id"!==s?l[s]=a:t=a;let a={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",a);try{await (0,m.um)(s,a),w.ZP.success("Model updated successfully, restart server to see updates"),es(!1),eT(null)}catch(e){console.log("Error occurred")}},lg=()=>{A(new Date().toLocaleString())},lf=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,m.K_)(s,{router_settings:{model_group_retry_policy:e6}}),w.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),w.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!s||!t||!i||!o)return;let e=async()=>{try{var e,l,t,a,n,r,d,c,h,x,p,j;let g=await (0,m.hy)(s);Y(g);let f=await (0,m.AZ)(s,o,i);console.log("Model data response:",f.data),u(f);let Z=new Set;for(let e=0;e0&&(_=y[y.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",eL);let b=await (0,m.o6)(s,o,i,_,null===(e=e8.from)||void 0===e?void 0:e.toISOString(),null===(l=e8.to)||void 0===l?void 0:l.toISOString(),null==li?void 0:li.token,ld);console.log("Model metrics response:",b),eq(b.data),eW(b.all_api_bases);let v=await (0,m.Rg)(s,_,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(a=e8.to)||void 0===a?void 0:a.toISOString());eG(v.data),eY(v.all_api_bases);let w=await (0,m.N8)(s,o,i,_,null===(n=e8.from)||void 0===n?void 0:n.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",w),e$(w.data),e0(w.exception_types);let S=await (0,m.fP)(s,o,i,_,null===(d=e8.from)||void 0===d?void 0:d.toISOString(),null===(c=e8.to)||void 0===c?void 0:c.toISOString(),null==li?void 0:li.token,ld),k=await (0,m.n$)(s,null===(h=e8.from)||void 0===h?void 0:h.toISOString().split("T")[0],null===(x=e8.to)||void 0===x?void 0:x.toISOString().split("T")[0],_);ls(k);let N=await (0,m.v9)(s,null===(p=e8.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=e8.to)||void 0===j?void 0:j.toISOString().split("T")[0],_);la(N),console.log("dailyExceptions:",k),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",S),e5(S);let I=await (0,m.j2)(s);lu(null==I?void 0:I.end_users);let C=(await (0,m.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,P=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",P),e7(A),le(P)}catch(e){console.error("There was an error fetching the model data",e)}};s&&t&&i&&o&&e();let l=async()=>{let e=await (0,m.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),k(e)};null==b&&l(),lg()},[s,t,i,o,b,I]),!d||!s||!t||!i||!o)return(0,n.jsx)("div",{children:"Loading..."});let lZ=[],ly=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(b)),null!=b&&"object"==typeof b&&e in b)?b[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(n=t)||(n=1===e.length?u(s):l)}else n="-";a&&(r=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,o=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}))),d.data[e].provider=n,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,ly.push(n),d.data[e].input_cost&&(d.data[e].input_cost=(1e6*Number(d.data[e].input_cost)).toFixed(2)),d.data[e].output_cost&&(d.data[e].output_cost=(1e6*Number(d.data[e].output_cost)).toFixed(2)),d.data[e].max_tokens=o,d.data[e].max_input_tokens=c,d.data[e].api_base=null==l?void 0:null===(lv=l.litellm_params)||void 0===lv?void 0:lv.api_base,d.data[e].cleanedLitellmParams=m,lZ.push(l.model_name),console.log(d.data[e])}if(d.data&&d.data.length>0&&d.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),i&&"Admin Viewer"==i){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lw=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(a).find(l=>a[l]===e);if(l){let e=eP[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,a]=l;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===e||a.litellm_provider.includes(e))&&s.push(t)}),"Cohere"==l&&(console.log("adding cohere chat model"),Object.entries(b).forEach(e=>{let[l,t]=e;null!==t&&"object"==typeof t&&"litellm_provider"in t&&"cohere"===t.litellm_provider&&s.push(l)}))),E(s),console.log("providerModels: ".concat(P))}},lS=async()=>{try{w.ZP.info("Running health check..."),ee("");let e=await (0,m.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lk=(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Select API Key Name"}),j?(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsxs)(G.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsxs)(G.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let r=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,n.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[r&&(0,n.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,n.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,n.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})},lI=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";console.log("selectedProvider: ".concat(X)),console.log("providerModels.length: ".concat(P.length));let lC=Object.keys(a).find(e=>a[e]===X);return lC&&(l=M.find(e=>e.name===eP[lC])),(0,n.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(ei.Z,{children:"All Models"}),(0,n.jsx)(ei.Z,{children:"Add Model"}),(0,n.jsx)(ei.Z,{children:(0,n.jsx)("pre",{children:"/health Models"})}),(0,n.jsx)(ei.Z,{children:"Model Analytics"}),(0,n.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[I&&(0,n.jsxs)(Z.Z,{children:["Last Refreshed: ",I]}),(0,n.jsx)(U.Z,{icon:D.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsxs)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||void 0,onValueChange:e=>eU("all"===e?"all":e),value:eL||void 0,children:[(0,n.jsx)(G.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created At":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created By":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,n.jsxs)(W.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.litellm_model_name,children:(0,n.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"===i&&(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.api_base,children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&e.model_info.created_by||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,n.jsx)(F.Z,{size:"xs",className:"text-white",children:(0,n.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,n.jsx)(F.Z,{size:"xs",className:"text-black",children:(0,n.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsxs)(h.Z,{numItems:3,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>lx(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(e_,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,n.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[r]=v.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,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,n.jsx)(S.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"max_retries",name:"max_retries",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"Input Cost per 1M Tokens",name:"input_cost_per_million_tokens",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"Output Cost per 1M Tokens",name:"output_cost_per_million_tokens",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),eT(null)},model:eS,onSubmit:lj}),(0,n.jsxs)(S.Z,{title:eS&&eS.model_name,visible:ea,width:800,footer:null,onCancel:()=>{ew(!1),eT(null)},children:[(0,n.jsx)(y.Z,{children:"Model Info"}),(0,n.jsx)(eI.Z,{language:"json",children:eS&&JSON.stringify(eS,null,2)})]})]}),(0,n.jsxs)(ec.Z,{className:"h-full",children:[(0,n.jsx)(eC,{level:2,children:"Add new model"}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(v.Z,{form:_,onFinish:()=>{_.validateFields().then(e=>{eO(e,s,_)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(H.Z,{value:X.toString(),children:O.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lw(e),$(e)},children:e},l))})}),(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],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.",className:"mb-0",children:(0,n.jsx)(p.Z,{})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,n.jsxs)(v.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,n.jsx)(v.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,n.jsx)(p.Z,{placeholder:lI(X.toString())}):P.length>0?(0,n.jsxs)(eu.Z,{children:[(0,n.jsx)(eh.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,n.jsx)(eh.Z,{value:e,children:e},l))]}):(0,n.jsx)(p.Z,{placeholder:lI(X.toString())})}),(0,n.jsx)(v.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,n.jsx)(v.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,n.jsx)(p.Z,{placeholder:"Enter custom model name"})})}})]}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==l&&l.fields.length>0&&(0,n.jsx)(eN,{fields:l.fields,selectedProvider:l.name}),"Amazon Bedrock"!=X&&"Vertex AI (Anthropic, Gemini, etc.)"!=X&&"Ollama"!=X&&(void 0===l||0==l.fields.length)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,n.jsx)(p.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization",children:(0,n.jsx)(p.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,n.jsx)(p.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,n.jsx)(p.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,n.jsx)(ev.Z,{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;_.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?w.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&w.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,n.jsx)(C.ZP,{icon:(0,n.jsx)(eb.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==X||"OpenAI-Compatible Endpoints (Together AI, etc.)"==X)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,n.jsx)(p.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,n.jsxs)("div",{children:[(0,n.jsx)(v.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,n.jsx)(p.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,n.jsx)(eA,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"us-east-1"})}),(0,n.jsx)(v.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,n.jsx)(v.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]}),(0,n.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,n.jsx)(ej.Z,{title:"Get help on our github",children:(0,n.jsx)(et.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,n.jsx)(x.Z,{onClick:lS,children:"Run `/health`"}),Q&&(0,n.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,n.jsxs)(eg.Z,{className:"ml-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model Group"}),(0,n.jsx)(H.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(eZ.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,n.jsx)(x.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,n.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,n.jsx)(Z.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eK&&(0,n.jsx)(ex.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(ek,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:j})})]})]})})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Deployment"}),(0,n.jsx)(K.Z,{children:"Success Responses"}),(0,n.jsxs)(K.Z,{children:["Slow Responses ",(0,n.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,n.jsx)(V.Z,{children:e4.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.api_base}),(0,n.jsx)(B.Z,{children:e.total_count}),(0,n.jsx)(B.Z,{children:e.slow_count})]},l))})]})})})]}),(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,n.jsx)(ep.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,n.jsxs)(h.Z,{numItems:1,children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,n.jsx)(eg.Z,{})]})]}),j?(0,n.jsx)(n.Fragment,{children:lt.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,n.jsx)(n.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsx)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||eR[0],value:eL||eR[0],onValueChange:e=>eU(e),children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,n.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,n.jsx)(Z.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eE&&(0,n.jsx)("table",{children:(0,n.jsx)("tbody",{children:Object.entries(eE).map((e,l)=>{var s;let[t,a]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[a];return null==r&&(r=e9),(0,n.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,n.jsx)("td",{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)("td",{children:(0,n.jsx)(N.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(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,n.jsx)(x.Z,{className:"mt-6 mr-8",onClick:lf,children:"Save"})]})]})]})})};function eR(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:r,Paragraph:i}=et.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,n.jsxs)(S.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,n.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"User ID"}),(0,n.jsx)(Z.Z,{children:null==a?void 0:a.user_id})]}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{children:"Invitation Link"}),(0,n.jsx)(Z.Z,{children:(0,n.jsx)(Z.Z,{children:o()})})]}),(0,n.jsx)("div",{className:"flex justify-end mt-5",children:(0,n.jsx)(_.CopyToClipboard,{text:o(),onCopy:()=>w.ZP.success("Copied!"),children:(0,n.jsx)(x.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:eD}=b.default;var eM=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,r.useState)(null),[c]=v.Z.useForm(),[u,h]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]),[_,k]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)(),[E,O]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,m.So)(s,l,"any"),t=[];for(let l=0;l{P&&O(new URL("/",window.location.href).toString())},[P]);let T=async e=>{try{var t;w.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let a=await (0,m.Ov)(s,null,e);console.log("user create Response:",a),g(a.key);let n=(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:n,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};A(e),k(!0)}else(0,m.XO)(s,n).then(e=>{e.has_user_setup_sso=!1,A(e),k(!0)});w.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,n.jsxs)(S.Z,{title:"Invite User",visible:u,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,n.jsxs)(v.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(v.Z.Item,{label:"User Email",name:"user_email",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",children:(0,n.jsx)(b.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,n.jsx)(eD,{value:e.team_id,children:e.team_alias},e.team_id)):(0,n.jsx)(eD,{value:null,children:"Default Team"},"default")})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),j&&(0,n.jsx)(eR,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:k,baseUrl:E,invitationLinkData:N})]})},eF=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,r.useState)(a),[c]=v.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,n.jsx)(S.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,n.jsx)(v.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eL=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,u]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)(1),[_,b]=r.useState(null),[v,S]=(0,r.useState)(null),[k,N]=(0,r.useState)(!1),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(!1),[E,O]=(0,r.useState)(null),[T,D]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let H=e=>{O(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,m.Eb)(l,[E]),w.ZP.success("User deleted successfully"),p){let e=p.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),w.ZP.error("Failed to delete user")}P(!1),O(null)},J=async()=>{C(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,m.pf)(l,e,null),w.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}p&&j(p.map(l=>l.user_id===e.user_id?e:l)),C(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);u(l),j(l.users||[])}else{let e=await (0,m.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),u(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,m.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,Z]),p&&l&&s&&a&&i)?(0,n.jsx)("div",{style:{width:"100%"},children:(0,n.jsxs)(h.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,n.jsx)(eM,{userID:i,accessToken:l,teams:o,possibleUIRoles:T}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,n.jsx)("div",{className:"mb-4 mt-1"}),(0,n.jsx)(eo.Z,{children:(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(z.Z,{className:"mt-5",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"User ID"}),(0,n.jsx)(K.Z,{children:"User Email"}),(0,n.jsx)(K.Z,{children:"Role"}),(0,n.jsx)(K.Z,{children:"User Spend ($ USD)"}),(0,n.jsx)(K.Z,{children:"User Max Budget ($ USD)"}),(0,n.jsx)(K.Z,{children:"API Keys"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:p.map(e=>{var l,s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id||"-"}),(0,n.jsx)(B.Z,{children:e.user_email||"-"}),(0,n.jsx)(B.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,n.jsx)(B.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,n.jsx)(B.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(h.Z,{numItems:2,children:e.key_count>0?(0,n.jsxs)(F.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,n.jsx)(F.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,onClick:()=>{C(e),N(!0)},children:"View Keys"}),(0,n.jsx)(U.Z,{icon:M.Z,onClick:()=>H(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,n.jsx)(eF,{visible:k,possibleUIRoles:T,onCancel:J,user:I,onSubmit:Y}),A&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,n.jsxs)("div",{className:"mt-2",children:[(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,n.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!p)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),y(e)};return(0,n.jsxs)("div",{className:"flex justify-between items-center",children:[(0,n.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,n.jsx)("div",{children:"Loading..."})},eU=e=>{var l,s;let{visible:t,onCancel:a,onSubmit:r,initialData:i,mode:o}=e,[d]=v.Z.useForm(),c=async e=>{try{let l={email:e.user_email,id:e.user_id,role:e.role};r(l),d.resetFields(),w.ZP.success("Successfully ".concat("add"===o?"added":"updated"," team member"))}catch(e){w.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}};return(0,n.jsx)(S.Z,{title:"add"===o?"Add Team Member":"Edit Team Member",visible:t,width:800,footer:null,onCancel:a,children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{user_email:(null==i?void 0:null===(l=i.email)||void 0===l?void 0:l.trim())||"",user_id:(null==i?void 0:null===(s=i.id)||void 0===s?void 0:s.trim())||"",role:(null==i?void 0:i.role)||"user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)("div",{className:"text-center mb-4",children:(0,n.jsx)(Z.Z,{children:"OR"})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})}),(0,n.jsxs)("div",{style:{textAlign:"right",marginTop:"20px"},children:[(0,n.jsx)(C.ZP,{onClick:a,style:{marginRight:8},children:"Cancel"}),(0,n.jsx)(C.ZP,{type:"primary",htmlType:"submit",children:"add"===o?"Add Member":"Save Changes"})]})]})})};console.log=function(){};var ez=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o}=e;(0,r.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&(async()=>{let e;e="Admin"!=o&&"Admin Viewer"!=o?await (0,m.It)(t,i):await (0,m.It)(t),console.log("givenTeams: ".concat(e)),a(e)})()},[l]);let[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:y,Paragraph:_}=et.default,[k,A]=(0,r.useState)(""),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(l?l[0]:null),[D,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)([]),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(null),[ed,ec]=(0,r.useState)({}),em=e=>{T(e),E(!0)},eu=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let n=await (0,m.Gh)(t,e);l&&a(l.map(e=>e.team_id===s?n.data:e)),w.ZP.success("Team updated successfully"),E(!1),T(null)},eh=()=>{X(!1),Q(!1),c.resetFields()},ex=async e=>{er(e),ea(!0)},ep=async()=>{if(null!=en&&null!=l&&null!=t){try{await (0,m.rs)(t,en);let e=l.filter(e=>e.team_id!==en);a(e)}catch(e){console.error("Error deleting the team:",e)}ea(!1),er(null)}};(0,r.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,m.It)(t,i):await (0,m.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,m.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eg=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let n=null==e?void 0:e.team_alias,r=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=null==e?void 0:e.organization_id;if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),r.includes(n))throw Error("Team alias ".concat(n," already exists, please pick another alias"));w.ZP.info("Creating Team");let o=await (0,m.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),w.ZP.success("Team created"),J(!1)}}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the team: "+e,20)}},ef=async(e,s)=>{try{if(null!=t&&null!=l){let n;w.ZP.info("Adding Member");let r={role:e.role,user_email:e.user_email,user_id:e.user_id};"add"==s?(n=await (0,m.cu)(t,O.team_id,r),w.ZP.success("Member added")):(n=await (0,m.sN)(t,O.team_id,{role:e.role,user_id:e.id,user_email:e.email}),w.ZP.success("Member updated"));let i=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(n.data.team_id)),e.team_id===n.data.team_id));if(console.log("foundIndex: ".concat(i)),-1!==i){let e=[...l];e[i]=n.data,a(e),T(n.data)}X(!1)}}catch(e){console.error("Error creating the team:",e)}},eZ=async e=>{ef(e,"add")},ey=async e=>{ef(e,"edit")};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"All Teams"}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Team Name"}),(0,n.jsx)(K.Z,{children:"Team ID"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"TPM / RPM Limits"}),(0,n.jsx)(K.Z,{children:"Info"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,n.jsx)(ej.Z,{title:e.team_id,children:e.team_id})}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,n.jsx)(B.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,n.jsx)(B.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].keys&&ed[e.team_id].keys.length," ","Keys"]}),(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].members_with_roles&&ed[e.team_id].members_with_roles.length," ","Members"]})]}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>em(e)}),(0,n.jsx)(U.Z,{onClick:()=>ex(e.team_id),icon:M.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),es&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:ep,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{ea(!1),er(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>J(!0),children:"+ Create New Team"}),(0,n.jsx)(S.Z,{title:"Create Team",visible:D,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:eg,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Additional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,n.jsx)(p.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"Team Members"}),(0,n.jsx)(_,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{T(e)},children:e.team_alias},l))}):(0,n.jsxs)(_,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:O?O.members_with_roles.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsx)(B.Z,{children:e.role}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{Q(!0),eo({id:e.user_id,email:e.user_email,role:e.role})}}),(0,n.jsx)(U.Z,{onClick:()=>{},icon:M.Z,size:"sm"})]}):null})]},l)):null})]})}),(0,n.jsx)(eU,{visible:$,onCancel:eh,onSubmit:ey,initialData:ei,mode:"edit"}),O&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:a}=e,[r]=v.Z.useForm();return(0,n.jsx)(S.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:eu,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee&&ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:P,onCancel:()=>{E(!1),T(null)},team:O,onSubmit:eu})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"==o||O&&(e=>{for(let l=0;lX(!0),children:"+ Add member"}):null,(0,n.jsx)(S.Z,{title:"Add member",visible:Y,width:800,footer:null,onOk:()=>{X(!1),Q(!1),c.resetFields()},onCancel:eh,children:(0,n.jsxs)(v.Z,{form:d,onFinish:eZ,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})};let eV=async(e,l,s)=>{if(null!=l)try{w.ZP.info("Creating Organization"),console.log("formValues: "+JSON.stringify(e));let t=await (0,m.H1)(l,e);console.log("response for organization create call: ".concat(t)),w.ZP.success("Organization created"),sessionStorage.removeItem("organizations"),s(!1)}catch(e){console.error("Error creating the organization:",e),w.ZP.error("Error creating the organization: "+e,20)}};var eB=e=>{let{title:l="Create Organization",onCancel:s,accessToken:t,availableModels:a=[],initialValues:i={},submitButtonText:o="Create",modelSelectionType:d="multiple"}=e,[c]=v.Z.useForm(),[m,u]=(0,r.useState)(!1),[h,j]=(0,r.useState)({name:i.name||"",models:i.models||[],maxBudget:i.maxBudget||null,budgetDuration:i.budgetDuration||null,tpmLimit:i.tpmLimit||null,rpmLimit:i.rpmLimit||null});console.log("availableModels: ".concat(a));let g=async e=>{null!=t&&(await eV(e,t,u),u(!1))};return(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)(x.Z,{onClick:()=>u(!0),className:"mx-auto",type:"button",children:["+ Create New ",l]}),(0,n.jsx)(S.Z,{title:"Create ".concat(l),visible:m,width:800,footer:null,onCancel:()=>{u(!1),s&&s()},children:(0,n.jsxs)(v.Z,{form:c,onFinish:g,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"".concat(l," Name"),name:"organization_alias",rules:[{required:!0,message:"Please input a ".concat(l," name")}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),a.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:o})})]})})]})};let eq=(e,l)=>{for(let s=0;s{let{userRole:l,userID:s,selectedOrganization:t,onMemberAdd:a}=e,[i,o]=r.useState(!1),[d]=v.Z.useForm();return(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"===l||t&&eq(t,s)?(0,n.jsx)(x.Z,{className:"mx-auto mb-5",onClick:()=>o(!0),children:"+ Add member"}):null,(0,n.jsxs)(S.Z,{title:"Add member",visible:i,width:800,footer:null,onOk:()=>{d.submit()},onCancel:()=>{d.resetFields(),o(!1)},children:[(0,n.jsx)(Z.Z,{className:"mb-2",children:"User must exist in proxy. Get User ID from 'Users' tab."}),(0,n.jsxs)(v.Z,{form:d,onFinish:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"internal_user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"org_admin",children:(0,n.jsxs)("div",{className:"flex",children:["Org Admin"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can add and remove members, and change their roles."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can view/create keys for themselves within organization."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user_viewer",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User Viewer"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can only view their keys within organization."})]})})]})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})]})]})},eW=e=>{var l;let{selectedEntity:s,onEditSubmit:t,editModalComponent:a,entityType:i}=e,[o,d]=r.useState(!1);return(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"team"===i?"Team Member":"Organization Member"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:(null!==(l=null==s?void 0:s.members)&&void 0!==l?l:[]).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id}),(0,n.jsx)(B.Z,{children:e.user_role})]},"".concat(e.user_id,"-").concat(l)))})]})}),s&&(0,n.jsx)(a,{visible:o,onCancel:()=>{d(!1)},entity:s,onSubmit:e=>{t(e),d(!1)}})]})},eH=e=>{let{data:l,columns:s,actions:t,emptyMessage:a="No data available",deleteModal:r}=e,i=(e,l)=>{let s=l[e.accessor];return e.cellRenderer?e.cellRenderer(s,l):Array.isArray(s)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===s.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"None"})}):s.map((e,l)=>(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:String(e).length>30?"".concat(String(e).slice(0,30),"..."):e})},l))}):(null==s?void 0:s.toString())||""};return(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[40vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[s.map((e,l)=>(0,n.jsx)(K.Z,{children:e.header},l)),t&&t.length>0&&(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map((e,l)=>(0,n.jsxs)(W.Z,{children:[s.map((l,s)=>(0,n.jsx)(B.Z,{style:{maxWidth:l.width||"4px",whiteSpace:"pre-wrap",overflow:"hidden",...l.style},children:"id"===l.accessor?(0,n.jsx)(ej.Z,{title:e[l.accessor],children:i(l,e)}):i(l,e)},s)),t&&t.length>0&&(0,n.jsx)(B.Z,{children:t.map((l,s)=>{var t;return(null===(t=l.condition)||void 0===t?void 0:t.call(l,e))!==!1&&(0,n.jsx)(ej.Z,{title:l.tooltip,children:(0,n.jsx)(U.Z,{icon:l.icon,size:"sm",onClick:()=>l.onClick(e),className:"cursor-pointer mx-1"})},s)})})]},l)):(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:s.length+(t?1:0),children:(0,n.jsx)(Z.Z,{className:"text-center",children:a})})})})]})})};console.log=function(){};let eG=e=>{let{visible:l,onCancel:s,entity:t,onSubmit:a}=e;return(0,n.jsx)("div",{})},eJ=e=>{let{organizations:l,userRole:s,onEdit:t,onDelete:a,isDeleteModalOpen:r,setIsDeleteModalOpen:i,selectedOrganization:o,setSelectedOrganization:d}=e,c=[...t&&"Admin"===s?[{icon:void 0,onClick:e=>t(e),condition:()=>"Admin"===s,tooltip:"Edit organization"}]:[],...a&&"Admin"===s?[{icon:void 0,onClick:e=>a(e),condition:()=>"Admin"===s,tooltip:"Delete organization"}]:[]];return(0,n.jsx)(eH,{data:l,columns:[{header:"Organization Name",accessor:"organization_alias",width:"4px",style:{whiteSpace:"pre-wrap",overflow:"hidden"}},{header:"Organization ID",accessor:"organization_id",width:"4px",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"}},{header:"Spend (USD)",accessor:"spend"},{header:"Budget (USD)",accessor:"max_budget",cellRenderer:e=>null!=e?e:"No limit"},{header:"Models",accessor:"models"},{header:"TPM / RPM Limits",accessor:"limits",cellRenderer:(e,l)=>(0,n.jsxs)("div",{className:"text-sm",children:[(0,n.jsxs)("span",{children:["TPM: ",l.tpm_limit?l.tpm_limit:"Unlimited"]}),(0,n.jsx)("br",{}),(0,n.jsxs)("span",{children:["RPM: ",l.rpm_limit?l.rpm_limit:"Unlimited"]})]})},{header:"Info",accessor:"info",cellRenderer:(e,l)=>{var s;return(0,n.jsx)("div",{className:"space-y-1",children:(0,n.jsxs)("div",{className:"text-sm",children:[(null===(s=l.members)||void 0===s?void 0:s.length)||0," Members"]})})}}],actions:c,emptyMessage:"No organizations available",deleteModal:{isOpen:r,onConfirm:()=>{o&&a&&a(o),i(!1),d(null)},onCancel:()=>{i(!1),d(null)},title:"Delete Organization",message:"Are you sure you want to delete this organization?"}})};var eY=e=>{let{accessToken:l,userID:s,userRole:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),{Title:d,Paragraph:c}=et.default,[x,p]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!l||!s||!t)return;let e=async()=>{try{let e=(await (0,m.So)(l,s,t)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}catch(e){console.error("Error fetching user models:",e)}},n=async()=>{let e;e=await (0,m.r6)(l),console.log("givenOrganizations: ".concat(e)),o(e),sessionStorage.setItem("organizations",JSON.stringify(e))};a&&(e(),n())},[l]);let _=async e=>{if(j&&l)try{let s={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,m.vh)(l,j.organization_id,s),w.ZP.success("Member added")}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the organization: "+e)}};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"✨ All Organizations"}),(0,n.jsxs)(Z.Z,{className:"mb-2",children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,n.jsx)("a",{href:"https://www.litellm.ai/#trial",className:"text-blue-600 hover:text-blue-800 underline",target:"_blank",rel:"noopener noreferrer",children:"here"})]}),t?eJ({organizations:i,userRole:t,isDeleteModalOpen:x,setIsDeleteModalOpen:p,selectedOrganization:j,setSelectedOrganization:g}):null]}),"Admin"==t&&l&&a?(0,n.jsx)(eB,{title:"Organization",accessToken:l,availableModels:f,submitButtonText:"Create Organization"}):null,a?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"Organization Members"}),(0,n.jsx)(c,{children:"If you belong to multiple organizations, this setting controls which organizations' members you see."}),i&&i.length>0?(0,n.jsx)(H.Z,{children:i.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{g(e)},children:e.organization_alias},l))}):(0,n.jsxs)(c,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eK,{userRole:t,userID:s,selectedOrganization:j,onMemberAdd:_}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eW,{selectedEntity:j,onEditSubmit:()=>{},editModalComponent:eG,entityType:"organization"}):null]})})},eX=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:a,premiumUser:o}=e,[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:p,Paragraph:j}=et.default,[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)(null),[b,k]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(!1),[D,M]=(0,r.useState)(!1),[F,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)([]),[ei,eo]=(0,r.useState)(null),ed=(0,i.useRouter)(),[ec,em]=(0,r.useState)(null);console.log=function(){};let[eu,eh]=(0,r.useState)(""),ex="All IP Addresses Allowed";try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let ep=async()=>{try{if(!0!==o){w.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,m.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),w.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,m.eH)(t,e.ip);let l=await (0,m.PT)(t);er(l),w.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),w.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),ea(!0)},ef=async()=>{if(ei&&t)try{await (0,m.$I)(t,ei);let e=await (0,m.PT)(t);er(e.length>0?e:[ex]),w.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),w.ZP.error("Failed to delete IP address ".concat(e))}finally{ea(!1),eo(null)}},eZ=()=>{X(!1)},ey=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(ed){let{protocol:e,host:l}=window.location;eh("".concat(e,"//").concat(l))}},[ed]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,m.Xd)(t,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let s=l.users;console.log("proxy viewers response: ".concat(s)),s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(s));let a=(await (0,m.Xd)(t,"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)),_(e),em(await (0,m.lg)(t))}})()},[t]);let e_=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,n.jsx)(H.Z,{value:l,children:ey.map((e,l)=>(0,n.jsx)(G.Z,{value:e,children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,n.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ek=async e=>{try{if(null!=t&&null!=y){w.ZP.info("Making API Call");let l=await (0,m.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),y.push(l),_(y)),w.ZP.success("Refresh tab to see updated user role"),M(!1)}}catch(e){console.error("Error creating the key:",e)}},eN=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call");let s=await (0,m.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)});let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,m.pf)(t,e,"proxy_admin"),a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)}),console.log("response for team create call: ".concat(s));let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),T(!1)}}catch(e){console.error("Error creating the key:",e)}},eC=async e=>{if(null==t)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,m.K_)(t,l)};return console.log("admins: ".concat(null==y?void 0:y.length)),(0,n.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,n.jsx)(p,{level:4,children:"Admin Access "}),(0,n.jsxs)(j,{children:[a&&(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:y?y.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsxs)(B.Z,{children:[" ",(null==ec?void 0:null===(s=ec[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>M(!0)}),(0,n.jsx)(S.Z,{title:"Update role",visible:D,width:800,footer:null,onOk:e_,onCancel:eb,children:eS(ek,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("div",{className:"flex justify-start",children:[(0,n.jsx)(x.Z,{className:"mr-4 mb-5",onClick:()=>T(!0),children:"+ Add admin"}),(0,n.jsx)(S.Z,{title:"Add admin",visible:O,width:800,footer:null,onOk:()=>{T(!1),c.resetFields(),d.resetFields()},onCancel:()=>{T(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,n.jsx)(eR,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,n.jsx)(x.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,n.jsx)(S.Z,{title:"Add viewer",visible:P,width:800,footer:null,onOk:()=>{E(!1),c.resetFields(),d.resetFields()},onCancel:()=>{E(!1),c.resetFields(),d.resetFields()},children:ev(eN)})]})})]}),(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(p,{level:4,children:" ✨ Security Settings"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:()=>!0===o?J(!0):w.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,n.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,n.jsx)(S.Z,{title:"Add SSO",visible:F,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:e=>{eI(e),eC(e),J(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,n.jsx)(I.Z.Password,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,n.jsx)(I.Z.Password,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,n.jsxs)(S.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:eZ,onCancel:()=>{X(!1)},children:[(0,n.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{onClick:eZ,children:"Done"})})]}),(0,n.jsx)(S.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,n.jsx)(x.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"IP Address"}),(0,n.jsx)(K.Z,{className:"text-right",children:"Action"})]})}),(0,n.jsx)(V.Z,{children:en.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e}),(0,n.jsx)(B.Z,{className:"text-right",children:e!==ex&&(0,n.jsx)(x.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,n.jsx)(S.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,n.jsxs)(v.Z,{onFinish:ej,children:[(0,n.jsx)(v.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,n.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,n.jsx)(v.Z.Item,{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,n.jsx)(S.Z,{title:"Confirm Delete",visible:es,onCancel:()=>ea(!1),onOk:ef,footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>ef(),children:"Yes"},"delete"),(0,n.jsx)(x.Z,{onClick:()=>ea(!1),children:"Close"},"close")],children:(0,n.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,n.jsxs)(ew.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,n.jsxs)("a",{href:l,target:"_blank",children:[(0,n.jsx)("b",{children:l})," "]})]})]})]})},e$=s(92858),eQ=s(44643),e0=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:r}=e,[i]=v.Z.useForm();return(0,n.jsxs)(v.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{align:"center",children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,n.jsx)(v.Z.Item,{name:e.field_name,children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,n.jsx)(v.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,n.jsx)("div",{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},e1=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,m.RQ)(l).then(e=>{a(e)})},[l]),(0,n.jsx)(e0,{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:n,...r}=a;console.log("slack_alerting: ".concat(n,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,m.jA)(l,"alerting_args",r),"boolean"==typeof n&&(!0==n?(0,m.jA)(l,"alerting",["slack"]):(0,m.jA)(l,"alerting",[])),w.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},e2=s(86582);let{Title:e4,Paragraph:e5}=et.default;console.log=function(){};var e8=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[u,j]=(0,r.useState)(!1),[g]=v.Z.useForm(),[f,y]=(0,r.useState)(null),[_,k]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,O]=(0,r.useState)([]),[T,D]=(0,r.useState)(!1),[M,F]=(0,r.useState)([]),[H,J]=(0,r.useState)(null),[Y,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),es=e=>{E.includes(e)?O(E.filter(l=>l!==e)):O([...E,e])},et={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,r.useEffect)(()=>{l&&s&&t&&(0,m.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),F(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),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ea=e=>E&&E.includes(e),en=()=>{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,m.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Email settings updated successfully")},er=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,m.K_)(l,{environment_variables:s}),w.ZP.success("Callback added successfully"),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eu=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,m.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),w.ZP.success("Callback ".concat(s," added successfully")),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),y(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",Y)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,n.jsxs)("div",{className:"w-full mx-4",children:[(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,n.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,n.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,n.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Active Logging Callbacks"}),(0,n.jsx)(h.Z,{numItems:2,children:(0,n.jsx)(L.Z,{className:"max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(K.Z,{children:"Callback Name"})})}),(0,n.jsx)(V.Z,{children:i.map((e,s)=>(0,n.jsxs)(W.Z,{className:"flex justify-between",children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.name})}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"flex justify-between",children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(Z.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,n.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{children:"Slack Webhook URL"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:"region_outage_alerts"==s?a?(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)}):(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,n.jsx)(x.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let n=(null==a?void 0:a.value)||"";console.log("newWebhookValue",n),e[s]=n}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,m.K_)(l,s)}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(e1,{accessToken:l,premiumUser:a})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Email Settings"}),(0,n.jsxs)(Z.Z,{children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,n.jsx)("br",{})]}),(0,n.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,n.jsx)(B.Z,{children:(0,n.jsx)("ul",{children:(0,n.jsx)(h.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,n.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,n.jsxs)("div",{children:[(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,n.jsxs)(Z.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-2",children:l}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,n.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,n.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,n.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,n.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,n.jsx)(x.Z,{className:"mt-2",onClick:()=>en(),children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,n.jsxs)(S.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>D(!1),footer:null,children:[(0,n.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,n.jsx)(v.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e2.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,n.jsx)(b.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,n.jsx)(G.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,n.jsx)(e2.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,n.jsx)(p.Z,{type:"password"})},e)),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,n.jsx)(S.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,n.jsxs)(v.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,n.jsx)(e2.Z,{label:l,name:l,children:(0,n.jsx)(p.Z,{type:"password",defaultValue:s})},l)})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:e3}=b.default;var e6=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=v.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,n.jsx)(S.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,n.jsxs)(v.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:n}=e,r=[...t.fallbacks||[],{[l]:n}],o={...t,fallbacks:r};console.log(o);try{(0,m.K_)(s,{router_settings:o}),a(o)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,n.jsx)(H.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>u(e),children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsx)(eu.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},e7=s(33619);async function e9(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new e7.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});w.ZP.success((0,n.jsxs)("span",{children:["Test model=",(0,n.jsx)("strong",{children:e}),", received model=",(0,n.jsx)("strong",{children:l.model}),". See"," ",(0,n.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let le={ttl:3600,lowest_latency_buffer:0},ll=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,n.jsx)(g.Z,{children:"latency-based-routing"==l?(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,n.jsx)(Z.Z,{children:"No specific settings"})})]})};var ls=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)(!1),[b]=v.Z.useForm(),[S,k]=(0,r.useState)(null),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,m.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,m.YU)(l).then(e=>{g(e)}))},[l,s,t]);let O=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,m.K_)(l,{router_settings:i}),o({...i}),C(i.routing_strategy),w.ZP.success("Router settings updated successfully")}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}}},T=(e,l)=>{g(j.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=j[s].field_value;if(null!=t&&void 0!=t)try{(0,m.jA)(l,e,t);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,m.ao)(l,e);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},J=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,I];if("routing_strategy_args"==l&&"latency-based-routing"==I){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,m.K_)(l,{router_settings:s})}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully")};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,n.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,n.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,n.jsx)(y.Z,{children:"Router Settings"}),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,n.jsx)(B.Z,{children:"routing_strategy"==l?(0,n.jsxs)(H.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:C,children:[(0,n.jsx)(G.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,n.jsx)(G.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,n.jsx)(G.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,n.jsx)(ll,{selectedStrategy:I,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:le,paramExplanation:E})]}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>J(i),children:"Save Changes"})})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model Name"}),(0,n.jsx)(K.Z,{children:"Fallbacks"})]})}),(0,n.jsx)(V.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:t}),(0,n.jsx)(B.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>e9(t,l),children:"Test Fallback"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,n.jsx)(e6,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"}),(0,n.jsx)(K.Z,{children:"Status"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:j.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,n.jsx)(B.Z,{children:"Integer"==e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(x.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lt=s(93142),la=s(45246),ln=s(96473),lr=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,r.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,n)=>{let r=[...t];r[e]=[l,n],a(r),null==s||s(Object.fromEntries(r))};return(0,n.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(lt.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,n.jsx)(p.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,n.jsx)(p.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,n.jsx)(la.Z,{onClick:()=>i(l)})]},l)}),(0,n.jsx)(C.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,n.jsx)(ln.Z,{}),children:"Add Header"})]})};let{Option:li}=b.default;var lo=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=v.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,n.jsx)(S.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,n.jsxs)(v.Z,{form:a,onFinish:e=>{console.log(e);let n=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,m.Vt)(l,e),s(n)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(lr,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},ld=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,m.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,m.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),w.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Path"}),(0,n.jsx)(K.Z,{children:"Target"}),(0,n.jsx)(K.Z,{children:"Headers"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:i.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.path})}),(0,n.jsx)(B.Z,{children:e.target}),(0,n.jsx)(B.Z,{children:JSON.stringify(e.headers)}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,n.jsx)(lo,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lc=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[r]=v.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call");let l=await (0,m.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),w.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,n.jsxs)(v.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lm=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=v.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call"),t(!0);let l=await (0,m.qI)(s,e);a(e=>e?[...e,l]:[l]),w.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},lu=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[a,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,u]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,m.O3)(l).then(e=>{u(e)})},[l]);let h=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),i(!0))},p=async(e,s)=>{if(null==l)return;w.ZP.info("Request made"),await (0,m.NV)(l,e);let t=[...c];t.splice(s,1),u(t),w.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,m.O3)(l).then(e=>{u(e)})};return(0,n.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,n.jsx)(x.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,n.jsx)(lc,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:u}),o&&(0,n.jsx)(lm,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:u,existingBudget:o,handleUpdateCall:j}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"Create a budget to assign to customers."}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Budget ID"}),(0,n.jsx)(K.Z,{children:"Max Budget"}),(0,n.jsx)(K.Z,{children:"TPM"}),(0,n.jsx)(K.Z,{children:"RPM"})]})}),(0,n.jsx)(V.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.budget_id}),(0,n.jsx)(B.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,n.jsx)(B.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,n.jsx)(B.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>p(e.budget_id,l)})]},l))})]})]}),(0,n.jsxs)("div",{className:"mt-5",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"How to use budget id"}),(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,n.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,n.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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)'})})]})]})]})]})},lh=s(77398),lx=s.n(lh),lp=s(24525),lj=s(71594);let lg=e=>e?"string"==typeof e?e:"object"==typeof e?e.text?e.text:e.content?e.content:JSON.stringify(e):String(e):"N/A",lf=e=>{let{data:l}=e,s=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,n.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Request"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.request),null,2)})]}),(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.response),null,2)})]}),l.metadata&&Object.keys(l.metadata).length>0&&(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"}),(0,n.jsx)("div",{children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(l.metadata,null,2)})]})]})};var lZ=e=>{let{accessToken:l,token:s,userRole:t,userID:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)(!0),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(null);(0,lp.Cl)();let j=[{header:"Time",accessorKey:"startTime",cell:e=>(0,n.jsx)("span",{children:lx()(e.getValue()).format("MMM DD HH:mm:ss")})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,n.jsx)("span",{className:"font-mono text-xs",children:String(e.getValue()||"")})},{header:"Type",accessorKey:"call_type",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Request",accessorKey:"messages",cell:e=>{let l=e.getValue();try{let e="string"==typeof l?JSON.parse(l):l,t="";if(Array.isArray(e)){var s;t=lg(null===(s=e[0])||void 0===s?void 0:s.content)}else t=lg(e);return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:t})}catch(e){return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:lg(l)})}}},{header:"Model",accessorKey:"model",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,n.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,n.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"User",accessorKey:"user",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Cost",accessorKey:"spend",cell:e=>(0,n.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();return l&&0!==Object.keys(l).length?(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(l).map(e=>{let[l,s]=e;return(0,n.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[l,": ",String(s)]},l)})}):"-"}}];return((0,lj.b7)({data:i,columns:j,state:{sorting:u},onSortingChange:h,getCoreRowModel:(0,lp.sC)(),getSortedRowModel:(0,lp.tj)()}),(0,r.useEffect)(()=>{(async()=>{if(!l||!s||!t||!a){console.log("got None values for one of accessToken, token, userRole, userID");return}try{c(!0);let e=lx()().format("YYYY-MM-DD HH:mm:ss"),n=lx()().subtract(24,"hours").format("YYYY-MM-DD HH:mm:ss"),r=await (0,m.h3)(l,s,t,a,n,e);console.log("response from uiSpendLogsCall:",r);let i=r.map((e,l)=>({...e,key:l.toString()}));o(i)}catch(e){console.error("Error fetching logs:",e)}finally{c(!1)}})()},[l,s,t,a]),l&&s&&t&&a)?(0,n.jsx)("div",{className:"w-[90%] mx-auto px-4",children:(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow w-full",children:[(0,n.jsxs)("div",{className:"p-4 border-b flex justify-between items-center",children:[(0,n.jsxs)("div",{className:"flex space-x-4 items-center",children:[(0,n.jsx)("input",{type:"text",placeholder:"Search by request ID, model, or user...",className:"px-4 py-2 border rounded-lg w-80"}),(0,n.jsxs)("button",{className:"px-4 py-2 border rounded-lg flex items-center gap-2",children:[(0,n.jsx)("span",{children:"Filters"}),(0,n.jsx)("span",{className:"text-xs bg-gray-100 px-2 py-1 rounded",children:"0"})]}),(0,n.jsxs)("select",{className:"px-4 py-2 border rounded-lg",children:[(0,n.jsx)("option",{children:"Last 24 hours"}),(0,n.jsx)("option",{children:"Last 7 days"}),(0,n.jsx)("option",{children:"Last 30 days"})]})]}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Export"})})]}),(0,n.jsx)("div",{className:"overflow-x-auto w-full",children:(0,n.jsxs)(z.Z,{className:"w-full table-fixed",children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:j.map(e=>(0,n.jsx)(K.Z,{className:"".concat("Request ID"===e.header?"w-32":""," whitespace-nowrap"),children:e.header},e.header))})}),(0,n.jsx)(V.Z,{children:i.map(e=>(0,n.jsxs)(r.Fragment,{children:[(0,n.jsx)(W.Z,{className:"cursor-pointer hover:bg-gray-50",onClick:()=>p(x===e.request_id?null:e.request_id),children:j.map(l=>{var s;return(0,n.jsx)(B.Z,{className:"Request ID"===l.header?"w-32 truncate":"",children:l.cell?l.cell({getValue:()=>e[l.accessorKey],row:{original:e}}):(0,n.jsx)("span",{children:String(null!==(s=e[l.accessorKey])&&void 0!==s?s:"")})},l.header)})}),x===e.request_id&&(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:j.length,className:"p-0",children:(0,n.jsx)(lf,{data:{request:"string"==typeof e.messages?JSON.parse(e.messages):e.messages,response:"string"==typeof e.response?JSON.parse(e.response):e.response,metadata:e.metadata}})})})]},e.request_id||e.startTime))})]})})]})}):(console.log("got None values for one of accessToken, token, userRole, userID"),null)},ly=s(92699),l_=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,n.jsx)(Z.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,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,n.jsx)(ei.Z,{children:"LlamaIndex"}),(0,n.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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 ')})})]})]})]})})})},lb=s(243),lv=s(94263);async function lw(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,n=new e7.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await n.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){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lS=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,r.useState)(i?"custom":"session"),[c,j]=(0,r.useState)(""),[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)([]),[v,S]=(0,r.useState)(void 0),[k,N]=(0,r.useState)([]),I=(0,r.useRef)(null);(0,r.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,m.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),S(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,r.useEffect)(()=>{I.current&&setTimeout(()=>{var e;null===(e=I.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[y]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===g.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){w.ZP.error("Please provide an API key or select Current UI Session");return}let n=[...y,{role:"user",content:g}];_(n);try{v&&await lw(n,(e,l)=>C("assistant",e,l),v,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}f("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,n.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsx)(ed.Z,{children:(0,n.jsx)(ei.Z,{children:"Chat"})}),(0,n.jsx)(em.Z,{children:(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"API Key Source"}),(0,n.jsx)(b.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,n.jsx)(p.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:j,value:c})]}),(0,n.jsxs)(u.Z,{className:"mx-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model:"}),(0,n.jsx)(b.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),S(e)},options:k,style:{width:"350px"},showSearch:!0})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{_([]),w.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,n.jsxs)(z.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{})})}),(0,n.jsxs)(V.Z,{children:[y.map((e,l)=>(0,n.jsx)(W.Z,{children:(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,n.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,n.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,n.jsx)(lb.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...r}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,n.jsx)(eI.Z,{style:lv.Z,language:i[1],PreTag:"div",...r,children:String(a).replace(/\n$/,"")}):(0,n.jsx)("code",{className:t,...r,children:a})}},children:e.content})})]})},l)),(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{children:(0,n.jsx)("div",{ref:I,style:{height:"1px"}})})})]})]}),(0,n.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,n.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,n.jsx)(p.Z,{type:"text",value:g,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,n.jsx)(x.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},lk=s(19226),lN=s(61787),lI=s(92403),lC=s(28595),lA=s(68208),lP=s(9775),lE=s(41361),lO=s(37527),lT=s(15883),lR=s(12660),lD=s(88009),lM=s(41169),lF=s(48231),lL=s(44625),lU=s(55322);let{Sider:lz}=lk.default,lV=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lB=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,n.jsx)(lI.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,n.jsx)(lC.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,n.jsx)(lA.Z,{}),roles:lV},{key:"4",page:"usage",label:"Usage",icon:(0,n.jsx)(lP.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,n.jsx)(lE.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,n.jsx)(lO.Z,{}),roles:lV},{key:"5",page:"users",label:"Internal Users",icon:(0,n.jsx)(lT.Z,{}),roles:lV},{key:"14",page:"api_ref",label:"API Reference",icon:(0,n.jsx)(lR.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,n.jsx)(lD.Z,{})},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,n.jsx)(lM.Z,{}),roles:lV,children:[{key:"15",page:"logs",label:"Logs",icon:(0,n.jsx)(lF.Z,{}),roles:lV},{key:"9",page:"caching",label:"Caching",icon:(0,n.jsx)(lL.Z,{}),roles:lV},{key:"10",page:"budgets",label:"Budgets",icon:(0,n.jsx)(lO.Z,{}),roles:lV}]},{key:"settings",page:"settings",label:"Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,n.jsx)(lR.Z,{}),roles:lV},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV}]}];var lq=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=lB.find(l=>l.page===e);if(l)return l.key;for(let l of lB)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),r=lB.filter(e=>!e.roles||e.roles.includes(s));return(0,n.jsx)(lk.default,{style:{minHeight:"100vh"},children:(0,n.jsx)(lz,{theme:"light",width:220,children:(0,n.jsx)(lN.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:r.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)}}})})})})},lK=s(96889),lW=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lH=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lG=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,p]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[w,S]=(0,r.useState)([]),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)([]),[A,P]=(0,r.useState)([]),[E,O]=(0,r.useState)([]),[T,R]=(0,r.useState)([]),[D,M]=(0,r.useState)({}),[F,U]=(0,r.useState)([]),[J,Y]=(0,r.useState)(""),[X,Q]=(0,r.useState)(["all-tags"]),[ee,el]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[es,et]=(0,r.useState)(null),ea=new Date(d.getFullYear(),d.getMonth(),1),ej=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(ea),ef=ev(ej);function eZ(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 ey=async()=>{if(l)try{let e=await (0,m.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,r.useEffect)(()=>{eb(ee.from,ee.to)},[ee,X]);let e_=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,m.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),v(a)},eb=async(e,s)=>{if(!e||!s||!l)return;let t=await ey();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,m.J$)(l,e.toISOString(),s.toISOString(),0===X.length?void 0:X)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ev(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(eg)),console.log("End date is ".concat(ef));let ew=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eS=()=>ew(()=>l?(0,m.FC)(l):Promise.reject("No access token"),p,"Error fetching overall spend"),ek=()=>ew(()=>l&&s?(0,m.OU)(l,s,eg,ef):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await ew(async()=>(await (0,m.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend})),g,"Error fetching top keys")},eI=async()=>{l&&await ew(async()=>(await (0,m.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),_,"Error fetching top models")},eC=async()=>{l&&await ew(async()=>{let e=await (0,m.mR)(l);return S(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eA=()=>{l&&ew(async()=>(await (0,m.X)(l)).tag_names,C,"Error fetching tag names")},eP=()=>{l&&ew(()=>{var e,s;return(0,m.J$)(l,null===(e=ee.from)||void 0===e?void 0:e.toISOString(),null===(s=ee.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>N(e.spend_per_tag),"Error fetching top tags")},eE=()=>{l&&ew(()=>(0,m.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eO=()=>{l&&ew(()=>(0,m.wd)(l,eg,ef),M,"Error fetching global activity")},eT=()=>{l&&ew(()=>(0,m.xA)(l,eg,ef),U,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ey();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),eS(),ek(),eN(),eI(),eO(),eT(),lH(t)&&(eC(),eA(),eP(),eE()))}})()},[l,s,t,a,eg,ef]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,n.jsxs)(Z.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,n.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,n.jsx)(x.Z,{className:"mt-4",children:(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{className:"mt-2",children:[(0,n.jsx)(ei.Z,{children:"All Up"}),lH(t)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ei.Z,{children:"Team Based Usage"}),(0,n.jsx)(ei.Z,{children:"Customer Usage"}),(0,n.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{})})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"solid",className:"mt-1",children:[(0,n.jsx)(ei.Z,{children:"Cost"}),(0,n.jsx)(ei.Z,{children:"Activity"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,n.jsx)($,{userID:a,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Monthly Spend"}),(0,n.jsx)(ep.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top API Keys"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top Models"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:f,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(lW.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend"})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Provider"}),(0,n.jsx)(K.Z,{children:"Spend"})]})}),(0,n.jsx)(V.Z,{children:T.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.provider}),(0,n.jsx)(B.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"All Up"}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(D.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(D.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,n.jsx)(n.Fragment,{children:F.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,n.jsx)(n.Fragment,{children:F&&F.length>0&&F.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eZ,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(u.Z,{numColSpan:2,children:[(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,n.jsx)(lK.Z,{data:E})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,n.jsx)(ep.Z,{className:"h-72",data:w,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,n.jsx)(u.Z,{numColSpan:2})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.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,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),e_(e.from,e.to,null)}})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Key"}),(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{e_(ee.from,ee.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,n.jsx)(G.Z,{value:String(l),onClick:()=>{e_(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,n.jsx)(L.Z,{className:"mt-4",children:(0,n.jsxs)(z.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Customer"}),(0,n.jsx)(K.Z,{children:"Spend"}),(0,n.jsx)(K.Z,{children:"Total Events"})]})}),(0,n.jsx)(V.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.end_user}),(0,n.jsx)(B.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,n.jsx)(B.Z,{children:e.total_count})]},l)})})]})})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(er.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,n.jsx)(u.Z,{children:o?(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsx)(eh.Z,{value:String(e),children:e},e))]})}):(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsxs)(G.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Spend Per Tag"}),(0,n.jsxs)(Z.Z,{children:["Get Started Tracking cost per tag ",(0,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,n.jsx)(ep.Z,{className:"h-72",data:k,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,n.jsx)(u.Z,{numColSpan:2})]})]})]})]})})};let lJ=e=>{if(e)return e.toISOString().split("T")[0]};function lY(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lX=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,x]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,f]=(0,r.useState)([]),[Z,y]=(0,r.useState)("0"),[_,b]=(0,r.useState)("0"),[v,w]=(0,r.useState)("0"),[S,k]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&S&&(async()=>{f(await (0,m.zg)(l,lJ(S.from),lJ(S.to)))})()},[l]);let N=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),I=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let C=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),f(await (0,m.zg)(l,lJ(e),lJ(s))))};return(0,r.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",g);let e=g;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),p.length>0&&(e=e.filter(e=>p.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 n=e.find(e=>e.name===a.call_type);return n?(n["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),n["Cache hit"]+=a.cache_hit_true_rows||0,n["Cached Completion Tokens"]+=a.cached_completion_tokens||0,n["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(lY(s)),b(lY(t));let n=s+l;n>0?w((s/n*100).toFixed(2)):w("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,p,S,g]),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(h.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select API Keys",value:c,onValueChange:x,children:N.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(er.Z,{enableSelect:!0,value:S,onValueChange:e=>{k(e),C(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Z})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]})]}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,n.jsx)(ep.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,n.jsx)(ep.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l$=()=>{let{Title:e,Paragraph:l}=et.default,[s,t]=(0,r.useState)(""),[a,o]=(0,r.useState)(!1),[d,u]=(0,r.useState)(!1),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[_,b]=(0,r.useState)(!0),v=(0,i.useSearchParams)(),[w,S]=(0,r.useState)({data:[]}),[k,N]=(0,r.useState)(null),I=v.get("userID"),C=v.get("invitation_id"),[A,P]=(0,r.useState)(()=>v.get("page")||"api-keys"),[E,O]=(0,r.useState)(null);return(0,r.useEffect)(()=>{N(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,r.useEffect)(()=>{if(!k)return;let e=(0,es.o)(k);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),O(e.key),u(e.disabled_non_admin_personal_key_creation),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&P("usage")}else console.log("User role not defined");e.user_email?x(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?b("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user),e.auth_header_name&&(0,m.K8)(e.auth_header_name)}},[k]),(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)("div",{children:"Loading..."}),children:C?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):(0,n.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,n.jsx)(c,{userID:I,userRole:s,userEmail:h,premiumUser:a,setProxySettings:y,proxySettings:Z}),(0,n.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,n.jsx)("div",{className:"mt-8",children:(0,n.jsx)(lq,{setPage:e=>{let l=new URLSearchParams(v);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),P(e)},userRole:s,defaultSelectedKey:A})}),"api-keys"==A?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):"models"==A?(0,n.jsx)(eT,{userID:I,userRole:s,token:k,keys:g,accessToken:E,modelData:w,setModelData:S,premiumUser:a}):"llm-playground"==A?(0,n.jsx)(lS,{userID:I,userRole:s,token:k,accessToken:E,disabledPersonalKeyCreation:d}):"users"==A?(0,n.jsx)(eL,{userID:I,userRole:s,token:k,keys:g,teams:p,accessToken:E,setKeys:f}):"teams"==A?(0,n.jsx)(ez,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s}):"organizations"==A?(0,n.jsx)(eY,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s,premiumUser:a}):"admin-panel"==A?(0,n.jsx)(eX,{setTeams:j,searchParams:v,accessToken:E,showSSOBanner:_,premiumUser:a}):"api_ref"==A?(0,n.jsx)(l_,{proxySettings:Z}):"settings"==A?(0,n.jsx)(e8,{userID:I,userRole:s,accessToken:E,premiumUser:a}):"budgets"==A?(0,n.jsx)(lu,{accessToken:E}):"general-settings"==A?(0,n.jsx)(ls,{userID:I,userRole:s,accessToken:E,modelData:w}):"model-hub"==A?(0,n.jsx)(ly.Z,{accessToken:E,publicPage:!1,premiumUser:a}):"caching"==A?(0,n.jsx)(lX,{userID:I,userRole:s,token:k,accessToken:E,premiumUser:a}):"pass-through-settings"==A?(0,n.jsx)(ld,{userID:I,userRole:s,accessToken:E,modelData:w}):"logs"==A?(0,n.jsx)(lZ,{userID:I,userRole:s,token:k,accessToken:E}):(0,n.jsx)(lG,{userID:I,userRole:s,token:k,accessToken:E,keys:g,premiumUser:a})]})]})})}}},function(e){e.O(0,[665,990,42,261,755,978,250,699,971,117,744],function(){return e(e.s=1900)}),_N_E=e.O()}]);
\ No newline at end of file
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,69623))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),n=s(99376),r=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),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,n.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,y]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,k]=(0,a.useState)(null),[N,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),y(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),k(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)(r.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=v,S&&s&&(0,p.m_)(Z,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)(g.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)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},69623:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l$}});var t,a,n=s(57437),r=s(2265),i=s(99376),o=s(27648),d=s(92643),c=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",a),console.log=function(){};let c="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(c=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",c);let m=[{key:"1",label:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{children:["Role: ",s]}),(0,n.jsxs)("p",{children:["ID: ",l]}),(0,n.jsxs)("p",{children:["Premium User: ",String(a)]})]})},{key:"2",label:(0,n.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=c},children:"Logout"})}];return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,n.jsx)("div",{className:"w-full px-4",children:(0,n.jsxs)("div",{className:"flex justify-between items-center h-14",children:[(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)(o.default,{href:"/",className:"flex items-center",children:[(0,n.jsx)("span",{className:"text-xl",children:"\uD83D\uDE85"}),(0,n.jsx)("span",{className:"ml-2 text-base font-medium text-gray-700",children:"LiteLLM"})]})}),(0,n.jsxs)("div",{className:"flex items-center space-x-6",children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-gray-600 hover:text-gray-800",children:"Docs"}),(0,n.jsx)(d.Z,{menu:{items:m},children:(0,n.jsxs)("button",{className:"flex items-center text-sm text-gray-600 hover:text-gray-800",children:["Admin",(0,n.jsx)("svg",{className:"ml-1 w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})})},m=s(19250),u=s(49804),h=s(67101),x=s(20831),p=s(26637),j=s(87452),g=s(88829),f=s(72208),Z=s(84264),y=s(96761),_=s(29233),b=s(41326),v=s(13634),w=s(41021),S=s(51369),k=s(8104),N=s(20577),I=s(56632),C=s(73002);let{Option:A}=b.default,P=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};var E=e=>{let{userID:l,team:s,userRole:t,accessToken:a,data:i,setData:o}=e,[d]=v.Z.useForm(),[c,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(null),[R,D]=(0,r.useState)(null),[M,F]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[z,V]=(0,r.useState)("you"),[B,q]=(0,r.useState)(P(i)),K=()=>{E(!1),d.resetFields()},W=()=>{E(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==a){let e=(await (0,m.So)(a,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,t]);let H=async e=>{try{var s,t,n;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(n=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==n?n:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(w.ZP.info("Making API Call"),E(!0),"service_account"===z){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 u=await (0,m.wX)(a,l,e);console.log("key create Response:",u),o(e=>e?[...e,u]:[u]),T(u.key),D(u.soft_budget),w.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),w.ZP.error("Error creating the key: ".concat(e))}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Key"}),(0,n.jsx)(S.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,n.jsxs)(v.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Owned By",className:"mb-4",children:(0,n.jsxs)(k.ZP.Group,{onChange:e=>V(e.target.value),value:z,children:[(0,n.jsx)(k.ZP,{value:"you",children:"You"}),(0,n.jsx)(k.ZP,{value:"service_account",children:"Service Account"}),"Admin"===t&&(0,n.jsx)(k.ZP,{value:"another_user",children:"Another User"})]})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==z,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===z,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,n.jsx)(p.Z,{placeholder:"User ID",onChange:e=>d.setFieldValue("user_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"you"===z||"another_user"===z?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===z?"key name":"service account ID")}],help:"you"===z?"required":"IDs can include letters, numbers, and hyphens",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",hidden:"another_user"!==z,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,n.jsx)(p.Z,{defaultValue:s?s.team_id:null,onChange:e=>d.setFieldValue("team_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,n.jsx)(A,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,n.jsx)(A,{value:e,children:e},e))]})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.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,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)(v.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,n.jsx)(b.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:B})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),O&&(0,n.jsx)(S.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Save your Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,n.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,n.jsx)(u.Z,{numColSpan:1,children:null!=O?(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:O})}),(0,n.jsx)(_.CopyToClipboard,{text:O,onCopy:()=>{w.ZP.success("API Key copied to clipboard")},children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,n.jsx)(Z.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(7366),T=s(15731),R=s(53410),D=s(23628),M=s(74998),F=s(41649),L=s(12514),U=s(47323),z=s(21626),V=s(97214),B=s(28241),q=s(58834),K=s(69552),W=s(71876),H=s(27281),G=s(57365),J=s(90464);let{Option:Y}=b.default;console.log=function(){};var X=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,data:i,setData:o,teams:d,premiumUser:c}=e,[j,g]=(0,r.useState)(!1),[f,k]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[X,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)([]),ed=new Set,[ec,em]=(0,r.useState)(!1),[eu,eh]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)(null),[ej,eg]=(0,r.useState)(null),[ef]=v.Z.useForm(),[eZ,ey]=(0,r.useState)(null),[e_,eb]=(0,r.useState)(ed),ev=e=>!!e.members_with_roles&&e.members_with_roles.some(e=>"admin"===e.role&&e.user_id===l),ew=r.useMemo(()=>{let e=[];return d&&0!==d.length?(d.forEach(l=>{"default-team"!==l.team_id&&ev(l)?ev(l)&&a&&a.team_id===l.team_id&&(e=[...e,...l.keys||[]]):a&&a.team_id===l.team_id&&i&&(e=[...e,...i.filter(e=>e.team_id===l.team_id)])}),!a&&i&&(e=[...i.filter(e=>!e.team_id||"default-team"===e.team_id),...d.filter(e=>ev(e)).flatMap(e=>e.keys||[])]),Array.from(new Map((e=e.filter(e=>"litellm-dashboard"!==e.team_id)).map(e=>[e.token,e])).values())):i},[i,d,a,l]);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",en),(null==ej?void 0:ej.duration)?ey((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,O.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,O.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,O.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}})(ej.duration)):ey(null),console.log("calculateNewExpiryTime:",eZ)},[en,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),eo(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]);let eS=e=>{er(e),em(!0)},ek=async e=>{if(null==t||null==en)return;let l={...en,metadata:e,key:en.token};try{let e=await (0,m.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===en.token?e:l);o(l)}w.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),w.ZP.error("Failed to update model-specific limits")}em(!1),er(null)};(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),eb(e)}},[d]);let eN=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id);let l=null;if(e.budget_duration)switch(e.budget_duration){case"24h":l="daily";break;case"7d":l="weekly";break;case"30d":l="monthly";break;default:l="None"}er({...e,budget_duration:l}),es(!0)},eI=async e=>{if(null==t)return;let l=e.token;if(e.key=l,e.metadata&&"string"==typeof e.metadata)try{e.metadata=JSON.parse(e.metadata)}catch(l){console.error("Error parsing metadata JSON:",l),w.ZP.error("Invalid metadata JSON for formValue "+e.metadata);return}if(e.budget_duration)switch(e.budget_duration){case"daily":e.budget_duration="24h";break;case"weekly":e.budget_duration="7d";break;case"monthly":e.budget_duration="30d"}console.log("handleEditSubmit:",e);let s=await (0,m.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),w.ZP.success("Key updated successfully"),es(!1),er(null)},eC=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(A(e.token),localStorage.removeItem("userData"+l),k(!0))},eA=async()=>{if(null!=I&&null!=i){try{await (0,m.I1)(t,I);let e=i.filter(e=>e.token!==I);o(e)}catch(e){console.error("Error deleting the key:",e)}k(!1),A(null)}},eP=e=>{er(e),ey(null),ef.setFieldsValue({key_alias:e.key_alias,max_budget:e.max_budget,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,duration:e.duration||""}),eh(!0)},eE=(e,l)=>{eg(s=>({...s,[e]:l}))},eO=async()=>{if(!c){w.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=en)try{let e=await ef.validateFields(),l=await (0,m.s0)(t,en.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==en?void 0:en.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),ef.resetFields(),w.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),w.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,n.jsxs)("div",{children:[(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,n.jsxs)(z.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Key Alias"}),(0,n.jsx)(K.Z,{children:"Secret Key"}),(0,n.jsx)(K.Z,{children:"Created"}),(0,n.jsx)(K.Z,{children:"Expires"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Budget Reset"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"Rate Limits"}),(0,n.jsx)(K.Z,{children:"Rate Limits per model"})]})}),(0,n.jsx)(V.Z,{children:ew&&ew.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(a){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(e_.has(e.team_id),", selectedTeam id: ").concat(a.team_id)),(null!=a.team_id||null===e.team_id||e_.has(e.team_id))&&e.team_id!=a.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,n.jsx)(Z.Z,{children:e.key_alias}):(0,n.jsx)(Z.Z,{children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.key_name})}),(0,n.jsx)(B.Z,{children:null!=e.created_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,n.jsx)(B.Z,{children:null!=e.expires?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,n.jsx)(B.Z,{children:null!=e.max_budget?(0,n.jsx)(Z.Z,{children:e.max_budget}):(0,n.jsx)(Z.Z,{children:"Unlimited"})}),(0,n.jsx)(B.Z,{children:null!=e.budget_reset_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(n.Fragment,{children:a&&a.models&&a.models.length>0?a.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{size:"xs",onClick:()=>eS(e),children:"Edit Limits"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{onClick:()=>{er(e),ea(!0)},icon:T.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:et,onCancel:()=>{ea(!1),er(null)},footer:null,width:800,children:en&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(en.spend).toFixed(4)}catch(e){return en.spend}})()})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.max_budget?(0,n.jsxs)(n.Fragment,{children:[en.max_budget,en.budget_duration&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("br",{}),"Budget will be reset at ",en.budget_reset_at?new Date(en.budget_reset_at).toLocaleString():"Never"]})]}):(0,n.jsx)(n.Fragment,{children:"Unlimited"})})})]},e.name),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.expires?(0,n.jsx)(n.Fragment,{children:new Date(en.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,n.jsx)(n.Fragment,{children:"Never"})})})]},e.name)]}),(0,n.jsxs)(L.Z,{className:"my-4",children:[(0,n.jsx)(y.Z,{children:"Token Name"}),(0,n.jsx)(Z.Z,{className:"my-1",children:en.key_alias?en.key_alias:en.key_name}),(0,n.jsx)(y.Z,{children:"Token ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.token}),(0,n.jsx)(y.Z,{children:"User ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.user_id}),(0,n.jsx)(y.Z,{children:"Metadata"}),(0,n.jsx)(Z.Z,{className:"my-1",children:(0,n.jsxs)("pre",{children:[JSON.stringify(en.metadata)," "]})})]}),(0,n.jsx)(x.Z,{className:"mx-auto flex items-center",onClick:()=>{ea(!1),er(null)},children:"Close"})]})}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>eN(e)}),(0,n.jsx)(U.Z,{onClick:()=>eP(e),icon:D.Z,size:"sm"}),(0,n.jsx)(U.Z,{onClick:()=>eC(e),icon:M.Z,size:"sm"})]})]},e.token)})})]}),f&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:eA,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{k(!1),A(null)},children:"Cancel"})]})]})]})})]}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=v.Z.useForm(),[c,m]=(0,r.useState)(a),[u,h]=(0,r.useState)([]),[x,j]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let f=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,n.jsx)(S.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:o,onFinish:eI,initialValues:f,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(Y,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ei.filter(e=>"all-proxy-models"!==e).map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):c.models.map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):ei.map(e=>(0,n.jsx)(Y,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Current Reset Budget: ".concat(t.budget_duration,", budget will be reset: ").concat(t.budget_reset_at?new Date(t.budget_reset_at).toLocaleString():"Never"),children:(0,n.jsxs)(b.default,{placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"daily",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"weekly",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"monthly",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"token",name:"token",hidden:!0}),(0,n.jsx)(v.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,n.jsx)(H.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,n.jsx)(G.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"TPM Limit (tokens per minute)",name:"tpm_limit",help:"tpm_limit cannot exceed team tpm_limit ".concat((null==c?void 0:c.tpm_limit)!==null&&(null==c?void 0:c.tpm_limit)!==void 0?null==c?void 0:c.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.tpm_limit&&l>c.tpm_limit)throw console.log("keyTeam.tpm_limit: ".concat(c.tpm_limit)),Error("tpm_limit cannot exceed team max tpm_limit: $".concat(c.tpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max rpm_limit: ".concat((null==c?void 0:c.rpm_limit)!==null&&(null==c?void 0:c.rpm_limit)!==void 0?null==c?void 0:c.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.rpm_limit&&l>c.rpm_limit)throw console.log("keyTeam.rpm_limit: ".concat(c.rpm_limit)),Error("rpm_limit cannot exceed team max rpm_limit: $".concat(c.rpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,n.jsx)(J.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:en,onSubmit:eI}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:a,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,u]=(0,r.useState)([]),[h,p]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(t.metadata){let e=t.metadata.model_tpm_limit||{},l=t.metadata.model_rpm_limit||{},s={};Object.keys({...e,...l}).forEach(t=>{s[t]={tpm:e[t]||0,rpm:l[t]||0}}),d(s)}(async()=>{try{let e=await (0,m.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));u(l)}catch(e){console.error("Error fetching model data:",e),w.ZP.error("Failed to fetch available models")}})()},[t,i]);let j=(e,l,s)=>{d(t=>({...t,[e]:{...t[e],[l]:s||0}}))},g=e=>{d(l=>{let{[e]:s,...t}=l;return t})};return(0,n.jsxs)(S.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model"}),(0,n.jsx)(K.Z,{children:"TPM Limit"}),(0,n.jsx)(K.Z,{children:"RPM Limit"}),(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsxs)(V.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:l}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(b.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),p(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,n.jsx)(Y,{value:e,children:e},e))})}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>p(null),children:"Cancel"})})]})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{p("")},disabled:null!==h,children:"Add Limit"})]}),(0,n.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,n.jsx)(x.Z,{onClick:s,children:"Cancel"}),(0,n.jsx)(x.Z,{onClick:()=>{a({...t.metadata,model_tpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.tpm]})),model_rpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.rpm]}))})},children:"Save"})]})]})},{visible:ec,onCancel:()=>em(!1),token:en,onSubmit:ek,accessToken:t}),(0,n.jsx)(S.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),ef.resetFields()},footer:[(0,n.jsx)(x.Z,{onClick:()=>{eh(!1),ef.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,n.jsx)(x.Z,{onClick:eO,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,n.jsxs)(v.Z,{form:ef,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eE("duration",e.duration)},children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{disabled:!0})}),(0,n.jsx)(v.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,n.jsx)(N.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==en?void 0:en.expires)!=null?new Date(en.expires).toLocaleString():"Never"]}),eZ&&(0,n.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eZ]})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,n.jsx)(S.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,n.jsx)(x.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Regenerated Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,n.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,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"Key Alias:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==en?void 0:en.key_alias)||"No alias set"})}),(0,n.jsx)(Z.Z,{className:"mt-3",children:"New API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,n.jsx)(_.CopyToClipboard,{text:ex,onCopy:()=>w.ZP.success("API Key copied to clipboard"),children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,r.useState)(null!==a?a:0),[u,h]=(0,r.useState)(o?o.max_budget:null);(0,r.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)h(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&&(h(s.litellm_budget_table.max_budget),e=!0);e||h(o.max_budget)}}},[o,i]);let[x,p]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",x),j=x):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=x);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,n.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==u?"$".concat(u," limit"):"No limit"})]})]})})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==a){let e=(await (0,m.So)(a,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==t?void 0:t.team_alias}),(null==t?void 0:t.team_id)&&(0,n.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},ee=e=>{let l,{teams:s,setSelectedTeam:t,userRole:a,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let u={models:(null==d?void 0:d.models)||[],team_id:null,team_alias:"Default Team",max_budget:(null==d?void 0:d.max_budget)||null},h=async()=>{null===i&&c&&o(await (0,m.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(u);return console.log("userRole: ".concat(a)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===a?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[u]:s?[...s,u]:[u],(0,n.jsxs)("div",{className:"mt-5 mb-5",children:[(0,n.jsx)(y.Z,{children:"Select Team"}),(0,n.jsx)(Z.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,n.jsxs)(Z.Z,{className:"mt-3 mb-3",children:[(0,n.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,n.jsxs)(Z.Z,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]})},el=s(12011),es=s(14474),et=s(68060);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:x,setKeys:p,premiumUser:j}=e,[g,f]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let y=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),_=Z.get("invitation_id"),[b,v]=(0,r.useState)(null),[w,S]=(0,r.useState)(null),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)(null),A={models:[],team_alias:"Default Team",team_id:null},[P,O]=(0,r.useState)(t?t[0]:A);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,es.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!a&&!g){let e=sessionStorage.getItem("userModels"+l);if(e)N(JSON.parse(e));else{let e=async()=>{let e;e="Admin"!=s&&"Admin Viewer"!=s?await (0,m.It)(b,l):await (0,m.It)(b),console.log("givenTeams: ".concat(e)),x(e)};(async()=>{try{let e=await (0,m.g)(b);C(e);let t=await (0,m.Br)(b,l,s,!1,null,null);console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),f(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys);let a=[...t.teams];a.length>0?(console.log("response['teams']: ".concat(a)),O(a[0])):O(A),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let n=(await (0,m.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),N(n),console.log("userModels:",k),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})(),e()}}},[l,y,b,a,s]),(0,r.useEffect)(()=>{if(null!==a&&null!=P&&null!==P.team_id){let e=0;for(let l of a)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);S(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;S(e)}},[P]),null!=_)return(0,n.jsx)(el.default,{});if(null==l||null==y){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==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Q,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,n.jsx)($,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:w,selectedTeam:P||null}),(0,n.jsx)(X,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:a,setData:p,premiumUser:j,teams:t}),(0,n.jsx)(E,{userID:l,team:P||null,userRole:s,accessToken:b,data:a,setData:p},P?P.team_id:null),(0,n.jsx)(ee,{teams:t,setSelectedTeam:O,userRole:s,proxySettings:I,setProxySettings:C,userInfo:g,accessToken:b})]})})})},en=s(97765),er=s(53003),ei=s(12485),eo=s(18135),ed=s(35242),ec=s(29706),em=s(77991),eu=s(92414),eh=s(46030),ex=s(75105),ep=s(40278),ej=s(75957),eg=s(69410),ef=s(47451),eZ=s(14301),ey=s(2356),e_=e=>{let{modelID:l,accessToken:s}=e,[t,a]=(0,r.useState)(!1),i=async()=>{try{w.ZP.info("Making API Call"),a(!0);let e=await (0,m.Og)(s,l);console.log("model delete Response:",e),w.ZP.success("Model ".concat(l," deleted successfully")),a(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(U.Z,{onClick:()=>a(!0),icon:M.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>a(!1),children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Delete Model"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Model ID: ",(0,n.jsx)("b",{children:l})]})})]})})]})},eb=s(3632),ev=s(18502),ew=s(94789),eS=s(59664),ek=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,n.jsx)(eS.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,n.jsxs)("div",{children:[(0,n.jsx)(ew.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,n.jsx)(x.Z,{variant:"primary",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eN=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,n.jsx)(n.Fragment,{children:l.map(e=>(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,n.jsx)(p.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eI=s(17906);let{Title:eC,Link:eA}=et.default;(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",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.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI";let eP={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"},eE={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eO=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},a={};t.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eP[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=s;else if("custom_model_name"===l)t.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 w.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw w.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 t[l]=s}let r={model_name:n,litellm_params:t,model_info:a},i=await (0,m.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){w.ZP.error("Failed to create model: "+e,10)}};var eT=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:u,premiumUser:j}=e,[g,f]=(0,r.useState)([]),[_]=v.Z.useForm(),[b,k]=(0,r.useState)(null),[I,A]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),O=Object.values(a).filter(e=>isNaN(Number(e))),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[ea,ew]=(0,r.useState)(!1),[eS,eT]=(0,r.useState)(null),[eR,eD]=(0,r.useState)([]),[eM,eF]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[ez,eV]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[eK,eW]=(0,r.useState)([]),[eH,eG]=(0,r.useState)([]),[eJ,eY]=(0,r.useState)([]),[eX,e$]=(0,r.useState)([]),[eQ,e0]=(0,r.useState)([]),[e1,e2]=(0,r.useState)([]),[e4,e5]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e7]=(0,r.useState)(null),[e9,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,la]=(0,r.useState)([]),[ln,lr]=(0,r.useState)(!1),[li,lo]=(0,r.useState)(null),[ld,lc]=(0,r.useState)(null),[lm,lu]=(0,r.useState)([]),lh=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),!s||!o||!i||!l||!t)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),eU(e);let a=null==li?void 0:li.token;void 0===a&&(a=null);let n=ld;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,m.o6)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,m.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,m.N8)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let u=await (0,m.fP)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);if(console.log("slowResponses:",u),e5(u),e){let a=await (0,m.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(a);let n=await (0,m.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{eT(e),es(!0)},lp=e=>{eT(e),ew(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,a]of(e.input_cost_per_million_tokens&&(e.input_cost_per_token=e.input_cost_per_million_tokens/1e6,delete e.input_cost_per_million_tokens),e.output_cost_per_million_tokens&&(e.output_cost_per_token=e.output_cost_per_million_tokens/1e6,delete e.output_cost_per_million_tokens),Object.entries(e)))"model_id"!==s?l[s]=a:t=a;let a={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",a);try{await (0,m.um)(s,a),w.ZP.success("Model updated successfully, restart server to see updates"),es(!1),eT(null)}catch(e){console.log("Error occurred")}},lg=()=>{A(new Date().toLocaleString())},lf=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,m.K_)(s,{router_settings:{model_group_retry_policy:e6}}),w.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),w.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!s||!t||!i||!o)return;let e=async()=>{try{var e,l,t,a,n,r,d,c,h,x,p,j;let g=await (0,m.hy)(s);Y(g);let f=await (0,m.AZ)(s,o,i);console.log("Model data response:",f.data),u(f);let Z=new Set;for(let e=0;e0&&(_=y[y.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",eL);let b=await (0,m.o6)(s,o,i,_,null===(e=e8.from)||void 0===e?void 0:e.toISOString(),null===(l=e8.to)||void 0===l?void 0:l.toISOString(),null==li?void 0:li.token,ld);console.log("Model metrics response:",b),eq(b.data),eW(b.all_api_bases);let v=await (0,m.Rg)(s,_,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(a=e8.to)||void 0===a?void 0:a.toISOString());eG(v.data),eY(v.all_api_bases);let w=await (0,m.N8)(s,o,i,_,null===(n=e8.from)||void 0===n?void 0:n.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",w),e$(w.data),e0(w.exception_types);let S=await (0,m.fP)(s,o,i,_,null===(d=e8.from)||void 0===d?void 0:d.toISOString(),null===(c=e8.to)||void 0===c?void 0:c.toISOString(),null==li?void 0:li.token,ld),k=await (0,m.n$)(s,null===(h=e8.from)||void 0===h?void 0:h.toISOString().split("T")[0],null===(x=e8.to)||void 0===x?void 0:x.toISOString().split("T")[0],_);ls(k);let N=await (0,m.v9)(s,null===(p=e8.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=e8.to)||void 0===j?void 0:j.toISOString().split("T")[0],_);la(N),console.log("dailyExceptions:",k),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",S),e5(S);let I=await (0,m.j2)(s);lu(null==I?void 0:I.end_users);let C=(await (0,m.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,P=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",P),e7(A),le(P)}catch(e){console.error("There was an error fetching the model data",e)}};s&&t&&i&&o&&e();let l=async()=>{let e=await (0,m.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),k(e)};null==b&&l(),lg()},[s,t,i,o,b,I]),!d||!s||!t||!i||!o)return(0,n.jsx)("div",{children:"Loading..."});let lZ=[],ly=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(b)),null!=b&&"object"==typeof b&&e in b)?b[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(n=t)||(n=1===e.length?u(s):l)}else n="-";a&&(r=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,o=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}))),d.data[e].provider=n,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,ly.push(n),d.data[e].input_cost&&(d.data[e].input_cost=(1e6*Number(d.data[e].input_cost)).toFixed(2)),d.data[e].output_cost&&(d.data[e].output_cost=(1e6*Number(d.data[e].output_cost)).toFixed(2)),d.data[e].max_tokens=o,d.data[e].max_input_tokens=c,d.data[e].api_base=null==l?void 0:null===(lv=l.litellm_params)||void 0===lv?void 0:lv.api_base,d.data[e].cleanedLitellmParams=m,lZ.push(l.model_name),console.log(d.data[e])}if(d.data&&d.data.length>0&&d.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),i&&"Admin Viewer"==i){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lw=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(a).find(l=>a[l]===e);if(l){let e=eP[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,a]=l;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===e||a.litellm_provider.includes(e))&&s.push(t)}),"Cohere"==l&&(console.log("adding cohere chat model"),Object.entries(b).forEach(e=>{let[l,t]=e;null!==t&&"object"==typeof t&&"litellm_provider"in t&&"cohere"===t.litellm_provider&&s.push(l)}))),E(s),console.log("providerModels: ".concat(P))}},lS=async()=>{try{w.ZP.info("Running health check..."),ee("");let e=await (0,m.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lk=(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Select API Key Name"}),j?(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsxs)(G.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsxs)(G.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let r=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,n.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[r&&(0,n.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,n.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,n.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})},lI=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";console.log("selectedProvider: ".concat(X)),console.log("providerModels.length: ".concat(P.length));let lC=Object.keys(a).find(e=>a[e]===X);return lC&&(l=M.find(e=>e.name===eP[lC])),(0,n.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(ei.Z,{children:"All Models"}),(0,n.jsx)(ei.Z,{children:"Add Model"}),(0,n.jsx)(ei.Z,{children:(0,n.jsx)("pre",{children:"/health Models"})}),(0,n.jsx)(ei.Z,{children:"Model Analytics"}),(0,n.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[I&&(0,n.jsxs)(Z.Z,{children:["Last Refreshed: ",I]}),(0,n.jsx)(U.Z,{icon:D.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsxs)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||void 0,onValueChange:e=>eU("all"===e?"all":e),value:eL||void 0,children:[(0,n.jsx)(G.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created At":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created By":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,n.jsxs)(W.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.litellm_model_name,children:(0,n.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"===i&&(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.api_base,children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&e.model_info.created_by||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,n.jsx)(F.Z,{size:"xs",className:"text-white",children:(0,n.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,n.jsx)(F.Z,{size:"xs",className:"text-black",children:(0,n.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsxs)(h.Z,{numItems:3,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>lx(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(e_,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,n.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[r]=v.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,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,n.jsx)(S.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"max_retries",name:"max_retries",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"Input Cost per 1M Tokens",name:"input_cost_per_million_tokens",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"Output Cost per 1M Tokens",name:"output_cost_per_million_tokens",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),eT(null)},model:eS,onSubmit:lj}),(0,n.jsxs)(S.Z,{title:eS&&eS.model_name,visible:ea,width:800,footer:null,onCancel:()=>{ew(!1),eT(null)},children:[(0,n.jsx)(y.Z,{children:"Model Info"}),(0,n.jsx)(eI.Z,{language:"json",children:eS&&JSON.stringify(eS,null,2)})]})]}),(0,n.jsxs)(ec.Z,{className:"h-full",children:[(0,n.jsx)(eC,{level:2,children:"Add new model"}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(v.Z,{form:_,onFinish:()=>{_.validateFields().then(e=>{eO(e,s,_)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(H.Z,{value:X.toString(),children:O.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lw(e),$(e)},children:e},l))})}),(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],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.",className:"mb-0",children:(0,n.jsx)(p.Z,{})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,n.jsxs)(v.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,n.jsx)(v.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,n.jsx)(p.Z,{placeholder:lI(X.toString())}):P.length>0?(0,n.jsxs)(eu.Z,{children:[(0,n.jsx)(eh.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,n.jsx)(eh.Z,{value:e,children:e},l))]}):(0,n.jsx)(p.Z,{placeholder:lI(X.toString())})}),(0,n.jsx)(v.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,n.jsx)(v.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,n.jsx)(p.Z,{placeholder:"Enter custom model name"})})}})]}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==l&&l.fields.length>0&&(0,n.jsx)(eN,{fields:l.fields,selectedProvider:l.name}),"Amazon Bedrock"!=X&&"Vertex AI (Anthropic, Gemini, etc.)"!=X&&"Ollama"!=X&&(void 0===l||0==l.fields.length)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,n.jsx)(p.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization",children:(0,n.jsx)(p.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,n.jsx)(p.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,n.jsx)(p.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,n.jsx)(ev.Z,{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;_.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?w.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&w.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,n.jsx)(C.ZP,{icon:(0,n.jsx)(eb.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==X||"OpenAI-Compatible Endpoints (Together AI, etc.)"==X)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,n.jsx)(p.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,n.jsxs)("div",{children:[(0,n.jsx)(v.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,n.jsx)(p.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,n.jsx)(eA,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"us-east-1"})}),(0,n.jsx)(v.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,n.jsx)(v.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]}),(0,n.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,n.jsx)(ej.Z,{title:"Get help on our github",children:(0,n.jsx)(et.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,n.jsx)(x.Z,{onClick:lS,children:"Run `/health`"}),Q&&(0,n.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,n.jsxs)(eg.Z,{className:"ml-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model Group"}),(0,n.jsx)(H.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(eZ.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,n.jsx)(x.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,n.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,n.jsx)(Z.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eK&&(0,n.jsx)(ex.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(ek,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:j})})]})]})})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Deployment"}),(0,n.jsx)(K.Z,{children:"Success Responses"}),(0,n.jsxs)(K.Z,{children:["Slow Responses ",(0,n.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,n.jsx)(V.Z,{children:e4.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.api_base}),(0,n.jsx)(B.Z,{children:e.total_count}),(0,n.jsx)(B.Z,{children:e.slow_count})]},l))})]})})})]}),(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,n.jsx)(ep.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,n.jsxs)(h.Z,{numItems:1,children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,n.jsx)(eg.Z,{})]})]}),j?(0,n.jsx)(n.Fragment,{children:lt.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,n.jsx)(n.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsx)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||eR[0],value:eL||eR[0],onValueChange:e=>eU(e),children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,n.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,n.jsx)(Z.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eE&&(0,n.jsx)("table",{children:(0,n.jsx)("tbody",{children:Object.entries(eE).map((e,l)=>{var s;let[t,a]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[a];return null==r&&(r=e9),(0,n.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,n.jsx)("td",{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)("td",{children:(0,n.jsx)(N.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(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,n.jsx)(x.Z,{className:"mt-6 mr-8",onClick:lf,children:"Save"})]})]})]})})};function eR(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:r,Paragraph:i}=et.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,n.jsxs)(S.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,n.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"User ID"}),(0,n.jsx)(Z.Z,{children:null==a?void 0:a.user_id})]}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{children:"Invitation Link"}),(0,n.jsx)(Z.Z,{children:(0,n.jsx)(Z.Z,{children:o()})})]}),(0,n.jsx)("div",{className:"flex justify-end mt-5",children:(0,n.jsx)(_.CopyToClipboard,{text:o(),onCopy:()=>w.ZP.success("Copied!"),children:(0,n.jsx)(x.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:eD}=b.default;var eM=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,r.useState)(null),[c]=v.Z.useForm(),[u,h]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]),[_,k]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)(),[E,O]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,m.So)(s,l,"any"),t=[];for(let l=0;l{P&&O(new URL("/",window.location.href).toString())},[P]);let T=async e=>{try{var t;w.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let a=await (0,m.Ov)(s,null,e);console.log("user create Response:",a),g(a.key);let n=(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:n,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};A(e),k(!0)}else(0,m.XO)(s,n).then(e=>{e.has_user_setup_sso=!1,A(e),k(!0)});w.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,n.jsxs)(S.Z,{title:"Invite User",visible:u,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,n.jsxs)(v.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(v.Z.Item,{label:"User Email",name:"user_email",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",children:(0,n.jsx)(b.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,n.jsx)(eD,{value:e.team_id,children:e.team_alias},e.team_id)):(0,n.jsx)(eD,{value:null,children:"Default Team"},"default")})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),j&&(0,n.jsx)(eR,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:k,baseUrl:E,invitationLinkData:N})]})},eF=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,r.useState)(a),[c]=v.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,n.jsx)(S.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,n.jsx)(v.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eL=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,u]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)(1),[_,b]=r.useState(null),[v,S]=(0,r.useState)(null),[k,N]=(0,r.useState)(!1),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(!1),[E,O]=(0,r.useState)(null),[T,D]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let H=e=>{O(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,m.Eb)(l,[E]),w.ZP.success("User deleted successfully"),p){let e=p.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),w.ZP.error("Failed to delete user")}P(!1),O(null)},J=async()=>{C(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,m.pf)(l,e,null),w.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}p&&j(p.map(l=>l.user_id===e.user_id?e:l)),C(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);u(l),j(l.users||[])}else{let e=await (0,m.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),u(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,m.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,Z]),p&&l&&s&&a&&i)?(0,n.jsx)("div",{style:{width:"100%"},children:(0,n.jsxs)(h.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,n.jsx)(eM,{userID:i,accessToken:l,teams:o,possibleUIRoles:T}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,n.jsx)("div",{className:"mb-4 mt-1"}),(0,n.jsx)(eo.Z,{children:(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(z.Z,{className:"mt-5",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"User ID"}),(0,n.jsx)(K.Z,{children:"User Email"}),(0,n.jsx)(K.Z,{children:"Role"}),(0,n.jsx)(K.Z,{children:"User Spend ($ USD)"}),(0,n.jsx)(K.Z,{children:"User Max Budget ($ USD)"}),(0,n.jsx)(K.Z,{children:"API Keys"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:p.map(e=>{var l,s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id||"-"}),(0,n.jsx)(B.Z,{children:e.user_email||"-"}),(0,n.jsx)(B.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,n.jsx)(B.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,n.jsx)(B.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(h.Z,{numItems:2,children:e.key_count>0?(0,n.jsxs)(F.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,n.jsx)(F.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,onClick:()=>{C(e),N(!0)},children:"View Keys"}),(0,n.jsx)(U.Z,{icon:M.Z,onClick:()=>H(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,n.jsx)(eF,{visible:k,possibleUIRoles:T,onCancel:J,user:I,onSubmit:Y}),A&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,n.jsxs)("div",{className:"mt-2",children:[(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,n.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!p)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),y(e)};return(0,n.jsxs)("div",{className:"flex justify-between items-center",children:[(0,n.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,n.jsx)("div",{children:"Loading..."})},eU=e=>{var l,s;let{visible:t,onCancel:a,onSubmit:r,initialData:i,mode:o}=e,[d]=v.Z.useForm(),c=async e=>{try{let l={email:e.user_email,id:e.user_id,role:e.role};r(l),d.resetFields(),w.ZP.success("Successfully ".concat("add"===o?"added":"updated"," team member"))}catch(e){w.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}};return(0,n.jsx)(S.Z,{title:"add"===o?"Add Team Member":"Edit Team Member",visible:t,width:800,footer:null,onCancel:a,children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{user_email:(null==i?void 0:null===(l=i.email)||void 0===l?void 0:l.trim())||"",user_id:(null==i?void 0:null===(s=i.id)||void 0===s?void 0:s.trim())||"",role:(null==i?void 0:i.role)||"user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)("div",{className:"text-center mb-4",children:(0,n.jsx)(Z.Z,{children:"OR"})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})}),(0,n.jsxs)("div",{style:{textAlign:"right",marginTop:"20px"},children:[(0,n.jsx)(C.ZP,{onClick:a,style:{marginRight:8},children:"Cancel"}),(0,n.jsx)(C.ZP,{type:"primary",htmlType:"submit",children:"add"===o?"Add Member":"Save Changes"})]})]})})};console.log=function(){};var ez=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o}=e;(0,r.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&(async()=>{let e;e="Admin"!=o&&"Admin Viewer"!=o?await (0,m.It)(t,i):await (0,m.It)(t),console.log("givenTeams: ".concat(e)),a(e)})()},[l]);let[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:y,Paragraph:_}=et.default,[k,A]=(0,r.useState)(""),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(l?l[0]:null),[D,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)([]),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(null),[ed,ec]=(0,r.useState)({}),em=e=>{T(e),E(!0)},eu=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let n=await (0,m.Gh)(t,e);l&&a(l.map(e=>e.team_id===s?n.data:e)),w.ZP.success("Team updated successfully"),E(!1),T(null)},eh=()=>{X(!1),Q(!1),c.resetFields()},ex=async e=>{er(e),ea(!0)},ep=async()=>{if(null!=en&&null!=l&&null!=t){try{await (0,m.rs)(t,en);let e=l.filter(e=>e.team_id!==en);a(e)}catch(e){console.error("Error deleting the team:",e)}ea(!1),er(null)}};(0,r.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,m.It)(t,i):await (0,m.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,m.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eg=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let n=null==e?void 0:e.team_alias,r=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=null==e?void 0:e.organization_id;if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),r.includes(n))throw Error("Team alias ".concat(n," already exists, please pick another alias"));w.ZP.info("Creating Team");let o=await (0,m.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),w.ZP.success("Team created"),J(!1)}}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the team: "+e,20)}},ef=async(e,s)=>{try{if(null!=t&&null!=l){let n;w.ZP.info("Adding Member");let r={role:e.role,user_email:e.user_email,user_id:e.user_id};"add"==s?(n=await (0,m.cu)(t,O.team_id,r),w.ZP.success("Member added")):(n=await (0,m.sN)(t,O.team_id,{role:e.role,user_id:e.id,user_email:e.email}),w.ZP.success("Member updated"));let i=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(n.data.team_id)),e.team_id===n.data.team_id));if(console.log("foundIndex: ".concat(i)),-1!==i){let e=[...l];e[i]=n.data,a(e),T(n.data)}X(!1)}}catch(e){console.error("Error creating the team:",e)}},eZ=async e=>{ef(e,"add")},ey=async e=>{ef(e,"edit")};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"All Teams"}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Team Name"}),(0,n.jsx)(K.Z,{children:"Team ID"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"TPM / RPM Limits"}),(0,n.jsx)(K.Z,{children:"Info"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,n.jsx)(ej.Z,{title:e.team_id,children:e.team_id})}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,n.jsx)(B.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,n.jsx)(B.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].keys&&ed[e.team_id].keys.length," ","Keys"]}),(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].members_with_roles&&ed[e.team_id].members_with_roles.length," ","Members"]})]}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>em(e)}),(0,n.jsx)(U.Z,{onClick:()=>ex(e.team_id),icon:M.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),es&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:ep,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{ea(!1),er(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>J(!0),children:"+ Create New Team"}),(0,n.jsx)(S.Z,{title:"Create Team",visible:D,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:eg,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Additional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,n.jsx)(p.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"Team Members"}),(0,n.jsx)(_,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{T(e)},children:e.team_alias},l))}):(0,n.jsxs)(_,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:O?O.members_with_roles.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsx)(B.Z,{children:e.role}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{Q(!0),eo({id:e.user_id,email:e.user_email,role:e.role})}}),(0,n.jsx)(U.Z,{onClick:()=>{},icon:M.Z,size:"sm"})]}):null})]},l)):null})]})}),(0,n.jsx)(eU,{visible:$,onCancel:eh,onSubmit:ey,initialData:ei,mode:"edit"}),O&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:a}=e,[r]=v.Z.useForm();return(0,n.jsx)(S.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:eu,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee&&ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:P,onCancel:()=>{E(!1),T(null)},team:O,onSubmit:eu})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"==o||O&&(e=>{for(let l=0;lX(!0),children:"+ Add member"}):null,(0,n.jsx)(S.Z,{title:"Add member",visible:Y,width:800,footer:null,onOk:()=>{X(!1),Q(!1),c.resetFields()},onCancel:eh,children:(0,n.jsxs)(v.Z,{form:d,onFinish:eZ,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})};let eV=async(e,l,s)=>{if(null!=l)try{w.ZP.info("Creating Organization"),console.log("formValues: "+JSON.stringify(e));let t=await (0,m.H1)(l,e);console.log("response for organization create call: ".concat(t)),w.ZP.success("Organization created"),sessionStorage.removeItem("organizations"),s(!1)}catch(e){console.error("Error creating the organization:",e),w.ZP.error("Error creating the organization: "+e,20)}};var eB=e=>{let{title:l="Create Organization",onCancel:s,accessToken:t,availableModels:a=[],initialValues:i={},submitButtonText:o="Create",modelSelectionType:d="multiple"}=e,[c]=v.Z.useForm(),[m,u]=(0,r.useState)(!1),[h,j]=(0,r.useState)({name:i.name||"",models:i.models||[],maxBudget:i.maxBudget||null,budgetDuration:i.budgetDuration||null,tpmLimit:i.tpmLimit||null,rpmLimit:i.rpmLimit||null});console.log("availableModels: ".concat(a));let g=async e=>{null!=t&&(await eV(e,t,u),u(!1))};return(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)(x.Z,{onClick:()=>u(!0),className:"mx-auto",type:"button",children:["+ Create New ",l]}),(0,n.jsx)(S.Z,{title:"Create ".concat(l),visible:m,width:800,footer:null,onCancel:()=>{u(!1),s&&s()},children:(0,n.jsxs)(v.Z,{form:c,onFinish:g,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"".concat(l," Name"),name:"organization_alias",rules:[{required:!0,message:"Please input a ".concat(l," name")}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),a.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:o})})]})})]})};let eq=(e,l)=>{for(let s=0;s{let{userRole:l,userID:s,selectedOrganization:t,onMemberAdd:a}=e,[i,o]=r.useState(!1),[d]=v.Z.useForm();return(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"===l||t&&eq(t,s)?(0,n.jsx)(x.Z,{className:"mx-auto mb-5",onClick:()=>o(!0),children:"+ Add member"}):null,(0,n.jsxs)(S.Z,{title:"Add member",visible:i,width:800,footer:null,onOk:()=>{d.submit()},onCancel:()=>{d.resetFields(),o(!1)},children:[(0,n.jsx)(Z.Z,{className:"mb-2",children:"User must exist in proxy. Get User ID from 'Users' tab."}),(0,n.jsxs)(v.Z,{form:d,onFinish:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"internal_user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"org_admin",children:(0,n.jsxs)("div",{className:"flex",children:["Org Admin"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can add and remove members, and change their roles."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can view/create keys for themselves within organization."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user_viewer",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User Viewer"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can only view their keys within organization."})]})})]})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})]})]})},eW=e=>{var l;let{selectedEntity:s,onEditSubmit:t,editModalComponent:a,entityType:i}=e,[o,d]=r.useState(!1);return(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"team"===i?"Team Member":"Organization Member"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:(null!==(l=null==s?void 0:s.members)&&void 0!==l?l:[]).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id}),(0,n.jsx)(B.Z,{children:e.user_role})]},"".concat(e.user_id,"-").concat(l)))})]})}),s&&(0,n.jsx)(a,{visible:o,onCancel:()=>{d(!1)},entity:s,onSubmit:e=>{t(e),d(!1)}})]})},eH=e=>{let{data:l,columns:s,actions:t,emptyMessage:a="No data available",deleteModal:r}=e,i=(e,l)=>{let s=l[e.accessor];return e.cellRenderer?e.cellRenderer(s,l):Array.isArray(s)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===s.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"None"})}):s.map((e,l)=>(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:String(e).length>30?"".concat(String(e).slice(0,30),"..."):e})},l))}):(null==s?void 0:s.toString())||""};return(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[40vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[s.map((e,l)=>(0,n.jsx)(K.Z,{children:e.header},l)),t&&t.length>0&&(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map((e,l)=>(0,n.jsxs)(W.Z,{children:[s.map((l,s)=>(0,n.jsx)(B.Z,{style:{maxWidth:l.width||"4px",whiteSpace:"pre-wrap",overflow:"hidden",...l.style},children:"id"===l.accessor?(0,n.jsx)(ej.Z,{title:e[l.accessor],children:i(l,e)}):i(l,e)},s)),t&&t.length>0&&(0,n.jsx)(B.Z,{children:t.map((l,s)=>{var t;return(null===(t=l.condition)||void 0===t?void 0:t.call(l,e))!==!1&&(0,n.jsx)(ej.Z,{title:l.tooltip,children:(0,n.jsx)(U.Z,{icon:l.icon,size:"sm",onClick:()=>l.onClick(e),className:"cursor-pointer mx-1"})},s)})})]},l)):(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:s.length+(t?1:0),children:(0,n.jsx)(Z.Z,{className:"text-center",children:a})})})})]})})};console.log=function(){};let eG=e=>{let{visible:l,onCancel:s,entity:t,onSubmit:a}=e;return(0,n.jsx)("div",{})},eJ=e=>{let{organizations:l,userRole:s,onEdit:t,onDelete:a,isDeleteModalOpen:r,setIsDeleteModalOpen:i,selectedOrganization:o,setSelectedOrganization:d}=e,c=[...t&&"Admin"===s?[{icon:void 0,onClick:e=>t(e),condition:()=>"Admin"===s,tooltip:"Edit organization"}]:[],...a&&"Admin"===s?[{icon:void 0,onClick:e=>a(e),condition:()=>"Admin"===s,tooltip:"Delete organization"}]:[]];return(0,n.jsx)(eH,{data:l,columns:[{header:"Organization Name",accessor:"organization_alias",width:"4px",style:{whiteSpace:"pre-wrap",overflow:"hidden"}},{header:"Organization ID",accessor:"organization_id",width:"4px",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"}},{header:"Spend (USD)",accessor:"spend"},{header:"Budget (USD)",accessor:"max_budget",cellRenderer:e=>null!=e?e:"No limit"},{header:"Models",accessor:"models"},{header:"TPM / RPM Limits",accessor:"limits",cellRenderer:(e,l)=>(0,n.jsxs)("div",{className:"text-sm",children:[(0,n.jsxs)("span",{children:["TPM: ",l.tpm_limit?l.tpm_limit:"Unlimited"]}),(0,n.jsx)("br",{}),(0,n.jsxs)("span",{children:["RPM: ",l.rpm_limit?l.rpm_limit:"Unlimited"]})]})},{header:"Info",accessor:"info",cellRenderer:(e,l)=>{var s;return(0,n.jsx)("div",{className:"space-y-1",children:(0,n.jsxs)("div",{className:"text-sm",children:[(null===(s=l.members)||void 0===s?void 0:s.length)||0," Members"]})})}}],actions:c,emptyMessage:"No organizations available",deleteModal:{isOpen:r,onConfirm:()=>{o&&a&&a(o),i(!1),d(null)},onCancel:()=>{i(!1),d(null)},title:"Delete Organization",message:"Are you sure you want to delete this organization?"}})};var eY=e=>{let{accessToken:l,userID:s,userRole:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),{Title:d,Paragraph:c}=et.default,[x,p]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!l||!s||!t)return;let e=async()=>{try{let e=(await (0,m.So)(l,s,t)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}catch(e){console.error("Error fetching user models:",e)}},n=async()=>{let e;e=await (0,m.r6)(l),console.log("givenOrganizations: ".concat(e)),o(e),sessionStorage.setItem("organizations",JSON.stringify(e))};a&&(e(),n())},[l]);let _=async e=>{if(j&&l)try{let s={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,m.vh)(l,j.organization_id,s),w.ZP.success("Member added")}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the organization: "+e)}};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"✨ All Organizations"}),(0,n.jsxs)(Z.Z,{className:"mb-2",children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,n.jsx)("a",{href:"https://www.litellm.ai/#trial",className:"text-blue-600 hover:text-blue-800 underline",target:"_blank",rel:"noopener noreferrer",children:"here"})]}),t?eJ({organizations:i,userRole:t,isDeleteModalOpen:x,setIsDeleteModalOpen:p,selectedOrganization:j,setSelectedOrganization:g}):null]}),"Admin"==t&&l&&a?(0,n.jsx)(eB,{title:"Organization",accessToken:l,availableModels:f,submitButtonText:"Create Organization"}):null,a?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"Organization Members"}),(0,n.jsx)(c,{children:"If you belong to multiple organizations, this setting controls which organizations' members you see."}),i&&i.length>0?(0,n.jsx)(H.Z,{children:i.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{g(e)},children:e.organization_alias},l))}):(0,n.jsxs)(c,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eK,{userRole:t,userID:s,selectedOrganization:j,onMemberAdd:_}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eW,{selectedEntity:j,onEditSubmit:()=>{},editModalComponent:eG,entityType:"organization"}):null]})})},eX=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:a,premiumUser:o}=e,[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:p,Paragraph:j}=et.default,[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)(null),[b,k]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(!1),[D,M]=(0,r.useState)(!1),[F,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)([]),[ei,eo]=(0,r.useState)(null),ed=(0,i.useRouter)(),[ec,em]=(0,r.useState)(null);console.log=function(){};let[eu,eh]=(0,r.useState)(""),ex="All IP Addresses Allowed";try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let ep=async()=>{try{if(!0!==o){w.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,m.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),w.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,m.eH)(t,e.ip);let l=await (0,m.PT)(t);er(l),w.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),w.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),ea(!0)},ef=async()=>{if(ei&&t)try{await (0,m.$I)(t,ei);let e=await (0,m.PT)(t);er(e.length>0?e:[ex]),w.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),w.ZP.error("Failed to delete IP address ".concat(e))}finally{ea(!1),eo(null)}},eZ=()=>{X(!1)},ey=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(ed){let{protocol:e,host:l}=window.location;eh("".concat(e,"//").concat(l))}},[ed]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,m.Xd)(t,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let s=l.users;console.log("proxy viewers response: ".concat(s)),s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(s));let a=(await (0,m.Xd)(t,"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)),_(e),em(await (0,m.lg)(t))}})()},[t]);let e_=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,n.jsx)(H.Z,{value:l,children:ey.map((e,l)=>(0,n.jsx)(G.Z,{value:e,children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,n.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ek=async e=>{try{if(null!=t&&null!=y){w.ZP.info("Making API Call");let l=await (0,m.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),y.push(l),_(y)),w.ZP.success("Refresh tab to see updated user role"),M(!1)}}catch(e){console.error("Error creating the key:",e)}},eN=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call");let s=await (0,m.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)});let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,m.pf)(t,e,"proxy_admin"),a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)}),console.log("response for team create call: ".concat(s));let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),T(!1)}}catch(e){console.error("Error creating the key:",e)}},eC=async e=>{if(null==t)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,m.K_)(t,l)};return console.log("admins: ".concat(null==y?void 0:y.length)),(0,n.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,n.jsx)(p,{level:4,children:"Admin Access "}),(0,n.jsxs)(j,{children:[a&&(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:y?y.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsxs)(B.Z,{children:[" ",(null==ec?void 0:null===(s=ec[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>M(!0)}),(0,n.jsx)(S.Z,{title:"Update role",visible:D,width:800,footer:null,onOk:e_,onCancel:eb,children:eS(ek,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("div",{className:"flex justify-start",children:[(0,n.jsx)(x.Z,{className:"mr-4 mb-5",onClick:()=>T(!0),children:"+ Add admin"}),(0,n.jsx)(S.Z,{title:"Add admin",visible:O,width:800,footer:null,onOk:()=>{T(!1),c.resetFields(),d.resetFields()},onCancel:()=>{T(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,n.jsx)(eR,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,n.jsx)(x.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,n.jsx)(S.Z,{title:"Add viewer",visible:P,width:800,footer:null,onOk:()=>{E(!1),c.resetFields(),d.resetFields()},onCancel:()=>{E(!1),c.resetFields(),d.resetFields()},children:ev(eN)})]})})]}),(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(p,{level:4,children:" ✨ Security Settings"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:()=>!0===o?J(!0):w.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,n.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,n.jsx)(S.Z,{title:"Add SSO",visible:F,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:e=>{eI(e),eC(e),J(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,n.jsx)(I.Z.Password,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,n.jsx)(I.Z.Password,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,n.jsxs)(S.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:eZ,onCancel:()=>{X(!1)},children:[(0,n.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{onClick:eZ,children:"Done"})})]}),(0,n.jsx)(S.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,n.jsx)(x.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"IP Address"}),(0,n.jsx)(K.Z,{className:"text-right",children:"Action"})]})}),(0,n.jsx)(V.Z,{children:en.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e}),(0,n.jsx)(B.Z,{className:"text-right",children:e!==ex&&(0,n.jsx)(x.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,n.jsx)(S.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,n.jsxs)(v.Z,{onFinish:ej,children:[(0,n.jsx)(v.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,n.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,n.jsx)(v.Z.Item,{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,n.jsx)(S.Z,{title:"Confirm Delete",visible:es,onCancel:()=>ea(!1),onOk:ef,footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>ef(),children:"Yes"},"delete"),(0,n.jsx)(x.Z,{onClick:()=>ea(!1),children:"Close"},"close")],children:(0,n.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,n.jsxs)(ew.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,n.jsxs)("a",{href:l,target:"_blank",children:[(0,n.jsx)("b",{children:l})," "]})]})]})]})},e$=s(92858),eQ=s(44643),e0=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:r}=e,[i]=v.Z.useForm();return(0,n.jsxs)(v.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{align:"center",children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,n.jsx)(v.Z.Item,{name:e.field_name,children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,n.jsx)(v.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,n.jsx)("div",{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},e1=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,m.RQ)(l).then(e=>{a(e)})},[l]),(0,n.jsx)(e0,{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:n,...r}=a;console.log("slack_alerting: ".concat(n,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,m.jA)(l,"alerting_args",r),"boolean"==typeof n&&(!0==n?(0,m.jA)(l,"alerting",["slack"]):(0,m.jA)(l,"alerting",[])),w.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},e2=s(86582);let{Title:e4,Paragraph:e5}=et.default;console.log=function(){};var e8=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[u,j]=(0,r.useState)(!1),[g]=v.Z.useForm(),[f,y]=(0,r.useState)(null),[_,k]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,O]=(0,r.useState)([]),[T,D]=(0,r.useState)(!1),[M,F]=(0,r.useState)([]),[H,J]=(0,r.useState)(null),[Y,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),es=e=>{E.includes(e)?O(E.filter(l=>l!==e)):O([...E,e])},et={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,r.useEffect)(()=>{l&&s&&t&&(0,m.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),F(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),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ea=e=>E&&E.includes(e),en=()=>{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,m.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Email settings updated successfully")},er=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,m.K_)(l,{environment_variables:s}),w.ZP.success("Callback added successfully"),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eu=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,m.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),w.ZP.success("Callback ".concat(s," added successfully")),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),y(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",Y)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,n.jsxs)("div",{className:"w-full mx-4",children:[(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,n.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,n.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,n.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Active Logging Callbacks"}),(0,n.jsx)(h.Z,{numItems:2,children:(0,n.jsx)(L.Z,{className:"max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(K.Z,{children:"Callback Name"})})}),(0,n.jsx)(V.Z,{children:i.map((e,s)=>(0,n.jsxs)(W.Z,{className:"flex justify-between",children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.name})}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"flex justify-between",children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(Z.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,n.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{children:"Slack Webhook URL"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:"region_outage_alerts"==s?a?(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)}):(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,n.jsx)(x.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let n=(null==a?void 0:a.value)||"";console.log("newWebhookValue",n),e[s]=n}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,m.K_)(l,s)}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(e1,{accessToken:l,premiumUser:a})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Email Settings"}),(0,n.jsxs)(Z.Z,{children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,n.jsx)("br",{})]}),(0,n.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,n.jsx)(B.Z,{children:(0,n.jsx)("ul",{children:(0,n.jsx)(h.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,n.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,n.jsxs)("div",{children:[(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,n.jsxs)(Z.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-2",children:l}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,n.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,n.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,n.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,n.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,n.jsx)(x.Z,{className:"mt-2",onClick:()=>en(),children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,n.jsxs)(S.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>D(!1),footer:null,children:[(0,n.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,n.jsx)(v.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e2.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,n.jsx)(b.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,n.jsx)(G.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,n.jsx)(e2.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,n.jsx)(p.Z,{type:"password"})},e)),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,n.jsx)(S.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,n.jsxs)(v.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,n.jsx)(e2.Z,{label:l,name:l,children:(0,n.jsx)(p.Z,{type:"password",defaultValue:s})},l)})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:e3}=b.default;var e6=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=v.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,n.jsx)(S.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,n.jsxs)(v.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:n}=e,r=[...t.fallbacks||[],{[l]:n}],o={...t,fallbacks:r};console.log(o);try{(0,m.K_)(s,{router_settings:o}),a(o)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,n.jsx)(H.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>u(e),children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsx)(eu.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},e7=s(33619);async function e9(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new e7.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});w.ZP.success((0,n.jsxs)("span",{children:["Test model=",(0,n.jsx)("strong",{children:e}),", received model=",(0,n.jsx)("strong",{children:l.model}),". See"," ",(0,n.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let le={ttl:3600,lowest_latency_buffer:0},ll=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,n.jsx)(g.Z,{children:"latency-based-routing"==l?(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,n.jsx)(Z.Z,{children:"No specific settings"})})]})};var ls=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)(!1),[b]=v.Z.useForm(),[S,k]=(0,r.useState)(null),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,m.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,m.YU)(l).then(e=>{g(e)}))},[l,s,t]);let O=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,m.K_)(l,{router_settings:i}),o({...i}),C(i.routing_strategy),w.ZP.success("Router settings updated successfully")}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}}},T=(e,l)=>{g(j.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=j[s].field_value;if(null!=t&&void 0!=t)try{(0,m.jA)(l,e,t);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,m.ao)(l,e);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},J=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,I];if("routing_strategy_args"==l&&"latency-based-routing"==I){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,m.K_)(l,{router_settings:s})}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully")};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,n.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,n.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,n.jsx)(y.Z,{children:"Router Settings"}),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,n.jsx)(B.Z,{children:"routing_strategy"==l?(0,n.jsxs)(H.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:C,children:[(0,n.jsx)(G.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,n.jsx)(G.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,n.jsx)(G.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,n.jsx)(ll,{selectedStrategy:I,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:le,paramExplanation:E})]}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>J(i),children:"Save Changes"})})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model Name"}),(0,n.jsx)(K.Z,{children:"Fallbacks"})]})}),(0,n.jsx)(V.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:t}),(0,n.jsx)(B.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>e9(t,l),children:"Test Fallback"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,n.jsx)(e6,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"}),(0,n.jsx)(K.Z,{children:"Status"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:j.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,n.jsx)(B.Z,{children:"Integer"==e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(x.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lt=s(93142),la=s(45246),ln=s(96473),lr=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,r.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,n)=>{let r=[...t];r[e]=[l,n],a(r),null==s||s(Object.fromEntries(r))};return(0,n.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(lt.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,n.jsx)(p.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,n.jsx)(p.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,n.jsx)(la.Z,{onClick:()=>i(l)})]},l)}),(0,n.jsx)(C.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,n.jsx)(ln.Z,{}),children:"Add Header"})]})};let{Option:li}=b.default;var lo=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=v.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,n.jsx)(S.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,n.jsxs)(v.Z,{form:a,onFinish:e=>{console.log(e);let n=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,m.Vt)(l,e),s(n)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(lr,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},ld=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,m.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,m.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),w.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Path"}),(0,n.jsx)(K.Z,{children:"Target"}),(0,n.jsx)(K.Z,{children:"Headers"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:i.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.path})}),(0,n.jsx)(B.Z,{children:e.target}),(0,n.jsx)(B.Z,{children:JSON.stringify(e.headers)}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,n.jsx)(lo,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lc=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[r]=v.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call");let l=await (0,m.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),w.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,n.jsxs)(v.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lm=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=v.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call"),t(!0);let l=await (0,m.qI)(s,e);a(e=>e?[...e,l]:[l]),w.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},lu=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[a,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,u]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,m.O3)(l).then(e=>{u(e)})},[l]);let h=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),i(!0))},p=async(e,s)=>{if(null==l)return;w.ZP.info("Request made"),await (0,m.NV)(l,e);let t=[...c];t.splice(s,1),u(t),w.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,m.O3)(l).then(e=>{u(e)})};return(0,n.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,n.jsx)(x.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,n.jsx)(lc,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:u}),o&&(0,n.jsx)(lm,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:u,existingBudget:o,handleUpdateCall:j}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"Create a budget to assign to customers."}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Budget ID"}),(0,n.jsx)(K.Z,{children:"Max Budget"}),(0,n.jsx)(K.Z,{children:"TPM"}),(0,n.jsx)(K.Z,{children:"RPM"})]})}),(0,n.jsx)(V.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.budget_id}),(0,n.jsx)(B.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,n.jsx)(B.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,n.jsx)(B.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>p(e.budget_id,l)})]},l))})]})]}),(0,n.jsxs)("div",{className:"mt-5",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"How to use budget id"}),(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,n.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,n.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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)'})})]})]})]})]})},lh=s(77398),lx=s.n(lh),lp=s(24525),lj=s(71594);let lg=e=>e?"string"==typeof e?e:"object"==typeof e?e.text?e.text:e.content?e.content:JSON.stringify(e):String(e):"N/A",lf=e=>{let{data:l}=e,s=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,n.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Request"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.request),null,2)})]}),(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.response),null,2)})]}),l.metadata&&Object.keys(l.metadata).length>0&&(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"}),(0,n.jsx)("div",{children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(l.metadata,null,2)})]})]})};var lZ=e=>{let{accessToken:l,token:s,userRole:t,userID:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)(!0),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(null);(0,lp.Cl)();let j=[{header:"Time",accessorKey:"startTime",cell:e=>(0,n.jsx)("span",{children:lx()(e.getValue()).format("MMM DD HH:mm:ss")})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,n.jsx)("span",{className:"font-mono text-xs",children:String(e.getValue()||"")})},{header:"Type",accessorKey:"call_type",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Request",accessorKey:"messages",cell:e=>{let l=e.getValue();try{let e="string"==typeof l?JSON.parse(l):l,t="";if(Array.isArray(e)){var s;t=lg(null===(s=e[0])||void 0===s?void 0:s.content)}else t=lg(e);return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:t})}catch(e){return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:lg(l)})}}},{header:"Model",accessorKey:"model",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,n.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,n.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"User",accessorKey:"user",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Cost",accessorKey:"spend",cell:e=>(0,n.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();return l&&0!==Object.keys(l).length?(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(l).map(e=>{let[l,s]=e;return(0,n.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[l,": ",String(s)]},l)})}):"-"}}];return((0,lj.b7)({data:i,columns:j,state:{sorting:u},onSortingChange:h,getCoreRowModel:(0,lp.sC)(),getSortedRowModel:(0,lp.tj)()}),(0,r.useEffect)(()=>{(async()=>{if(!l||!s||!t||!a){console.log("got None values for one of accessToken, token, userRole, userID");return}try{c(!0);let e=lx()().format("YYYY-MM-DD HH:mm:ss"),n=lx()().subtract(24,"hours").format("YYYY-MM-DD HH:mm:ss"),r=await (0,m.h3)(l,s,t,a,n,e);console.log("response from uiSpendLogsCall:",r);let i=r.map((e,l)=>({...e,key:l.toString()}));o(i)}catch(e){console.error("Error fetching logs:",e)}finally{c(!1)}})()},[l,s,t,a]),l&&s&&t&&a)?(0,n.jsx)("div",{className:"w-[90%] mx-auto px-4",children:(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow w-full",children:[(0,n.jsxs)("div",{className:"p-4 border-b flex justify-between items-center",children:[(0,n.jsxs)("div",{className:"flex space-x-4 items-center",children:[(0,n.jsx)("input",{type:"text",placeholder:"Search by request ID, model, or user...",className:"px-4 py-2 border rounded-lg w-80"}),(0,n.jsxs)("button",{className:"px-4 py-2 border rounded-lg flex items-center gap-2",children:[(0,n.jsx)("span",{children:"Filters"}),(0,n.jsx)("span",{className:"text-xs bg-gray-100 px-2 py-1 rounded",children:"0"})]}),(0,n.jsxs)("select",{className:"px-4 py-2 border rounded-lg",children:[(0,n.jsx)("option",{children:"Last 24 hours"}),(0,n.jsx)("option",{children:"Last 7 days"}),(0,n.jsx)("option",{children:"Last 30 days"})]})]}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Export"})})]}),(0,n.jsx)("div",{className:"overflow-x-auto w-full",children:i.length>0?(0,n.jsxs)(z.Z,{className:"w-full table-fixed",children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:j.map(e=>(0,n.jsx)(K.Z,{className:"".concat("Request ID"===e.header?"w-32":""," whitespace-nowrap"),children:e.header},e.header))})}),(0,n.jsx)(V.Z,{children:i.map(e=>(0,n.jsxs)(r.Fragment,{children:[(0,n.jsx)(W.Z,{className:"cursor-pointer hover:bg-gray-50",onClick:()=>p(x===e.request_id?null:e.request_id),children:j.map(l=>{var s;return(0,n.jsx)(B.Z,{className:"Request ID"===l.header?"w-32 truncate":"",children:l.cell?l.cell({getValue:()=>e[l.accessorKey],row:{original:e}}):(0,n.jsx)("span",{children:String(null!==(s=e[l.accessorKey])&&void 0!==s?s:"")})},l.header)})}),x===e.request_id&&(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:j.length,className:"p-0",children:(0,n.jsx)(lf,{data:{request:"string"==typeof e.messages?JSON.parse(e.messages):e.messages,response:"string"==typeof e.response?JSON.parse(e.response):e.response,metadata:e.metadata}})})})]},e.request_id||e.startTime))})]}):(0,n.jsxs)("div",{className:"p-8 text-center text-gray-500",children:[(0,n.jsx)("p",{children:"No SpendLogs messages available."}),(0,n.jsxs)("p",{className:"text-sm mt-2",children:["To enable this, set ",(0,n.jsx)("code",{children:"`general_settings.store_prompts_in_spend_logs: true`"})," in your config.yaml"]})]})})]})}):(console.log("got None values for one of accessToken, token, userRole, userID"),null)},ly=s(92699),l_=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,n.jsx)(Z.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,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,n.jsx)(ei.Z,{children:"LlamaIndex"}),(0,n.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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 ')})})]})]})]})})})},lb=s(243),lv=s(94263);async function lw(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,n=new e7.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await n.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){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lS=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,r.useState)(i?"custom":"session"),[c,j]=(0,r.useState)(""),[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)([]),[v,S]=(0,r.useState)(void 0),[k,N]=(0,r.useState)([]),I=(0,r.useRef)(null);(0,r.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,m.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),S(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,r.useEffect)(()=>{I.current&&setTimeout(()=>{var e;null===(e=I.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[y]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===g.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){w.ZP.error("Please provide an API key or select Current UI Session");return}let n=[...y,{role:"user",content:g}];_(n);try{v&&await lw(n,(e,l)=>C("assistant",e,l),v,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}f("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,n.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsx)(ed.Z,{children:(0,n.jsx)(ei.Z,{children:"Chat"})}),(0,n.jsx)(em.Z,{children:(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"API Key Source"}),(0,n.jsx)(b.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,n.jsx)(p.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:j,value:c})]}),(0,n.jsxs)(u.Z,{className:"mx-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model:"}),(0,n.jsx)(b.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),S(e)},options:k,style:{width:"350px"},showSearch:!0})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{_([]),w.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,n.jsxs)(z.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{})})}),(0,n.jsxs)(V.Z,{children:[y.map((e,l)=>(0,n.jsx)(W.Z,{children:(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,n.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,n.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,n.jsx)(lb.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...r}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,n.jsx)(eI.Z,{style:lv.Z,language:i[1],PreTag:"div",...r,children:String(a).replace(/\n$/,"")}):(0,n.jsx)("code",{className:t,...r,children:a})}},children:e.content})})]})},l)),(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{children:(0,n.jsx)("div",{ref:I,style:{height:"1px"}})})})]})]}),(0,n.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,n.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,n.jsx)(p.Z,{type:"text",value:g,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,n.jsx)(x.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},lk=s(19226),lN=s(61787),lI=s(92403),lC=s(28595),lA=s(68208),lP=s(9775),lE=s(41361),lO=s(37527),lT=s(15883),lR=s(12660),lD=s(88009),lM=s(41169),lF=s(48231),lL=s(44625),lU=s(55322);let{Sider:lz}=lk.default,lV=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lB=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,n.jsx)(lI.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,n.jsx)(lC.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,n.jsx)(lA.Z,{}),roles:lV},{key:"4",page:"usage",label:"Usage",icon:(0,n.jsx)(lP.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,n.jsx)(lE.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,n.jsx)(lO.Z,{}),roles:lV},{key:"5",page:"users",label:"Internal Users",icon:(0,n.jsx)(lT.Z,{}),roles:lV},{key:"14",page:"api_ref",label:"API Reference",icon:(0,n.jsx)(lR.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,n.jsx)(lD.Z,{})},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,n.jsx)(lM.Z,{}),roles:lV,children:[{key:"15",page:"logs",label:"Logs",icon:(0,n.jsx)(lF.Z,{}),roles:lV},{key:"9",page:"caching",label:"Caching",icon:(0,n.jsx)(lL.Z,{}),roles:lV},{key:"10",page:"budgets",label:"Budgets",icon:(0,n.jsx)(lO.Z,{}),roles:lV}]},{key:"settings",page:"settings",label:"Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,n.jsx)(lR.Z,{}),roles:lV},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV}]}];var lq=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=lB.find(l=>l.page===e);if(l)return l.key;for(let l of lB)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),r=lB.filter(e=>!e.roles||e.roles.includes(s));return(0,n.jsx)(lk.default,{style:{minHeight:"100vh"},children:(0,n.jsx)(lz,{theme:"light",width:220,children:(0,n.jsx)(lN.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:r.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)}}})})})})},lK=s(96889),lW=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lH=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lG=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,p]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[w,S]=(0,r.useState)([]),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)([]),[A,P]=(0,r.useState)([]),[E,O]=(0,r.useState)([]),[T,R]=(0,r.useState)([]),[D,M]=(0,r.useState)({}),[F,U]=(0,r.useState)([]),[J,Y]=(0,r.useState)(""),[X,Q]=(0,r.useState)(["all-tags"]),[ee,el]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[es,et]=(0,r.useState)(null),ea=new Date(d.getFullYear(),d.getMonth(),1),ej=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(ea),ef=ev(ej);function eZ(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 ey=async()=>{if(l)try{let e=await (0,m.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,r.useEffect)(()=>{eb(ee.from,ee.to)},[ee,X]);let e_=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,m.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),v(a)},eb=async(e,s)=>{if(!e||!s||!l)return;let t=await ey();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,m.J$)(l,e.toISOString(),s.toISOString(),0===X.length?void 0:X)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ev(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(eg)),console.log("End date is ".concat(ef));let ew=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eS=()=>ew(()=>l?(0,m.FC)(l):Promise.reject("No access token"),p,"Error fetching overall spend"),ek=()=>ew(()=>l&&s?(0,m.OU)(l,s,eg,ef):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await ew(async()=>(await (0,m.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend})),g,"Error fetching top keys")},eI=async()=>{l&&await ew(async()=>(await (0,m.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),_,"Error fetching top models")},eC=async()=>{l&&await ew(async()=>{let e=await (0,m.mR)(l);return S(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eA=()=>{l&&ew(async()=>(await (0,m.X)(l)).tag_names,C,"Error fetching tag names")},eP=()=>{l&&ew(()=>{var e,s;return(0,m.J$)(l,null===(e=ee.from)||void 0===e?void 0:e.toISOString(),null===(s=ee.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>N(e.spend_per_tag),"Error fetching top tags")},eE=()=>{l&&ew(()=>(0,m.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eO=()=>{l&&ew(()=>(0,m.wd)(l,eg,ef),M,"Error fetching global activity")},eT=()=>{l&&ew(()=>(0,m.xA)(l,eg,ef),U,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ey();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),eS(),ek(),eN(),eI(),eO(),eT(),lH(t)&&(eC(),eA(),eP(),eE()))}})()},[l,s,t,a,eg,ef]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,n.jsxs)(Z.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,n.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,n.jsx)(x.Z,{className:"mt-4",children:(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{className:"mt-2",children:[(0,n.jsx)(ei.Z,{children:"All Up"}),lH(t)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ei.Z,{children:"Team Based Usage"}),(0,n.jsx)(ei.Z,{children:"Customer Usage"}),(0,n.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{})})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"solid",className:"mt-1",children:[(0,n.jsx)(ei.Z,{children:"Cost"}),(0,n.jsx)(ei.Z,{children:"Activity"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,n.jsx)($,{userID:a,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Monthly Spend"}),(0,n.jsx)(ep.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top API Keys"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top Models"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:f,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(lW.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend"})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Provider"}),(0,n.jsx)(K.Z,{children:"Spend"})]})}),(0,n.jsx)(V.Z,{children:T.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.provider}),(0,n.jsx)(B.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"All Up"}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(D.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(D.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,n.jsx)(n.Fragment,{children:F.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,n.jsx)(n.Fragment,{children:F&&F.length>0&&F.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eZ,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(u.Z,{numColSpan:2,children:[(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,n.jsx)(lK.Z,{data:E})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,n.jsx)(ep.Z,{className:"h-72",data:w,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,n.jsx)(u.Z,{numColSpan:2})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.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,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),e_(e.from,e.to,null)}})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Key"}),(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{e_(ee.from,ee.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,n.jsx)(G.Z,{value:String(l),onClick:()=>{e_(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,n.jsx)(L.Z,{className:"mt-4",children:(0,n.jsxs)(z.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Customer"}),(0,n.jsx)(K.Z,{children:"Spend"}),(0,n.jsx)(K.Z,{children:"Total Events"})]})}),(0,n.jsx)(V.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.end_user}),(0,n.jsx)(B.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,n.jsx)(B.Z,{children:e.total_count})]},l)})})]})})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(er.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,n.jsx)(u.Z,{children:o?(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsx)(eh.Z,{value:String(e),children:e},e))]})}):(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsxs)(G.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Spend Per Tag"}),(0,n.jsxs)(Z.Z,{children:["Get Started Tracking cost per tag ",(0,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,n.jsx)(ep.Z,{className:"h-72",data:k,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,n.jsx)(u.Z,{numColSpan:2})]})]})]})]})})};let lJ=e=>{if(e)return e.toISOString().split("T")[0]};function lY(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lX=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,x]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,f]=(0,r.useState)([]),[Z,y]=(0,r.useState)("0"),[_,b]=(0,r.useState)("0"),[v,w]=(0,r.useState)("0"),[S,k]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&S&&(async()=>{f(await (0,m.zg)(l,lJ(S.from),lJ(S.to)))})()},[l]);let N=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),I=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let C=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),f(await (0,m.zg)(l,lJ(e),lJ(s))))};return(0,r.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",g);let e=g;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),p.length>0&&(e=e.filter(e=>p.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 n=e.find(e=>e.name===a.call_type);return n?(n["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),n["Cache hit"]+=a.cache_hit_true_rows||0,n["Cached Completion Tokens"]+=a.cached_completion_tokens||0,n["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(lY(s)),b(lY(t));let n=s+l;n>0?w((s/n*100).toFixed(2)):w("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,p,S,g]),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(h.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select API Keys",value:c,onValueChange:x,children:N.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(er.Z,{enableSelect:!0,value:S,onValueChange:e=>{k(e),C(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Z})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]})]}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,n.jsx)(ep.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,n.jsx)(ep.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l$=()=>{let{Title:e,Paragraph:l}=et.default,[s,t]=(0,r.useState)(""),[a,o]=(0,r.useState)(!1),[d,u]=(0,r.useState)(!1),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[_,b]=(0,r.useState)(!0),v=(0,i.useSearchParams)(),[w,S]=(0,r.useState)({data:[]}),[k,N]=(0,r.useState)(null),I=v.get("userID"),C=v.get("invitation_id"),[A,P]=(0,r.useState)(()=>v.get("page")||"api-keys"),[E,O]=(0,r.useState)(null);return(0,r.useEffect)(()=>{N(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,r.useEffect)(()=>{if(!k)return;let e=(0,es.o)(k);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),O(e.key),u(e.disabled_non_admin_personal_key_creation),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&P("usage")}else console.log("User role not defined");e.user_email?x(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?b("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user),e.auth_header_name&&(0,m.K8)(e.auth_header_name)}},[k]),(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)("div",{children:"Loading..."}),children:C?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):(0,n.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,n.jsx)(c,{userID:I,userRole:s,userEmail:h,premiumUser:a,setProxySettings:y,proxySettings:Z}),(0,n.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,n.jsx)("div",{className:"mt-8",children:(0,n.jsx)(lq,{setPage:e=>{let l=new URLSearchParams(v);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),P(e)},userRole:s,defaultSelectedKey:A})}),"api-keys"==A?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):"models"==A?(0,n.jsx)(eT,{userID:I,userRole:s,token:k,keys:g,accessToken:E,modelData:w,setModelData:S,premiumUser:a}):"llm-playground"==A?(0,n.jsx)(lS,{userID:I,userRole:s,token:k,accessToken:E,disabledPersonalKeyCreation:d}):"users"==A?(0,n.jsx)(eL,{userID:I,userRole:s,token:k,keys:g,teams:p,accessToken:E,setKeys:f}):"teams"==A?(0,n.jsx)(ez,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s}):"organizations"==A?(0,n.jsx)(eY,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s,premiumUser:a}):"admin-panel"==A?(0,n.jsx)(eX,{setTeams:j,searchParams:v,accessToken:E,showSSOBanner:_,premiumUser:a}):"api_ref"==A?(0,n.jsx)(l_,{proxySettings:Z}):"settings"==A?(0,n.jsx)(e8,{userID:I,userRole:s,accessToken:E,premiumUser:a}):"budgets"==A?(0,n.jsx)(lu,{accessToken:E}):"general-settings"==A?(0,n.jsx)(ls,{userID:I,userRole:s,accessToken:E,modelData:w}):"model-hub"==A?(0,n.jsx)(ly.Z,{accessToken:E,publicPage:!1,premiumUser:a}):"caching"==A?(0,n.jsx)(lX,{userID:I,userRole:s,token:k,accessToken:E,premiumUser:a}):"pass-through-settings"==A?(0,n.jsx)(ld,{userID:I,userRole:s,accessToken:E,modelData:w}):"logs"==A?(0,n.jsx)(lZ,{userID:I,userRole:s,token:k,accessToken:E}):(0,n.jsx)(lG,{userID:I,userRole:s,token:k,accessToken:E,keys:g,premiumUser:a})]})]})})}}},function(e){e.O(0,[665,990,42,261,755,978,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 5e2c2d24b7d..202c0821724 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 96cf942cfb6..3e70cd4614d 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[69623,["665","static/chunks/3014691f-879b58d3fc1547e5.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-4c9a56afdf4d8d5b.js","261","static/chunks/261-1a8c5eb3e86e9745.js","755","static/chunks/755-c7e0ae255f32cb18.js","978","static/chunks/978-8a30252ea2e72994.js","250","static/chunks/250-14d49cbd51f2ae7d.js","699","static/chunks/699-bf55769caf9128ce.js","931","static/chunks/app/page-f3fef89bb008195a.js"],"default",1]
+3:I[69623,["665","static/chunks/3014691f-879b58d3fc1547e5.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-4c9a56afdf4d8d5b.js","261","static/chunks/261-1a8c5eb3e86e9745.js","755","static/chunks/755-c7e0ae255f32cb18.js","978","static/chunks/978-8a30252ea2e72994.js","250","static/chunks/250-14d49cbd51f2ae7d.js","699","static/chunks/699-bf55769caf9128ce.js","931","static/chunks/app/page-7af065b71201666b.js"],"default",1]
4:I[4707,[],""]
5:I[36423,[],""]
-0:["mtFU-WaJL2V39gBiXh0cn",[[["",{"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/04831c41b377e329.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:["0Ao-pNdjmYzz5_ojxRT0i",[[["",{"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/04831c41b377e329.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.html b/litellm/proxy/_experimental/out/model_hub.html
index 13f85f7e78c..b30d16fff84 100644
--- a/litellm/proxy/_experimental/out/model_hub.html
+++ b/litellm/proxy/_experimental/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/litellm/proxy/_experimental/out/model_hub.txt b/litellm/proxy/_experimental/out/model_hub.txt
index 4e395443b5a..a771151da6f 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-4c9a56afdf4d8d5b.js","261","static/chunks/261-1a8c5eb3e86e9745.js","250","static/chunks/250-14d49cbd51f2ae7d.js","699","static/chunks/699-bf55769caf9128ce.js","418","static/chunks/app/model_hub/page-227e49e1b9d01e96.js"],"default",1]
4:I[4707,[],""]
5:I[36423,[],""]
-0:["mtFU-WaJL2V39gBiXh0cn",[[["",{"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/04831c41b377e329.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:["0Ao-pNdjmYzz5_ojxRT0i",[[["",{"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/04831c41b377e329.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 1e6be751359..3ab72ec5024 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 792bf9c9856..a20fc7ebb38 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-879b58d3fc1547e5.js","42","static/chunks/42-4c9a56afdf4d8d5b.js","755","static/chunks/755-c7e0ae255f32cb18.js","250","static/chunks/250-14d49cbd51f2ae7d.js","461","static/chunks/app/onboarding/page-ae78048a415c7f25.js"],"default",1]
4:I[4707,[],""]
5:I[36423,[],""]
-0:["mtFU-WaJL2V39gBiXh0cn",[[["",{"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/04831c41b377e329.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:["0Ao-pNdjmYzz5_ojxRT0i",[[["",{"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/04831c41b377e329.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 c4143fa9124..03d4e13c556 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/mtFU-WaJL2V39gBiXh0cn/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_buildManifest.js
similarity index 100%
rename from ui/litellm-dashboard/out/_next/static/mtFU-WaJL2V39gBiXh0cn/_buildManifest.js
rename to ui/litellm-dashboard/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_buildManifest.js
diff --git a/ui/litellm-dashboard/out/_next/static/mtFU-WaJL2V39gBiXh0cn/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_ssgManifest.js
similarity index 100%
rename from ui/litellm-dashboard/out/_next/static/mtFU-WaJL2V39gBiXh0cn/_ssgManifest.js
rename to ui/litellm-dashboard/out/_next/static/0Ao-pNdjmYzz5_ojxRT0i/_ssgManifest.js
diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-f3fef89bb008195a.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-7af065b71201666b.js
similarity index 83%
rename from ui/litellm-dashboard/out/_next/static/chunks/app/page-f3fef89bb008195a.js
rename to ui/litellm-dashboard/out/_next/static/chunks/app/page-7af065b71201666b.js
index a5d8fc51861..134dbea855c 100644
--- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-f3fef89bb008195a.js
+++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-7af065b71201666b.js
@@ -1 +1 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,69623))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),n=s(99376),r=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),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,n.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,y]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,k]=(0,a.useState)(null),[N,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),y(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),k(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)(r.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=v,S&&s&&(0,p.m_)(Z,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)(g.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)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},69623:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l$}});var t,a,n=s(57437),r=s(2265),i=s(99376),o=s(27648),d=s(92643),c=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",a),console.log=function(){};let c="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(c=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",c);let m=[{key:"1",label:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{children:["Role: ",s]}),(0,n.jsxs)("p",{children:["ID: ",l]}),(0,n.jsxs)("p",{children:["Premium User: ",String(a)]})]})},{key:"2",label:(0,n.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=c},children:"Logout"})}];return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,n.jsx)("div",{className:"w-full px-4",children:(0,n.jsxs)("div",{className:"flex justify-between items-center h-14",children:[(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)(o.default,{href:"/",className:"flex items-center",children:[(0,n.jsx)("span",{className:"text-xl",children:"\uD83D\uDE85"}),(0,n.jsx)("span",{className:"ml-2 text-base font-medium text-gray-700",children:"LiteLLM"})]})}),(0,n.jsxs)("div",{className:"flex items-center space-x-6",children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-gray-600 hover:text-gray-800",children:"Docs"}),(0,n.jsx)(d.Z,{menu:{items:m},children:(0,n.jsxs)("button",{className:"flex items-center text-sm text-gray-600 hover:text-gray-800",children:["Admin",(0,n.jsx)("svg",{className:"ml-1 w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})})},m=s(19250),u=s(49804),h=s(67101),x=s(20831),p=s(26637),j=s(87452),g=s(88829),f=s(72208),Z=s(84264),y=s(96761),_=s(29233),b=s(41326),v=s(13634),w=s(41021),S=s(51369),k=s(8104),N=s(20577),I=s(56632),C=s(73002);let{Option:A}=b.default,P=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};var E=e=>{let{userID:l,team:s,userRole:t,accessToken:a,data:i,setData:o}=e,[d]=v.Z.useForm(),[c,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(null),[R,D]=(0,r.useState)(null),[M,F]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[z,V]=(0,r.useState)("you"),[B,q]=(0,r.useState)(P(i)),K=()=>{E(!1),d.resetFields()},W=()=>{E(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==a){let e=(await (0,m.So)(a,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,t]);let H=async e=>{try{var s,t,n;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(n=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==n?n:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(w.ZP.info("Making API Call"),E(!0),"service_account"===z){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 u=await (0,m.wX)(a,l,e);console.log("key create Response:",u),o(e=>e?[...e,u]:[u]),T(u.key),D(u.soft_budget),w.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),w.ZP.error("Error creating the key: ".concat(e))}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Key"}),(0,n.jsx)(S.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,n.jsxs)(v.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Owned By",className:"mb-4",children:(0,n.jsxs)(k.ZP.Group,{onChange:e=>V(e.target.value),value:z,children:[(0,n.jsx)(k.ZP,{value:"you",children:"You"}),(0,n.jsx)(k.ZP,{value:"service_account",children:"Service Account"}),"Admin"===t&&(0,n.jsx)(k.ZP,{value:"another_user",children:"Another User"})]})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==z,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===z,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,n.jsx)(p.Z,{placeholder:"User ID",onChange:e=>d.setFieldValue("user_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"you"===z||"another_user"===z?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===z?"key name":"service account ID")}],help:"you"===z?"required":"IDs can include letters, numbers, and hyphens",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",hidden:"another_user"!==z,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,n.jsx)(p.Z,{defaultValue:s?s.team_id:null,onChange:e=>d.setFieldValue("team_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,n.jsx)(A,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,n.jsx)(A,{value:e,children:e},e))]})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.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,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)(v.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,n.jsx)(b.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:B})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),O&&(0,n.jsx)(S.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Save your Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,n.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,n.jsx)(u.Z,{numColSpan:1,children:null!=O?(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:O})}),(0,n.jsx)(_.CopyToClipboard,{text:O,onCopy:()=>{w.ZP.success("API Key copied to clipboard")},children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,n.jsx)(Z.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(7366),T=s(15731),R=s(53410),D=s(23628),M=s(74998),F=s(41649),L=s(12514),U=s(47323),z=s(21626),V=s(97214),B=s(28241),q=s(58834),K=s(69552),W=s(71876),H=s(27281),G=s(57365),J=s(90464);let{Option:Y}=b.default;console.log=function(){};var X=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,data:i,setData:o,teams:d,premiumUser:c}=e,[j,g]=(0,r.useState)(!1),[f,k]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[X,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)([]),ed=new Set,[ec,em]=(0,r.useState)(!1),[eu,eh]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)(null),[ej,eg]=(0,r.useState)(null),[ef]=v.Z.useForm(),[eZ,ey]=(0,r.useState)(null),[e_,eb]=(0,r.useState)(ed),ev=e=>!!e.members_with_roles&&e.members_with_roles.some(e=>"admin"===e.role&&e.user_id===l),ew=r.useMemo(()=>{let e=[];return d&&0!==d.length?(d.forEach(l=>{"default-team"!==l.team_id&&ev(l)?ev(l)&&a&&a.team_id===l.team_id&&(e=[...e,...l.keys||[]]):a&&a.team_id===l.team_id&&i&&(e=[...e,...i.filter(e=>e.team_id===l.team_id)])}),!a&&i&&(e=[...i.filter(e=>!e.team_id||"default-team"===e.team_id),...d.filter(e=>ev(e)).flatMap(e=>e.keys||[])]),Array.from(new Map((e=e.filter(e=>"litellm-dashboard"!==e.team_id)).map(e=>[e.token,e])).values())):i},[i,d,a,l]);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",en),(null==ej?void 0:ej.duration)?ey((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,O.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,O.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,O.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}})(ej.duration)):ey(null),console.log("calculateNewExpiryTime:",eZ)},[en,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),eo(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]);let eS=e=>{er(e),em(!0)},ek=async e=>{if(null==t||null==en)return;let l={...en,metadata:e,key:en.token};try{let e=await (0,m.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===en.token?e:l);o(l)}w.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),w.ZP.error("Failed to update model-specific limits")}em(!1),er(null)};(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),eb(e)}},[d]);let eN=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id);let l=null;if(e.budget_duration)switch(e.budget_duration){case"24h":l="daily";break;case"7d":l="weekly";break;case"30d":l="monthly";break;default:l="None"}er({...e,budget_duration:l}),es(!0)},eI=async e=>{if(null==t)return;let l=e.token;if(e.key=l,e.metadata&&"string"==typeof e.metadata)try{e.metadata=JSON.parse(e.metadata)}catch(l){console.error("Error parsing metadata JSON:",l),w.ZP.error("Invalid metadata JSON for formValue "+e.metadata);return}if(e.budget_duration)switch(e.budget_duration){case"daily":e.budget_duration="24h";break;case"weekly":e.budget_duration="7d";break;case"monthly":e.budget_duration="30d"}console.log("handleEditSubmit:",e);let s=await (0,m.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),w.ZP.success("Key updated successfully"),es(!1),er(null)},eC=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(A(e.token),localStorage.removeItem("userData"+l),k(!0))},eA=async()=>{if(null!=I&&null!=i){try{await (0,m.I1)(t,I);let e=i.filter(e=>e.token!==I);o(e)}catch(e){console.error("Error deleting the key:",e)}k(!1),A(null)}},eP=e=>{er(e),ey(null),ef.setFieldsValue({key_alias:e.key_alias,max_budget:e.max_budget,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,duration:e.duration||""}),eh(!0)},eE=(e,l)=>{eg(s=>({...s,[e]:l}))},eO=async()=>{if(!c){w.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=en)try{let e=await ef.validateFields(),l=await (0,m.s0)(t,en.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==en?void 0:en.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),ef.resetFields(),w.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),w.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,n.jsxs)("div",{children:[(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,n.jsxs)(z.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Key Alias"}),(0,n.jsx)(K.Z,{children:"Secret Key"}),(0,n.jsx)(K.Z,{children:"Created"}),(0,n.jsx)(K.Z,{children:"Expires"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Budget Reset"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"Rate Limits"}),(0,n.jsx)(K.Z,{children:"Rate Limits per model"})]})}),(0,n.jsx)(V.Z,{children:ew&&ew.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(a){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(e_.has(e.team_id),", selectedTeam id: ").concat(a.team_id)),(null!=a.team_id||null===e.team_id||e_.has(e.team_id))&&e.team_id!=a.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,n.jsx)(Z.Z,{children:e.key_alias}):(0,n.jsx)(Z.Z,{children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.key_name})}),(0,n.jsx)(B.Z,{children:null!=e.created_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,n.jsx)(B.Z,{children:null!=e.expires?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,n.jsx)(B.Z,{children:null!=e.max_budget?(0,n.jsx)(Z.Z,{children:e.max_budget}):(0,n.jsx)(Z.Z,{children:"Unlimited"})}),(0,n.jsx)(B.Z,{children:null!=e.budget_reset_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(n.Fragment,{children:a&&a.models&&a.models.length>0?a.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{size:"xs",onClick:()=>eS(e),children:"Edit Limits"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{onClick:()=>{er(e),ea(!0)},icon:T.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:et,onCancel:()=>{ea(!1),er(null)},footer:null,width:800,children:en&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(en.spend).toFixed(4)}catch(e){return en.spend}})()})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.max_budget?(0,n.jsxs)(n.Fragment,{children:[en.max_budget,en.budget_duration&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("br",{}),"Budget will be reset at ",en.budget_reset_at?new Date(en.budget_reset_at).toLocaleString():"Never"]})]}):(0,n.jsx)(n.Fragment,{children:"Unlimited"})})})]},e.name),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.expires?(0,n.jsx)(n.Fragment,{children:new Date(en.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,n.jsx)(n.Fragment,{children:"Never"})})})]},e.name)]}),(0,n.jsxs)(L.Z,{className:"my-4",children:[(0,n.jsx)(y.Z,{children:"Token Name"}),(0,n.jsx)(Z.Z,{className:"my-1",children:en.key_alias?en.key_alias:en.key_name}),(0,n.jsx)(y.Z,{children:"Token ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.token}),(0,n.jsx)(y.Z,{children:"User ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.user_id}),(0,n.jsx)(y.Z,{children:"Metadata"}),(0,n.jsx)(Z.Z,{className:"my-1",children:(0,n.jsxs)("pre",{children:[JSON.stringify(en.metadata)," "]})})]}),(0,n.jsx)(x.Z,{className:"mx-auto flex items-center",onClick:()=>{ea(!1),er(null)},children:"Close"})]})}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>eN(e)}),(0,n.jsx)(U.Z,{onClick:()=>eP(e),icon:D.Z,size:"sm"}),(0,n.jsx)(U.Z,{onClick:()=>eC(e),icon:M.Z,size:"sm"})]})]},e.token)})})]}),f&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:eA,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{k(!1),A(null)},children:"Cancel"})]})]})]})})]}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=v.Z.useForm(),[c,m]=(0,r.useState)(a),[u,h]=(0,r.useState)([]),[x,j]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let f=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,n.jsx)(S.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:o,onFinish:eI,initialValues:f,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(Y,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ei.filter(e=>"all-proxy-models"!==e).map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):c.models.map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):ei.map(e=>(0,n.jsx)(Y,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Current Reset Budget: ".concat(t.budget_duration,", budget will be reset: ").concat(t.budget_reset_at?new Date(t.budget_reset_at).toLocaleString():"Never"),children:(0,n.jsxs)(b.default,{placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"daily",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"weekly",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"monthly",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"token",name:"token",hidden:!0}),(0,n.jsx)(v.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,n.jsx)(H.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,n.jsx)(G.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"TPM Limit (tokens per minute)",name:"tpm_limit",help:"tpm_limit cannot exceed team tpm_limit ".concat((null==c?void 0:c.tpm_limit)!==null&&(null==c?void 0:c.tpm_limit)!==void 0?null==c?void 0:c.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.tpm_limit&&l>c.tpm_limit)throw console.log("keyTeam.tpm_limit: ".concat(c.tpm_limit)),Error("tpm_limit cannot exceed team max tpm_limit: $".concat(c.tpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max rpm_limit: ".concat((null==c?void 0:c.rpm_limit)!==null&&(null==c?void 0:c.rpm_limit)!==void 0?null==c?void 0:c.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.rpm_limit&&l>c.rpm_limit)throw console.log("keyTeam.rpm_limit: ".concat(c.rpm_limit)),Error("rpm_limit cannot exceed team max rpm_limit: $".concat(c.rpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,n.jsx)(J.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:en,onSubmit:eI}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:a,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,u]=(0,r.useState)([]),[h,p]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(t.metadata){let e=t.metadata.model_tpm_limit||{},l=t.metadata.model_rpm_limit||{},s={};Object.keys({...e,...l}).forEach(t=>{s[t]={tpm:e[t]||0,rpm:l[t]||0}}),d(s)}(async()=>{try{let e=await (0,m.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));u(l)}catch(e){console.error("Error fetching model data:",e),w.ZP.error("Failed to fetch available models")}})()},[t,i]);let j=(e,l,s)=>{d(t=>({...t,[e]:{...t[e],[l]:s||0}}))},g=e=>{d(l=>{let{[e]:s,...t}=l;return t})};return(0,n.jsxs)(S.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model"}),(0,n.jsx)(K.Z,{children:"TPM Limit"}),(0,n.jsx)(K.Z,{children:"RPM Limit"}),(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsxs)(V.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:l}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(b.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),p(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,n.jsx)(Y,{value:e,children:e},e))})}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>p(null),children:"Cancel"})})]})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{p("")},disabled:null!==h,children:"Add Limit"})]}),(0,n.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,n.jsx)(x.Z,{onClick:s,children:"Cancel"}),(0,n.jsx)(x.Z,{onClick:()=>{a({...t.metadata,model_tpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.tpm]})),model_rpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.rpm]}))})},children:"Save"})]})]})},{visible:ec,onCancel:()=>em(!1),token:en,onSubmit:ek,accessToken:t}),(0,n.jsx)(S.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),ef.resetFields()},footer:[(0,n.jsx)(x.Z,{onClick:()=>{eh(!1),ef.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,n.jsx)(x.Z,{onClick:eO,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,n.jsxs)(v.Z,{form:ef,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eE("duration",e.duration)},children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{disabled:!0})}),(0,n.jsx)(v.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,n.jsx)(N.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==en?void 0:en.expires)!=null?new Date(en.expires).toLocaleString():"Never"]}),eZ&&(0,n.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eZ]})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,n.jsx)(S.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,n.jsx)(x.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Regenerated Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,n.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,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"Key Alias:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==en?void 0:en.key_alias)||"No alias set"})}),(0,n.jsx)(Z.Z,{className:"mt-3",children:"New API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,n.jsx)(_.CopyToClipboard,{text:ex,onCopy:()=>w.ZP.success("API Key copied to clipboard"),children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,r.useState)(null!==a?a:0),[u,h]=(0,r.useState)(o?o.max_budget:null);(0,r.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)h(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&&(h(s.litellm_budget_table.max_budget),e=!0);e||h(o.max_budget)}}},[o,i]);let[x,p]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",x),j=x):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=x);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,n.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==u?"$".concat(u," limit"):"No limit"})]})]})})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==a){let e=(await (0,m.So)(a,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==t?void 0:t.team_alias}),(null==t?void 0:t.team_id)&&(0,n.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},ee=e=>{let l,{teams:s,setSelectedTeam:t,userRole:a,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let u={models:(null==d?void 0:d.models)||[],team_id:null,team_alias:"Default Team",max_budget:(null==d?void 0:d.max_budget)||null},h=async()=>{null===i&&c&&o(await (0,m.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(u);return console.log("userRole: ".concat(a)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===a?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[u]:s?[...s,u]:[u],(0,n.jsxs)("div",{className:"mt-5 mb-5",children:[(0,n.jsx)(y.Z,{children:"Select Team"}),(0,n.jsx)(Z.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,n.jsxs)(Z.Z,{className:"mt-3 mb-3",children:[(0,n.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,n.jsxs)(Z.Z,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]})},el=s(12011),es=s(14474),et=s(68060);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:x,setKeys:p,premiumUser:j}=e,[g,f]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let y=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),_=Z.get("invitation_id"),[b,v]=(0,r.useState)(null),[w,S]=(0,r.useState)(null),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)(null),A={models:[],team_alias:"Default Team",team_id:null},[P,O]=(0,r.useState)(t?t[0]:A);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,es.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!a&&!g){let e=sessionStorage.getItem("userModels"+l);if(e)N(JSON.parse(e));else{let e=async()=>{let e;e="Admin"!=s&&"Admin Viewer"!=s?await (0,m.It)(b,l):await (0,m.It)(b),console.log("givenTeams: ".concat(e)),x(e)};(async()=>{try{let e=await (0,m.g)(b);C(e);let t=await (0,m.Br)(b,l,s,!1,null,null);console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),f(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys);let a=[...t.teams];a.length>0?(console.log("response['teams']: ".concat(a)),O(a[0])):O(A),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let n=(await (0,m.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),N(n),console.log("userModels:",k),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})(),e()}}},[l,y,b,a,s]),(0,r.useEffect)(()=>{if(null!==a&&null!=P&&null!==P.team_id){let e=0;for(let l of a)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);S(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;S(e)}},[P]),null!=_)return(0,n.jsx)(el.default,{});if(null==l||null==y){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==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Q,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,n.jsx)($,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:w,selectedTeam:P||null}),(0,n.jsx)(X,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:a,setData:p,premiumUser:j,teams:t}),(0,n.jsx)(E,{userID:l,team:P||null,userRole:s,accessToken:b,data:a,setData:p},P?P.team_id:null),(0,n.jsx)(ee,{teams:t,setSelectedTeam:O,userRole:s,proxySettings:I,setProxySettings:C,userInfo:g,accessToken:b})]})})})},en=s(97765),er=s(53003),ei=s(12485),eo=s(18135),ed=s(35242),ec=s(29706),em=s(77991),eu=s(92414),eh=s(46030),ex=s(75105),ep=s(40278),ej=s(75957),eg=s(69410),ef=s(47451),eZ=s(14301),ey=s(2356),e_=e=>{let{modelID:l,accessToken:s}=e,[t,a]=(0,r.useState)(!1),i=async()=>{try{w.ZP.info("Making API Call"),a(!0);let e=await (0,m.Og)(s,l);console.log("model delete Response:",e),w.ZP.success("Model ".concat(l," deleted successfully")),a(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(U.Z,{onClick:()=>a(!0),icon:M.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>a(!1),children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Delete Model"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Model ID: ",(0,n.jsx)("b",{children:l})]})})]})})]})},eb=s(3632),ev=s(18502),ew=s(94789),eS=s(59664),ek=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,n.jsx)(eS.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,n.jsxs)("div",{children:[(0,n.jsx)(ew.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,n.jsx)(x.Z,{variant:"primary",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eN=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,n.jsx)(n.Fragment,{children:l.map(e=>(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,n.jsx)(p.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eI=s(17906);let{Title:eC,Link:eA}=et.default;(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",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.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI";let eP={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"},eE={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eO=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},a={};t.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eP[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=s;else if("custom_model_name"===l)t.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 w.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw w.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 t[l]=s}let r={model_name:n,litellm_params:t,model_info:a},i=await (0,m.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){w.ZP.error("Failed to create model: "+e,10)}};var eT=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:u,premiumUser:j}=e,[g,f]=(0,r.useState)([]),[_]=v.Z.useForm(),[b,k]=(0,r.useState)(null),[I,A]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),O=Object.values(a).filter(e=>isNaN(Number(e))),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[ea,ew]=(0,r.useState)(!1),[eS,eT]=(0,r.useState)(null),[eR,eD]=(0,r.useState)([]),[eM,eF]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[ez,eV]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[eK,eW]=(0,r.useState)([]),[eH,eG]=(0,r.useState)([]),[eJ,eY]=(0,r.useState)([]),[eX,e$]=(0,r.useState)([]),[eQ,e0]=(0,r.useState)([]),[e1,e2]=(0,r.useState)([]),[e4,e5]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e7]=(0,r.useState)(null),[e9,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,la]=(0,r.useState)([]),[ln,lr]=(0,r.useState)(!1),[li,lo]=(0,r.useState)(null),[ld,lc]=(0,r.useState)(null),[lm,lu]=(0,r.useState)([]),lh=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),!s||!o||!i||!l||!t)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),eU(e);let a=null==li?void 0:li.token;void 0===a&&(a=null);let n=ld;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,m.o6)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,m.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,m.N8)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let u=await (0,m.fP)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);if(console.log("slowResponses:",u),e5(u),e){let a=await (0,m.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(a);let n=await (0,m.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{eT(e),es(!0)},lp=e=>{eT(e),ew(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,a]of(e.input_cost_per_million_tokens&&(e.input_cost_per_token=e.input_cost_per_million_tokens/1e6,delete e.input_cost_per_million_tokens),e.output_cost_per_million_tokens&&(e.output_cost_per_token=e.output_cost_per_million_tokens/1e6,delete e.output_cost_per_million_tokens),Object.entries(e)))"model_id"!==s?l[s]=a:t=a;let a={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",a);try{await (0,m.um)(s,a),w.ZP.success("Model updated successfully, restart server to see updates"),es(!1),eT(null)}catch(e){console.log("Error occurred")}},lg=()=>{A(new Date().toLocaleString())},lf=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,m.K_)(s,{router_settings:{model_group_retry_policy:e6}}),w.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),w.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!s||!t||!i||!o)return;let e=async()=>{try{var e,l,t,a,n,r,d,c,h,x,p,j;let g=await (0,m.hy)(s);Y(g);let f=await (0,m.AZ)(s,o,i);console.log("Model data response:",f.data),u(f);let Z=new Set;for(let e=0;e0&&(_=y[y.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",eL);let b=await (0,m.o6)(s,o,i,_,null===(e=e8.from)||void 0===e?void 0:e.toISOString(),null===(l=e8.to)||void 0===l?void 0:l.toISOString(),null==li?void 0:li.token,ld);console.log("Model metrics response:",b),eq(b.data),eW(b.all_api_bases);let v=await (0,m.Rg)(s,_,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(a=e8.to)||void 0===a?void 0:a.toISOString());eG(v.data),eY(v.all_api_bases);let w=await (0,m.N8)(s,o,i,_,null===(n=e8.from)||void 0===n?void 0:n.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",w),e$(w.data),e0(w.exception_types);let S=await (0,m.fP)(s,o,i,_,null===(d=e8.from)||void 0===d?void 0:d.toISOString(),null===(c=e8.to)||void 0===c?void 0:c.toISOString(),null==li?void 0:li.token,ld),k=await (0,m.n$)(s,null===(h=e8.from)||void 0===h?void 0:h.toISOString().split("T")[0],null===(x=e8.to)||void 0===x?void 0:x.toISOString().split("T")[0],_);ls(k);let N=await (0,m.v9)(s,null===(p=e8.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=e8.to)||void 0===j?void 0:j.toISOString().split("T")[0],_);la(N),console.log("dailyExceptions:",k),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",S),e5(S);let I=await (0,m.j2)(s);lu(null==I?void 0:I.end_users);let C=(await (0,m.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,P=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",P),e7(A),le(P)}catch(e){console.error("There was an error fetching the model data",e)}};s&&t&&i&&o&&e();let l=async()=>{let e=await (0,m.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),k(e)};null==b&&l(),lg()},[s,t,i,o,b,I]),!d||!s||!t||!i||!o)return(0,n.jsx)("div",{children:"Loading..."});let lZ=[],ly=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(b)),null!=b&&"object"==typeof b&&e in b)?b[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(n=t)||(n=1===e.length?u(s):l)}else n="-";a&&(r=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,o=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}))),d.data[e].provider=n,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,ly.push(n),d.data[e].input_cost&&(d.data[e].input_cost=(1e6*Number(d.data[e].input_cost)).toFixed(2)),d.data[e].output_cost&&(d.data[e].output_cost=(1e6*Number(d.data[e].output_cost)).toFixed(2)),d.data[e].max_tokens=o,d.data[e].max_input_tokens=c,d.data[e].api_base=null==l?void 0:null===(lv=l.litellm_params)||void 0===lv?void 0:lv.api_base,d.data[e].cleanedLitellmParams=m,lZ.push(l.model_name),console.log(d.data[e])}if(d.data&&d.data.length>0&&d.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),i&&"Admin Viewer"==i){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lw=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(a).find(l=>a[l]===e);if(l){let e=eP[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,a]=l;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===e||a.litellm_provider.includes(e))&&s.push(t)}),"Cohere"==l&&(console.log("adding cohere chat model"),Object.entries(b).forEach(e=>{let[l,t]=e;null!==t&&"object"==typeof t&&"litellm_provider"in t&&"cohere"===t.litellm_provider&&s.push(l)}))),E(s),console.log("providerModels: ".concat(P))}},lS=async()=>{try{w.ZP.info("Running health check..."),ee("");let e=await (0,m.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lk=(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Select API Key Name"}),j?(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsxs)(G.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsxs)(G.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let r=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,n.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[r&&(0,n.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,n.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,n.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})},lI=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";console.log("selectedProvider: ".concat(X)),console.log("providerModels.length: ".concat(P.length));let lC=Object.keys(a).find(e=>a[e]===X);return lC&&(l=M.find(e=>e.name===eP[lC])),(0,n.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(ei.Z,{children:"All Models"}),(0,n.jsx)(ei.Z,{children:"Add Model"}),(0,n.jsx)(ei.Z,{children:(0,n.jsx)("pre",{children:"/health Models"})}),(0,n.jsx)(ei.Z,{children:"Model Analytics"}),(0,n.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[I&&(0,n.jsxs)(Z.Z,{children:["Last Refreshed: ",I]}),(0,n.jsx)(U.Z,{icon:D.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsxs)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||void 0,onValueChange:e=>eU("all"===e?"all":e),value:eL||void 0,children:[(0,n.jsx)(G.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created At":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created By":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,n.jsxs)(W.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.litellm_model_name,children:(0,n.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"===i&&(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.api_base,children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&e.model_info.created_by||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,n.jsx)(F.Z,{size:"xs",className:"text-white",children:(0,n.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,n.jsx)(F.Z,{size:"xs",className:"text-black",children:(0,n.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsxs)(h.Z,{numItems:3,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>lx(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(e_,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,n.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[r]=v.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,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,n.jsx)(S.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"max_retries",name:"max_retries",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"Input Cost per 1M Tokens",name:"input_cost_per_million_tokens",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"Output Cost per 1M Tokens",name:"output_cost_per_million_tokens",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),eT(null)},model:eS,onSubmit:lj}),(0,n.jsxs)(S.Z,{title:eS&&eS.model_name,visible:ea,width:800,footer:null,onCancel:()=>{ew(!1),eT(null)},children:[(0,n.jsx)(y.Z,{children:"Model Info"}),(0,n.jsx)(eI.Z,{language:"json",children:eS&&JSON.stringify(eS,null,2)})]})]}),(0,n.jsxs)(ec.Z,{className:"h-full",children:[(0,n.jsx)(eC,{level:2,children:"Add new model"}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(v.Z,{form:_,onFinish:()=>{_.validateFields().then(e=>{eO(e,s,_)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(H.Z,{value:X.toString(),children:O.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lw(e),$(e)},children:e},l))})}),(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],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.",className:"mb-0",children:(0,n.jsx)(p.Z,{})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,n.jsxs)(v.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,n.jsx)(v.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,n.jsx)(p.Z,{placeholder:lI(X.toString())}):P.length>0?(0,n.jsxs)(eu.Z,{children:[(0,n.jsx)(eh.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,n.jsx)(eh.Z,{value:e,children:e},l))]}):(0,n.jsx)(p.Z,{placeholder:lI(X.toString())})}),(0,n.jsx)(v.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,n.jsx)(v.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,n.jsx)(p.Z,{placeholder:"Enter custom model name"})})}})]}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==l&&l.fields.length>0&&(0,n.jsx)(eN,{fields:l.fields,selectedProvider:l.name}),"Amazon Bedrock"!=X&&"Vertex AI (Anthropic, Gemini, etc.)"!=X&&"Ollama"!=X&&(void 0===l||0==l.fields.length)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,n.jsx)(p.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization",children:(0,n.jsx)(p.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,n.jsx)(p.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,n.jsx)(p.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,n.jsx)(ev.Z,{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;_.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?w.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&w.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,n.jsx)(C.ZP,{icon:(0,n.jsx)(eb.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==X||"OpenAI-Compatible Endpoints (Together AI, etc.)"==X)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,n.jsx)(p.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,n.jsxs)("div",{children:[(0,n.jsx)(v.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,n.jsx)(p.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,n.jsx)(eA,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"us-east-1"})}),(0,n.jsx)(v.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,n.jsx)(v.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]}),(0,n.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,n.jsx)(ej.Z,{title:"Get help on our github",children:(0,n.jsx)(et.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,n.jsx)(x.Z,{onClick:lS,children:"Run `/health`"}),Q&&(0,n.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,n.jsxs)(eg.Z,{className:"ml-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model Group"}),(0,n.jsx)(H.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(eZ.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,n.jsx)(x.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,n.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,n.jsx)(Z.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eK&&(0,n.jsx)(ex.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(ek,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:j})})]})]})})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Deployment"}),(0,n.jsx)(K.Z,{children:"Success Responses"}),(0,n.jsxs)(K.Z,{children:["Slow Responses ",(0,n.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,n.jsx)(V.Z,{children:e4.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.api_base}),(0,n.jsx)(B.Z,{children:e.total_count}),(0,n.jsx)(B.Z,{children:e.slow_count})]},l))})]})})})]}),(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,n.jsx)(ep.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,n.jsxs)(h.Z,{numItems:1,children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,n.jsx)(eg.Z,{})]})]}),j?(0,n.jsx)(n.Fragment,{children:lt.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,n.jsx)(n.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsx)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||eR[0],value:eL||eR[0],onValueChange:e=>eU(e),children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,n.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,n.jsx)(Z.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eE&&(0,n.jsx)("table",{children:(0,n.jsx)("tbody",{children:Object.entries(eE).map((e,l)=>{var s;let[t,a]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[a];return null==r&&(r=e9),(0,n.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,n.jsx)("td",{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)("td",{children:(0,n.jsx)(N.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(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,n.jsx)(x.Z,{className:"mt-6 mr-8",onClick:lf,children:"Save"})]})]})]})})};function eR(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:r,Paragraph:i}=et.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,n.jsxs)(S.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,n.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"User ID"}),(0,n.jsx)(Z.Z,{children:null==a?void 0:a.user_id})]}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{children:"Invitation Link"}),(0,n.jsx)(Z.Z,{children:(0,n.jsx)(Z.Z,{children:o()})})]}),(0,n.jsx)("div",{className:"flex justify-end mt-5",children:(0,n.jsx)(_.CopyToClipboard,{text:o(),onCopy:()=>w.ZP.success("Copied!"),children:(0,n.jsx)(x.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:eD}=b.default;var eM=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,r.useState)(null),[c]=v.Z.useForm(),[u,h]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]),[_,k]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)(),[E,O]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,m.So)(s,l,"any"),t=[];for(let l=0;l{P&&O(new URL("/",window.location.href).toString())},[P]);let T=async e=>{try{var t;w.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let a=await (0,m.Ov)(s,null,e);console.log("user create Response:",a),g(a.key);let n=(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:n,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};A(e),k(!0)}else(0,m.XO)(s,n).then(e=>{e.has_user_setup_sso=!1,A(e),k(!0)});w.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,n.jsxs)(S.Z,{title:"Invite User",visible:u,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,n.jsxs)(v.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(v.Z.Item,{label:"User Email",name:"user_email",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",children:(0,n.jsx)(b.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,n.jsx)(eD,{value:e.team_id,children:e.team_alias},e.team_id)):(0,n.jsx)(eD,{value:null,children:"Default Team"},"default")})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),j&&(0,n.jsx)(eR,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:k,baseUrl:E,invitationLinkData:N})]})},eF=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,r.useState)(a),[c]=v.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,n.jsx)(S.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,n.jsx)(v.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eL=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,u]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)(1),[_,b]=r.useState(null),[v,S]=(0,r.useState)(null),[k,N]=(0,r.useState)(!1),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(!1),[E,O]=(0,r.useState)(null),[T,D]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let H=e=>{O(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,m.Eb)(l,[E]),w.ZP.success("User deleted successfully"),p){let e=p.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),w.ZP.error("Failed to delete user")}P(!1),O(null)},J=async()=>{C(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,m.pf)(l,e,null),w.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}p&&j(p.map(l=>l.user_id===e.user_id?e:l)),C(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);u(l),j(l.users||[])}else{let e=await (0,m.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),u(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,m.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,Z]),p&&l&&s&&a&&i)?(0,n.jsx)("div",{style:{width:"100%"},children:(0,n.jsxs)(h.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,n.jsx)(eM,{userID:i,accessToken:l,teams:o,possibleUIRoles:T}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,n.jsx)("div",{className:"mb-4 mt-1"}),(0,n.jsx)(eo.Z,{children:(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(z.Z,{className:"mt-5",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"User ID"}),(0,n.jsx)(K.Z,{children:"User Email"}),(0,n.jsx)(K.Z,{children:"Role"}),(0,n.jsx)(K.Z,{children:"User Spend ($ USD)"}),(0,n.jsx)(K.Z,{children:"User Max Budget ($ USD)"}),(0,n.jsx)(K.Z,{children:"API Keys"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:p.map(e=>{var l,s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id||"-"}),(0,n.jsx)(B.Z,{children:e.user_email||"-"}),(0,n.jsx)(B.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,n.jsx)(B.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,n.jsx)(B.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(h.Z,{numItems:2,children:e.key_count>0?(0,n.jsxs)(F.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,n.jsx)(F.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,onClick:()=>{C(e),N(!0)},children:"View Keys"}),(0,n.jsx)(U.Z,{icon:M.Z,onClick:()=>H(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,n.jsx)(eF,{visible:k,possibleUIRoles:T,onCancel:J,user:I,onSubmit:Y}),A&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,n.jsxs)("div",{className:"mt-2",children:[(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,n.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!p)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),y(e)};return(0,n.jsxs)("div",{className:"flex justify-between items-center",children:[(0,n.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,n.jsx)("div",{children:"Loading..."})},eU=e=>{var l,s;let{visible:t,onCancel:a,onSubmit:r,initialData:i,mode:o}=e,[d]=v.Z.useForm(),c=async e=>{try{let l={email:e.user_email,id:e.user_id,role:e.role};r(l),d.resetFields(),w.ZP.success("Successfully ".concat("add"===o?"added":"updated"," team member"))}catch(e){w.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}};return(0,n.jsx)(S.Z,{title:"add"===o?"Add Team Member":"Edit Team Member",visible:t,width:800,footer:null,onCancel:a,children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{user_email:(null==i?void 0:null===(l=i.email)||void 0===l?void 0:l.trim())||"",user_id:(null==i?void 0:null===(s=i.id)||void 0===s?void 0:s.trim())||"",role:(null==i?void 0:i.role)||"user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)("div",{className:"text-center mb-4",children:(0,n.jsx)(Z.Z,{children:"OR"})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})}),(0,n.jsxs)("div",{style:{textAlign:"right",marginTop:"20px"},children:[(0,n.jsx)(C.ZP,{onClick:a,style:{marginRight:8},children:"Cancel"}),(0,n.jsx)(C.ZP,{type:"primary",htmlType:"submit",children:"add"===o?"Add Member":"Save Changes"})]})]})})};console.log=function(){};var ez=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o}=e;(0,r.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&(async()=>{let e;e="Admin"!=o&&"Admin Viewer"!=o?await (0,m.It)(t,i):await (0,m.It)(t),console.log("givenTeams: ".concat(e)),a(e)})()},[l]);let[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:y,Paragraph:_}=et.default,[k,A]=(0,r.useState)(""),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(l?l[0]:null),[D,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)([]),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(null),[ed,ec]=(0,r.useState)({}),em=e=>{T(e),E(!0)},eu=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let n=await (0,m.Gh)(t,e);l&&a(l.map(e=>e.team_id===s?n.data:e)),w.ZP.success("Team updated successfully"),E(!1),T(null)},eh=()=>{X(!1),Q(!1),c.resetFields()},ex=async e=>{er(e),ea(!0)},ep=async()=>{if(null!=en&&null!=l&&null!=t){try{await (0,m.rs)(t,en);let e=l.filter(e=>e.team_id!==en);a(e)}catch(e){console.error("Error deleting the team:",e)}ea(!1),er(null)}};(0,r.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,m.It)(t,i):await (0,m.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,m.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eg=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let n=null==e?void 0:e.team_alias,r=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=null==e?void 0:e.organization_id;if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),r.includes(n))throw Error("Team alias ".concat(n," already exists, please pick another alias"));w.ZP.info("Creating Team");let o=await (0,m.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),w.ZP.success("Team created"),J(!1)}}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the team: "+e,20)}},ef=async(e,s)=>{try{if(null!=t&&null!=l){let n;w.ZP.info("Adding Member");let r={role:e.role,user_email:e.user_email,user_id:e.user_id};"add"==s?(n=await (0,m.cu)(t,O.team_id,r),w.ZP.success("Member added")):(n=await (0,m.sN)(t,O.team_id,{role:e.role,user_id:e.id,user_email:e.email}),w.ZP.success("Member updated"));let i=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(n.data.team_id)),e.team_id===n.data.team_id));if(console.log("foundIndex: ".concat(i)),-1!==i){let e=[...l];e[i]=n.data,a(e),T(n.data)}X(!1)}}catch(e){console.error("Error creating the team:",e)}},eZ=async e=>{ef(e,"add")},ey=async e=>{ef(e,"edit")};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"All Teams"}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Team Name"}),(0,n.jsx)(K.Z,{children:"Team ID"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"TPM / RPM Limits"}),(0,n.jsx)(K.Z,{children:"Info"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,n.jsx)(ej.Z,{title:e.team_id,children:e.team_id})}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,n.jsx)(B.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,n.jsx)(B.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].keys&&ed[e.team_id].keys.length," ","Keys"]}),(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].members_with_roles&&ed[e.team_id].members_with_roles.length," ","Members"]})]}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>em(e)}),(0,n.jsx)(U.Z,{onClick:()=>ex(e.team_id),icon:M.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),es&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:ep,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{ea(!1),er(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>J(!0),children:"+ Create New Team"}),(0,n.jsx)(S.Z,{title:"Create Team",visible:D,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:eg,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Additional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,n.jsx)(p.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"Team Members"}),(0,n.jsx)(_,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{T(e)},children:e.team_alias},l))}):(0,n.jsxs)(_,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:O?O.members_with_roles.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsx)(B.Z,{children:e.role}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{Q(!0),eo({id:e.user_id,email:e.user_email,role:e.role})}}),(0,n.jsx)(U.Z,{onClick:()=>{},icon:M.Z,size:"sm"})]}):null})]},l)):null})]})}),(0,n.jsx)(eU,{visible:$,onCancel:eh,onSubmit:ey,initialData:ei,mode:"edit"}),O&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:a}=e,[r]=v.Z.useForm();return(0,n.jsx)(S.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:eu,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee&&ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:P,onCancel:()=>{E(!1),T(null)},team:O,onSubmit:eu})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"==o||O&&(e=>{for(let l=0;lX(!0),children:"+ Add member"}):null,(0,n.jsx)(S.Z,{title:"Add member",visible:Y,width:800,footer:null,onOk:()=>{X(!1),Q(!1),c.resetFields()},onCancel:eh,children:(0,n.jsxs)(v.Z,{form:d,onFinish:eZ,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})};let eV=async(e,l,s)=>{if(null!=l)try{w.ZP.info("Creating Organization"),console.log("formValues: "+JSON.stringify(e));let t=await (0,m.H1)(l,e);console.log("response for organization create call: ".concat(t)),w.ZP.success("Organization created"),sessionStorage.removeItem("organizations"),s(!1)}catch(e){console.error("Error creating the organization:",e),w.ZP.error("Error creating the organization: "+e,20)}};var eB=e=>{let{title:l="Create Organization",onCancel:s,accessToken:t,availableModels:a=[],initialValues:i={},submitButtonText:o="Create",modelSelectionType:d="multiple"}=e,[c]=v.Z.useForm(),[m,u]=(0,r.useState)(!1),[h,j]=(0,r.useState)({name:i.name||"",models:i.models||[],maxBudget:i.maxBudget||null,budgetDuration:i.budgetDuration||null,tpmLimit:i.tpmLimit||null,rpmLimit:i.rpmLimit||null});console.log("availableModels: ".concat(a));let g=async e=>{null!=t&&(await eV(e,t,u),u(!1))};return(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)(x.Z,{onClick:()=>u(!0),className:"mx-auto",type:"button",children:["+ Create New ",l]}),(0,n.jsx)(S.Z,{title:"Create ".concat(l),visible:m,width:800,footer:null,onCancel:()=>{u(!1),s&&s()},children:(0,n.jsxs)(v.Z,{form:c,onFinish:g,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"".concat(l," Name"),name:"organization_alias",rules:[{required:!0,message:"Please input a ".concat(l," name")}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),a.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:o})})]})})]})};let eq=(e,l)=>{for(let s=0;s{let{userRole:l,userID:s,selectedOrganization:t,onMemberAdd:a}=e,[i,o]=r.useState(!1),[d]=v.Z.useForm();return(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"===l||t&&eq(t,s)?(0,n.jsx)(x.Z,{className:"mx-auto mb-5",onClick:()=>o(!0),children:"+ Add member"}):null,(0,n.jsxs)(S.Z,{title:"Add member",visible:i,width:800,footer:null,onOk:()=>{d.submit()},onCancel:()=>{d.resetFields(),o(!1)},children:[(0,n.jsx)(Z.Z,{className:"mb-2",children:"User must exist in proxy. Get User ID from 'Users' tab."}),(0,n.jsxs)(v.Z,{form:d,onFinish:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"internal_user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"org_admin",children:(0,n.jsxs)("div",{className:"flex",children:["Org Admin"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can add and remove members, and change their roles."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can view/create keys for themselves within organization."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user_viewer",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User Viewer"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can only view their keys within organization."})]})})]})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})]})]})},eW=e=>{var l;let{selectedEntity:s,onEditSubmit:t,editModalComponent:a,entityType:i}=e,[o,d]=r.useState(!1);return(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"team"===i?"Team Member":"Organization Member"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:(null!==(l=null==s?void 0:s.members)&&void 0!==l?l:[]).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id}),(0,n.jsx)(B.Z,{children:e.user_role})]},"".concat(e.user_id,"-").concat(l)))})]})}),s&&(0,n.jsx)(a,{visible:o,onCancel:()=>{d(!1)},entity:s,onSubmit:e=>{t(e),d(!1)}})]})},eH=e=>{let{data:l,columns:s,actions:t,emptyMessage:a="No data available",deleteModal:r}=e,i=(e,l)=>{let s=l[e.accessor];return e.cellRenderer?e.cellRenderer(s,l):Array.isArray(s)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===s.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"None"})}):s.map((e,l)=>(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:String(e).length>30?"".concat(String(e).slice(0,30),"..."):e})},l))}):(null==s?void 0:s.toString())||""};return(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[40vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[s.map((e,l)=>(0,n.jsx)(K.Z,{children:e.header},l)),t&&t.length>0&&(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map((e,l)=>(0,n.jsxs)(W.Z,{children:[s.map((l,s)=>(0,n.jsx)(B.Z,{style:{maxWidth:l.width||"4px",whiteSpace:"pre-wrap",overflow:"hidden",...l.style},children:"id"===l.accessor?(0,n.jsx)(ej.Z,{title:e[l.accessor],children:i(l,e)}):i(l,e)},s)),t&&t.length>0&&(0,n.jsx)(B.Z,{children:t.map((l,s)=>{var t;return(null===(t=l.condition)||void 0===t?void 0:t.call(l,e))!==!1&&(0,n.jsx)(ej.Z,{title:l.tooltip,children:(0,n.jsx)(U.Z,{icon:l.icon,size:"sm",onClick:()=>l.onClick(e),className:"cursor-pointer mx-1"})},s)})})]},l)):(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:s.length+(t?1:0),children:(0,n.jsx)(Z.Z,{className:"text-center",children:a})})})})]})})};console.log=function(){};let eG=e=>{let{visible:l,onCancel:s,entity:t,onSubmit:a}=e;return(0,n.jsx)("div",{})},eJ=e=>{let{organizations:l,userRole:s,onEdit:t,onDelete:a,isDeleteModalOpen:r,setIsDeleteModalOpen:i,selectedOrganization:o,setSelectedOrganization:d}=e,c=[...t&&"Admin"===s?[{icon:void 0,onClick:e=>t(e),condition:()=>"Admin"===s,tooltip:"Edit organization"}]:[],...a&&"Admin"===s?[{icon:void 0,onClick:e=>a(e),condition:()=>"Admin"===s,tooltip:"Delete organization"}]:[]];return(0,n.jsx)(eH,{data:l,columns:[{header:"Organization Name",accessor:"organization_alias",width:"4px",style:{whiteSpace:"pre-wrap",overflow:"hidden"}},{header:"Organization ID",accessor:"organization_id",width:"4px",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"}},{header:"Spend (USD)",accessor:"spend"},{header:"Budget (USD)",accessor:"max_budget",cellRenderer:e=>null!=e?e:"No limit"},{header:"Models",accessor:"models"},{header:"TPM / RPM Limits",accessor:"limits",cellRenderer:(e,l)=>(0,n.jsxs)("div",{className:"text-sm",children:[(0,n.jsxs)("span",{children:["TPM: ",l.tpm_limit?l.tpm_limit:"Unlimited"]}),(0,n.jsx)("br",{}),(0,n.jsxs)("span",{children:["RPM: ",l.rpm_limit?l.rpm_limit:"Unlimited"]})]})},{header:"Info",accessor:"info",cellRenderer:(e,l)=>{var s;return(0,n.jsx)("div",{className:"space-y-1",children:(0,n.jsxs)("div",{className:"text-sm",children:[(null===(s=l.members)||void 0===s?void 0:s.length)||0," Members"]})})}}],actions:c,emptyMessage:"No organizations available",deleteModal:{isOpen:r,onConfirm:()=>{o&&a&&a(o),i(!1),d(null)},onCancel:()=>{i(!1),d(null)},title:"Delete Organization",message:"Are you sure you want to delete this organization?"}})};var eY=e=>{let{accessToken:l,userID:s,userRole:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),{Title:d,Paragraph:c}=et.default,[x,p]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!l||!s||!t)return;let e=async()=>{try{let e=(await (0,m.So)(l,s,t)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}catch(e){console.error("Error fetching user models:",e)}},n=async()=>{let e;e=await (0,m.r6)(l),console.log("givenOrganizations: ".concat(e)),o(e),sessionStorage.setItem("organizations",JSON.stringify(e))};a&&(e(),n())},[l]);let _=async e=>{if(j&&l)try{let s={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,m.vh)(l,j.organization_id,s),w.ZP.success("Member added")}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the organization: "+e)}};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"✨ All Organizations"}),(0,n.jsxs)(Z.Z,{className:"mb-2",children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,n.jsx)("a",{href:"https://www.litellm.ai/#trial",className:"text-blue-600 hover:text-blue-800 underline",target:"_blank",rel:"noopener noreferrer",children:"here"})]}),t?eJ({organizations:i,userRole:t,isDeleteModalOpen:x,setIsDeleteModalOpen:p,selectedOrganization:j,setSelectedOrganization:g}):null]}),"Admin"==t&&l&&a?(0,n.jsx)(eB,{title:"Organization",accessToken:l,availableModels:f,submitButtonText:"Create Organization"}):null,a?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"Organization Members"}),(0,n.jsx)(c,{children:"If you belong to multiple organizations, this setting controls which organizations' members you see."}),i&&i.length>0?(0,n.jsx)(H.Z,{children:i.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{g(e)},children:e.organization_alias},l))}):(0,n.jsxs)(c,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eK,{userRole:t,userID:s,selectedOrganization:j,onMemberAdd:_}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eW,{selectedEntity:j,onEditSubmit:()=>{},editModalComponent:eG,entityType:"organization"}):null]})})},eX=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:a,premiumUser:o}=e,[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:p,Paragraph:j}=et.default,[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)(null),[b,k]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(!1),[D,M]=(0,r.useState)(!1),[F,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)([]),[ei,eo]=(0,r.useState)(null),ed=(0,i.useRouter)(),[ec,em]=(0,r.useState)(null);console.log=function(){};let[eu,eh]=(0,r.useState)(""),ex="All IP Addresses Allowed";try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let ep=async()=>{try{if(!0!==o){w.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,m.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),w.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,m.eH)(t,e.ip);let l=await (0,m.PT)(t);er(l),w.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),w.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),ea(!0)},ef=async()=>{if(ei&&t)try{await (0,m.$I)(t,ei);let e=await (0,m.PT)(t);er(e.length>0?e:[ex]),w.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),w.ZP.error("Failed to delete IP address ".concat(e))}finally{ea(!1),eo(null)}},eZ=()=>{X(!1)},ey=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(ed){let{protocol:e,host:l}=window.location;eh("".concat(e,"//").concat(l))}},[ed]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,m.Xd)(t,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let s=l.users;console.log("proxy viewers response: ".concat(s)),s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(s));let a=(await (0,m.Xd)(t,"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)),_(e),em(await (0,m.lg)(t))}})()},[t]);let e_=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,n.jsx)(H.Z,{value:l,children:ey.map((e,l)=>(0,n.jsx)(G.Z,{value:e,children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,n.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ek=async e=>{try{if(null!=t&&null!=y){w.ZP.info("Making API Call");let l=await (0,m.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),y.push(l),_(y)),w.ZP.success("Refresh tab to see updated user role"),M(!1)}}catch(e){console.error("Error creating the key:",e)}},eN=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call");let s=await (0,m.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)});let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,m.pf)(t,e,"proxy_admin"),a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)}),console.log("response for team create call: ".concat(s));let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),T(!1)}}catch(e){console.error("Error creating the key:",e)}},eC=async e=>{if(null==t)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,m.K_)(t,l)};return console.log("admins: ".concat(null==y?void 0:y.length)),(0,n.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,n.jsx)(p,{level:4,children:"Admin Access "}),(0,n.jsxs)(j,{children:[a&&(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:y?y.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsxs)(B.Z,{children:[" ",(null==ec?void 0:null===(s=ec[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>M(!0)}),(0,n.jsx)(S.Z,{title:"Update role",visible:D,width:800,footer:null,onOk:e_,onCancel:eb,children:eS(ek,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("div",{className:"flex justify-start",children:[(0,n.jsx)(x.Z,{className:"mr-4 mb-5",onClick:()=>T(!0),children:"+ Add admin"}),(0,n.jsx)(S.Z,{title:"Add admin",visible:O,width:800,footer:null,onOk:()=>{T(!1),c.resetFields(),d.resetFields()},onCancel:()=>{T(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,n.jsx)(eR,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,n.jsx)(x.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,n.jsx)(S.Z,{title:"Add viewer",visible:P,width:800,footer:null,onOk:()=>{E(!1),c.resetFields(),d.resetFields()},onCancel:()=>{E(!1),c.resetFields(),d.resetFields()},children:ev(eN)})]})})]}),(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(p,{level:4,children:" ✨ Security Settings"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:()=>!0===o?J(!0):w.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,n.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,n.jsx)(S.Z,{title:"Add SSO",visible:F,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:e=>{eI(e),eC(e),J(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,n.jsx)(I.Z.Password,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,n.jsx)(I.Z.Password,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,n.jsxs)(S.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:eZ,onCancel:()=>{X(!1)},children:[(0,n.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{onClick:eZ,children:"Done"})})]}),(0,n.jsx)(S.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,n.jsx)(x.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"IP Address"}),(0,n.jsx)(K.Z,{className:"text-right",children:"Action"})]})}),(0,n.jsx)(V.Z,{children:en.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e}),(0,n.jsx)(B.Z,{className:"text-right",children:e!==ex&&(0,n.jsx)(x.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,n.jsx)(S.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,n.jsxs)(v.Z,{onFinish:ej,children:[(0,n.jsx)(v.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,n.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,n.jsx)(v.Z.Item,{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,n.jsx)(S.Z,{title:"Confirm Delete",visible:es,onCancel:()=>ea(!1),onOk:ef,footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>ef(),children:"Yes"},"delete"),(0,n.jsx)(x.Z,{onClick:()=>ea(!1),children:"Close"},"close")],children:(0,n.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,n.jsxs)(ew.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,n.jsxs)("a",{href:l,target:"_blank",children:[(0,n.jsx)("b",{children:l})," "]})]})]})]})},e$=s(92858),eQ=s(44643),e0=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:r}=e,[i]=v.Z.useForm();return(0,n.jsxs)(v.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{align:"center",children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,n.jsx)(v.Z.Item,{name:e.field_name,children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,n.jsx)(v.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,n.jsx)("div",{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},e1=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,m.RQ)(l).then(e=>{a(e)})},[l]),(0,n.jsx)(e0,{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:n,...r}=a;console.log("slack_alerting: ".concat(n,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,m.jA)(l,"alerting_args",r),"boolean"==typeof n&&(!0==n?(0,m.jA)(l,"alerting",["slack"]):(0,m.jA)(l,"alerting",[])),w.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},e2=s(86582);let{Title:e4,Paragraph:e5}=et.default;console.log=function(){};var e8=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[u,j]=(0,r.useState)(!1),[g]=v.Z.useForm(),[f,y]=(0,r.useState)(null),[_,k]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,O]=(0,r.useState)([]),[T,D]=(0,r.useState)(!1),[M,F]=(0,r.useState)([]),[H,J]=(0,r.useState)(null),[Y,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),es=e=>{E.includes(e)?O(E.filter(l=>l!==e)):O([...E,e])},et={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,r.useEffect)(()=>{l&&s&&t&&(0,m.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),F(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),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ea=e=>E&&E.includes(e),en=()=>{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,m.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Email settings updated successfully")},er=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,m.K_)(l,{environment_variables:s}),w.ZP.success("Callback added successfully"),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eu=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,m.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),w.ZP.success("Callback ".concat(s," added successfully")),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),y(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",Y)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,n.jsxs)("div",{className:"w-full mx-4",children:[(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,n.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,n.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,n.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Active Logging Callbacks"}),(0,n.jsx)(h.Z,{numItems:2,children:(0,n.jsx)(L.Z,{className:"max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(K.Z,{children:"Callback Name"})})}),(0,n.jsx)(V.Z,{children:i.map((e,s)=>(0,n.jsxs)(W.Z,{className:"flex justify-between",children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.name})}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"flex justify-between",children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(Z.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,n.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{children:"Slack Webhook URL"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:"region_outage_alerts"==s?a?(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)}):(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,n.jsx)(x.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let n=(null==a?void 0:a.value)||"";console.log("newWebhookValue",n),e[s]=n}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,m.K_)(l,s)}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(e1,{accessToken:l,premiumUser:a})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Email Settings"}),(0,n.jsxs)(Z.Z,{children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,n.jsx)("br",{})]}),(0,n.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,n.jsx)(B.Z,{children:(0,n.jsx)("ul",{children:(0,n.jsx)(h.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,n.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,n.jsxs)("div",{children:[(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,n.jsxs)(Z.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-2",children:l}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,n.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,n.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,n.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,n.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,n.jsx)(x.Z,{className:"mt-2",onClick:()=>en(),children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,n.jsxs)(S.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>D(!1),footer:null,children:[(0,n.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,n.jsx)(v.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e2.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,n.jsx)(b.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,n.jsx)(G.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,n.jsx)(e2.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,n.jsx)(p.Z,{type:"password"})},e)),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,n.jsx)(S.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,n.jsxs)(v.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,n.jsx)(e2.Z,{label:l,name:l,children:(0,n.jsx)(p.Z,{type:"password",defaultValue:s})},l)})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:e3}=b.default;var e6=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=v.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,n.jsx)(S.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,n.jsxs)(v.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:n}=e,r=[...t.fallbacks||[],{[l]:n}],o={...t,fallbacks:r};console.log(o);try{(0,m.K_)(s,{router_settings:o}),a(o)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,n.jsx)(H.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>u(e),children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsx)(eu.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},e7=s(33619);async function e9(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new e7.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});w.ZP.success((0,n.jsxs)("span",{children:["Test model=",(0,n.jsx)("strong",{children:e}),", received model=",(0,n.jsx)("strong",{children:l.model}),". See"," ",(0,n.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let le={ttl:3600,lowest_latency_buffer:0},ll=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,n.jsx)(g.Z,{children:"latency-based-routing"==l?(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,n.jsx)(Z.Z,{children:"No specific settings"})})]})};var ls=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)(!1),[b]=v.Z.useForm(),[S,k]=(0,r.useState)(null),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,m.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,m.YU)(l).then(e=>{g(e)}))},[l,s,t]);let O=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,m.K_)(l,{router_settings:i}),o({...i}),C(i.routing_strategy),w.ZP.success("Router settings updated successfully")}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}}},T=(e,l)=>{g(j.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=j[s].field_value;if(null!=t&&void 0!=t)try{(0,m.jA)(l,e,t);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,m.ao)(l,e);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},J=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,I];if("routing_strategy_args"==l&&"latency-based-routing"==I){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,m.K_)(l,{router_settings:s})}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully")};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,n.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,n.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,n.jsx)(y.Z,{children:"Router Settings"}),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,n.jsx)(B.Z,{children:"routing_strategy"==l?(0,n.jsxs)(H.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:C,children:[(0,n.jsx)(G.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,n.jsx)(G.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,n.jsx)(G.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,n.jsx)(ll,{selectedStrategy:I,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:le,paramExplanation:E})]}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>J(i),children:"Save Changes"})})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model Name"}),(0,n.jsx)(K.Z,{children:"Fallbacks"})]})}),(0,n.jsx)(V.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:t}),(0,n.jsx)(B.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>e9(t,l),children:"Test Fallback"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,n.jsx)(e6,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"}),(0,n.jsx)(K.Z,{children:"Status"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:j.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,n.jsx)(B.Z,{children:"Integer"==e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(x.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lt=s(93142),la=s(45246),ln=s(96473),lr=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,r.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,n)=>{let r=[...t];r[e]=[l,n],a(r),null==s||s(Object.fromEntries(r))};return(0,n.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(lt.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,n.jsx)(p.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,n.jsx)(p.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,n.jsx)(la.Z,{onClick:()=>i(l)})]},l)}),(0,n.jsx)(C.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,n.jsx)(ln.Z,{}),children:"Add Header"})]})};let{Option:li}=b.default;var lo=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=v.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,n.jsx)(S.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,n.jsxs)(v.Z,{form:a,onFinish:e=>{console.log(e);let n=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,m.Vt)(l,e),s(n)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(lr,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},ld=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,m.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,m.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),w.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Path"}),(0,n.jsx)(K.Z,{children:"Target"}),(0,n.jsx)(K.Z,{children:"Headers"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:i.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.path})}),(0,n.jsx)(B.Z,{children:e.target}),(0,n.jsx)(B.Z,{children:JSON.stringify(e.headers)}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,n.jsx)(lo,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lc=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[r]=v.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call");let l=await (0,m.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),w.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,n.jsxs)(v.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lm=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=v.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call"),t(!0);let l=await (0,m.qI)(s,e);a(e=>e?[...e,l]:[l]),w.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},lu=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[a,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,u]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,m.O3)(l).then(e=>{u(e)})},[l]);let h=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),i(!0))},p=async(e,s)=>{if(null==l)return;w.ZP.info("Request made"),await (0,m.NV)(l,e);let t=[...c];t.splice(s,1),u(t),w.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,m.O3)(l).then(e=>{u(e)})};return(0,n.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,n.jsx)(x.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,n.jsx)(lc,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:u}),o&&(0,n.jsx)(lm,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:u,existingBudget:o,handleUpdateCall:j}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"Create a budget to assign to customers."}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Budget ID"}),(0,n.jsx)(K.Z,{children:"Max Budget"}),(0,n.jsx)(K.Z,{children:"TPM"}),(0,n.jsx)(K.Z,{children:"RPM"})]})}),(0,n.jsx)(V.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.budget_id}),(0,n.jsx)(B.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,n.jsx)(B.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,n.jsx)(B.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>p(e.budget_id,l)})]},l))})]})]}),(0,n.jsxs)("div",{className:"mt-5",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"How to use budget id"}),(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,n.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,n.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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)'})})]})]})]})]})},lh=s(77398),lx=s.n(lh),lp=s(24525),lj=s(71594);let lg=e=>e?"string"==typeof e?e:"object"==typeof e?e.text?e.text:e.content?e.content:JSON.stringify(e):String(e):"N/A",lf=e=>{let{data:l}=e,s=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,n.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Request"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.request),null,2)})]}),(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.response),null,2)})]}),l.metadata&&Object.keys(l.metadata).length>0&&(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"}),(0,n.jsx)("div",{children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(l.metadata,null,2)})]})]})};var lZ=e=>{let{accessToken:l,token:s,userRole:t,userID:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)(!0),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(null);(0,lp.Cl)();let j=[{header:"Time",accessorKey:"startTime",cell:e=>(0,n.jsx)("span",{children:lx()(e.getValue()).format("MMM DD HH:mm:ss")})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,n.jsx)("span",{className:"font-mono text-xs",children:String(e.getValue()||"")})},{header:"Type",accessorKey:"call_type",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Request",accessorKey:"messages",cell:e=>{let l=e.getValue();try{let e="string"==typeof l?JSON.parse(l):l,t="";if(Array.isArray(e)){var s;t=lg(null===(s=e[0])||void 0===s?void 0:s.content)}else t=lg(e);return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:t})}catch(e){return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:lg(l)})}}},{header:"Model",accessorKey:"model",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,n.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,n.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"User",accessorKey:"user",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Cost",accessorKey:"spend",cell:e=>(0,n.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();return l&&0!==Object.keys(l).length?(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(l).map(e=>{let[l,s]=e;return(0,n.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[l,": ",String(s)]},l)})}):"-"}}];return((0,lj.b7)({data:i,columns:j,state:{sorting:u},onSortingChange:h,getCoreRowModel:(0,lp.sC)(),getSortedRowModel:(0,lp.tj)()}),(0,r.useEffect)(()=>{(async()=>{if(!l||!s||!t||!a){console.log("got None values for one of accessToken, token, userRole, userID");return}try{c(!0);let e=lx()().format("YYYY-MM-DD HH:mm:ss"),n=lx()().subtract(24,"hours").format("YYYY-MM-DD HH:mm:ss"),r=await (0,m.h3)(l,s,t,a,n,e);console.log("response from uiSpendLogsCall:",r);let i=r.map((e,l)=>({...e,key:l.toString()}));o(i)}catch(e){console.error("Error fetching logs:",e)}finally{c(!1)}})()},[l,s,t,a]),l&&s&&t&&a)?(0,n.jsx)("div",{className:"w-[90%] mx-auto px-4",children:(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow w-full",children:[(0,n.jsxs)("div",{className:"p-4 border-b flex justify-between items-center",children:[(0,n.jsxs)("div",{className:"flex space-x-4 items-center",children:[(0,n.jsx)("input",{type:"text",placeholder:"Search by request ID, model, or user...",className:"px-4 py-2 border rounded-lg w-80"}),(0,n.jsxs)("button",{className:"px-4 py-2 border rounded-lg flex items-center gap-2",children:[(0,n.jsx)("span",{children:"Filters"}),(0,n.jsx)("span",{className:"text-xs bg-gray-100 px-2 py-1 rounded",children:"0"})]}),(0,n.jsxs)("select",{className:"px-4 py-2 border rounded-lg",children:[(0,n.jsx)("option",{children:"Last 24 hours"}),(0,n.jsx)("option",{children:"Last 7 days"}),(0,n.jsx)("option",{children:"Last 30 days"})]})]}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Export"})})]}),(0,n.jsx)("div",{className:"overflow-x-auto w-full",children:(0,n.jsxs)(z.Z,{className:"w-full table-fixed",children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:j.map(e=>(0,n.jsx)(K.Z,{className:"".concat("Request ID"===e.header?"w-32":""," whitespace-nowrap"),children:e.header},e.header))})}),(0,n.jsx)(V.Z,{children:i.map(e=>(0,n.jsxs)(r.Fragment,{children:[(0,n.jsx)(W.Z,{className:"cursor-pointer hover:bg-gray-50",onClick:()=>p(x===e.request_id?null:e.request_id),children:j.map(l=>{var s;return(0,n.jsx)(B.Z,{className:"Request ID"===l.header?"w-32 truncate":"",children:l.cell?l.cell({getValue:()=>e[l.accessorKey],row:{original:e}}):(0,n.jsx)("span",{children:String(null!==(s=e[l.accessorKey])&&void 0!==s?s:"")})},l.header)})}),x===e.request_id&&(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:j.length,className:"p-0",children:(0,n.jsx)(lf,{data:{request:"string"==typeof e.messages?JSON.parse(e.messages):e.messages,response:"string"==typeof e.response?JSON.parse(e.response):e.response,metadata:e.metadata}})})})]},e.request_id||e.startTime))})]})})]})}):(console.log("got None values for one of accessToken, token, userRole, userID"),null)},ly=s(92699),l_=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,n.jsx)(Z.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,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,n.jsx)(ei.Z,{children:"LlamaIndex"}),(0,n.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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 ')})})]})]})]})})})},lb=s(243),lv=s(94263);async function lw(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,n=new e7.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await n.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){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lS=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,r.useState)(i?"custom":"session"),[c,j]=(0,r.useState)(""),[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)([]),[v,S]=(0,r.useState)(void 0),[k,N]=(0,r.useState)([]),I=(0,r.useRef)(null);(0,r.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,m.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),S(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,r.useEffect)(()=>{I.current&&setTimeout(()=>{var e;null===(e=I.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[y]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===g.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){w.ZP.error("Please provide an API key or select Current UI Session");return}let n=[...y,{role:"user",content:g}];_(n);try{v&&await lw(n,(e,l)=>C("assistant",e,l),v,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}f("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,n.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsx)(ed.Z,{children:(0,n.jsx)(ei.Z,{children:"Chat"})}),(0,n.jsx)(em.Z,{children:(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"API Key Source"}),(0,n.jsx)(b.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,n.jsx)(p.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:j,value:c})]}),(0,n.jsxs)(u.Z,{className:"mx-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model:"}),(0,n.jsx)(b.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),S(e)},options:k,style:{width:"350px"},showSearch:!0})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{_([]),w.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,n.jsxs)(z.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{})})}),(0,n.jsxs)(V.Z,{children:[y.map((e,l)=>(0,n.jsx)(W.Z,{children:(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,n.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,n.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,n.jsx)(lb.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...r}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,n.jsx)(eI.Z,{style:lv.Z,language:i[1],PreTag:"div",...r,children:String(a).replace(/\n$/,"")}):(0,n.jsx)("code",{className:t,...r,children:a})}},children:e.content})})]})},l)),(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{children:(0,n.jsx)("div",{ref:I,style:{height:"1px"}})})})]})]}),(0,n.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,n.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,n.jsx)(p.Z,{type:"text",value:g,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,n.jsx)(x.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},lk=s(19226),lN=s(61787),lI=s(92403),lC=s(28595),lA=s(68208),lP=s(9775),lE=s(41361),lO=s(37527),lT=s(15883),lR=s(12660),lD=s(88009),lM=s(41169),lF=s(48231),lL=s(44625),lU=s(55322);let{Sider:lz}=lk.default,lV=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lB=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,n.jsx)(lI.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,n.jsx)(lC.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,n.jsx)(lA.Z,{}),roles:lV},{key:"4",page:"usage",label:"Usage",icon:(0,n.jsx)(lP.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,n.jsx)(lE.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,n.jsx)(lO.Z,{}),roles:lV},{key:"5",page:"users",label:"Internal Users",icon:(0,n.jsx)(lT.Z,{}),roles:lV},{key:"14",page:"api_ref",label:"API Reference",icon:(0,n.jsx)(lR.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,n.jsx)(lD.Z,{})},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,n.jsx)(lM.Z,{}),roles:lV,children:[{key:"15",page:"logs",label:"Logs",icon:(0,n.jsx)(lF.Z,{}),roles:lV},{key:"9",page:"caching",label:"Caching",icon:(0,n.jsx)(lL.Z,{}),roles:lV},{key:"10",page:"budgets",label:"Budgets",icon:(0,n.jsx)(lO.Z,{}),roles:lV}]},{key:"settings",page:"settings",label:"Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,n.jsx)(lR.Z,{}),roles:lV},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV}]}];var lq=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=lB.find(l=>l.page===e);if(l)return l.key;for(let l of lB)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),r=lB.filter(e=>!e.roles||e.roles.includes(s));return(0,n.jsx)(lk.default,{style:{minHeight:"100vh"},children:(0,n.jsx)(lz,{theme:"light",width:220,children:(0,n.jsx)(lN.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:r.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)}}})})})})},lK=s(96889),lW=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lH=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lG=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,p]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[w,S]=(0,r.useState)([]),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)([]),[A,P]=(0,r.useState)([]),[E,O]=(0,r.useState)([]),[T,R]=(0,r.useState)([]),[D,M]=(0,r.useState)({}),[F,U]=(0,r.useState)([]),[J,Y]=(0,r.useState)(""),[X,Q]=(0,r.useState)(["all-tags"]),[ee,el]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[es,et]=(0,r.useState)(null),ea=new Date(d.getFullYear(),d.getMonth(),1),ej=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(ea),ef=ev(ej);function eZ(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 ey=async()=>{if(l)try{let e=await (0,m.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,r.useEffect)(()=>{eb(ee.from,ee.to)},[ee,X]);let e_=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,m.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),v(a)},eb=async(e,s)=>{if(!e||!s||!l)return;let t=await ey();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,m.J$)(l,e.toISOString(),s.toISOString(),0===X.length?void 0:X)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ev(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(eg)),console.log("End date is ".concat(ef));let ew=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eS=()=>ew(()=>l?(0,m.FC)(l):Promise.reject("No access token"),p,"Error fetching overall spend"),ek=()=>ew(()=>l&&s?(0,m.OU)(l,s,eg,ef):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await ew(async()=>(await (0,m.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend})),g,"Error fetching top keys")},eI=async()=>{l&&await ew(async()=>(await (0,m.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),_,"Error fetching top models")},eC=async()=>{l&&await ew(async()=>{let e=await (0,m.mR)(l);return S(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eA=()=>{l&&ew(async()=>(await (0,m.X)(l)).tag_names,C,"Error fetching tag names")},eP=()=>{l&&ew(()=>{var e,s;return(0,m.J$)(l,null===(e=ee.from)||void 0===e?void 0:e.toISOString(),null===(s=ee.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>N(e.spend_per_tag),"Error fetching top tags")},eE=()=>{l&&ew(()=>(0,m.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eO=()=>{l&&ew(()=>(0,m.wd)(l,eg,ef),M,"Error fetching global activity")},eT=()=>{l&&ew(()=>(0,m.xA)(l,eg,ef),U,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ey();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),eS(),ek(),eN(),eI(),eO(),eT(),lH(t)&&(eC(),eA(),eP(),eE()))}})()},[l,s,t,a,eg,ef]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,n.jsxs)(Z.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,n.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,n.jsx)(x.Z,{className:"mt-4",children:(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{className:"mt-2",children:[(0,n.jsx)(ei.Z,{children:"All Up"}),lH(t)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ei.Z,{children:"Team Based Usage"}),(0,n.jsx)(ei.Z,{children:"Customer Usage"}),(0,n.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{})})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"solid",className:"mt-1",children:[(0,n.jsx)(ei.Z,{children:"Cost"}),(0,n.jsx)(ei.Z,{children:"Activity"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,n.jsx)($,{userID:a,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Monthly Spend"}),(0,n.jsx)(ep.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top API Keys"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top Models"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:f,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(lW.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend"})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Provider"}),(0,n.jsx)(K.Z,{children:"Spend"})]})}),(0,n.jsx)(V.Z,{children:T.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.provider}),(0,n.jsx)(B.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"All Up"}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(D.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(D.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,n.jsx)(n.Fragment,{children:F.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,n.jsx)(n.Fragment,{children:F&&F.length>0&&F.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eZ,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(u.Z,{numColSpan:2,children:[(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,n.jsx)(lK.Z,{data:E})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,n.jsx)(ep.Z,{className:"h-72",data:w,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,n.jsx)(u.Z,{numColSpan:2})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.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,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),e_(e.from,e.to,null)}})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Key"}),(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{e_(ee.from,ee.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,n.jsx)(G.Z,{value:String(l),onClick:()=>{e_(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,n.jsx)(L.Z,{className:"mt-4",children:(0,n.jsxs)(z.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Customer"}),(0,n.jsx)(K.Z,{children:"Spend"}),(0,n.jsx)(K.Z,{children:"Total Events"})]})}),(0,n.jsx)(V.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.end_user}),(0,n.jsx)(B.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,n.jsx)(B.Z,{children:e.total_count})]},l)})})]})})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(er.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,n.jsx)(u.Z,{children:o?(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsx)(eh.Z,{value:String(e),children:e},e))]})}):(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsxs)(G.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Spend Per Tag"}),(0,n.jsxs)(Z.Z,{children:["Get Started Tracking cost per tag ",(0,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,n.jsx)(ep.Z,{className:"h-72",data:k,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,n.jsx)(u.Z,{numColSpan:2})]})]})]})]})})};let lJ=e=>{if(e)return e.toISOString().split("T")[0]};function lY(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lX=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,x]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,f]=(0,r.useState)([]),[Z,y]=(0,r.useState)("0"),[_,b]=(0,r.useState)("0"),[v,w]=(0,r.useState)("0"),[S,k]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&S&&(async()=>{f(await (0,m.zg)(l,lJ(S.from),lJ(S.to)))})()},[l]);let N=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),I=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let C=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),f(await (0,m.zg)(l,lJ(e),lJ(s))))};return(0,r.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",g);let e=g;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),p.length>0&&(e=e.filter(e=>p.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 n=e.find(e=>e.name===a.call_type);return n?(n["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),n["Cache hit"]+=a.cache_hit_true_rows||0,n["Cached Completion Tokens"]+=a.cached_completion_tokens||0,n["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(lY(s)),b(lY(t));let n=s+l;n>0?w((s/n*100).toFixed(2)):w("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,p,S,g]),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(h.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select API Keys",value:c,onValueChange:x,children:N.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(er.Z,{enableSelect:!0,value:S,onValueChange:e=>{k(e),C(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Z})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]})]}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,n.jsx)(ep.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,n.jsx)(ep.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l$=()=>{let{Title:e,Paragraph:l}=et.default,[s,t]=(0,r.useState)(""),[a,o]=(0,r.useState)(!1),[d,u]=(0,r.useState)(!1),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[_,b]=(0,r.useState)(!0),v=(0,i.useSearchParams)(),[w,S]=(0,r.useState)({data:[]}),[k,N]=(0,r.useState)(null),I=v.get("userID"),C=v.get("invitation_id"),[A,P]=(0,r.useState)(()=>v.get("page")||"api-keys"),[E,O]=(0,r.useState)(null);return(0,r.useEffect)(()=>{N(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,r.useEffect)(()=>{if(!k)return;let e=(0,es.o)(k);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),O(e.key),u(e.disabled_non_admin_personal_key_creation),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&P("usage")}else console.log("User role not defined");e.user_email?x(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?b("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user),e.auth_header_name&&(0,m.K8)(e.auth_header_name)}},[k]),(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)("div",{children:"Loading..."}),children:C?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):(0,n.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,n.jsx)(c,{userID:I,userRole:s,userEmail:h,premiumUser:a,setProxySettings:y,proxySettings:Z}),(0,n.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,n.jsx)("div",{className:"mt-8",children:(0,n.jsx)(lq,{setPage:e=>{let l=new URLSearchParams(v);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),P(e)},userRole:s,defaultSelectedKey:A})}),"api-keys"==A?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):"models"==A?(0,n.jsx)(eT,{userID:I,userRole:s,token:k,keys:g,accessToken:E,modelData:w,setModelData:S,premiumUser:a}):"llm-playground"==A?(0,n.jsx)(lS,{userID:I,userRole:s,token:k,accessToken:E,disabledPersonalKeyCreation:d}):"users"==A?(0,n.jsx)(eL,{userID:I,userRole:s,token:k,keys:g,teams:p,accessToken:E,setKeys:f}):"teams"==A?(0,n.jsx)(ez,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s}):"organizations"==A?(0,n.jsx)(eY,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s,premiumUser:a}):"admin-panel"==A?(0,n.jsx)(eX,{setTeams:j,searchParams:v,accessToken:E,showSSOBanner:_,premiumUser:a}):"api_ref"==A?(0,n.jsx)(l_,{proxySettings:Z}):"settings"==A?(0,n.jsx)(e8,{userID:I,userRole:s,accessToken:E,premiumUser:a}):"budgets"==A?(0,n.jsx)(lu,{accessToken:E}):"general-settings"==A?(0,n.jsx)(ls,{userID:I,userRole:s,accessToken:E,modelData:w}):"model-hub"==A?(0,n.jsx)(ly.Z,{accessToken:E,publicPage:!1,premiumUser:a}):"caching"==A?(0,n.jsx)(lX,{userID:I,userRole:s,token:k,accessToken:E,premiumUser:a}):"pass-through-settings"==A?(0,n.jsx)(ld,{userID:I,userRole:s,accessToken:E,modelData:w}):"logs"==A?(0,n.jsx)(lZ,{userID:I,userRole:s,token:k,accessToken:E}):(0,n.jsx)(lG,{userID:I,userRole:s,token:k,accessToken:E,keys:g,premiumUser:a})]})]})})}}},function(e){e.O(0,[665,990,42,261,755,978,250,699,971,117,744],function(){return e(e.s=1900)}),_N_E=e.O()}]);
\ No newline at end of file
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,69623))},12011:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return Z}});var t=s(57437),a=s(2265),n=s(99376),r=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),j=s(14474),g=s(13634),f=s(73002);function Z(){let[e]=g.Z.useForm(),l=(0,n.useSearchParams)();!function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));l&&l.split("=")[1]}("token");let s=l.get("invitation_id"),[Z,y]=(0,a.useState)(null),[_,b]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),[S,k]=(0,a.useState)(null),[N,I]=(0,a.useState)(""),[C,A]=(0,a.useState)("");return(0,a.useEffect)(()=>{s&&(0,p.W_)(s).then(e=>{let l=e.login_url;console.log("login_url:",l),I(l);let s=e.token,t=(0,j.o)(s);A(s),console.log("decoded:",t),y(t.key),console.log("decoded user email:",t.user_email),w(t.user_email),k(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)(r.Z,{variant:"primary",className:"mb-2",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})})]})}),(0,t.jsxs)(g.Z,{className:"mt-10 mb-5 mx-auto",layout:"vertical",onFinish:e=>{console.log("in handle submit. accessToken:",Z,"token:",C,"formValues:",e),Z&&C&&(e.user_email=v,S&&s&&(0,p.m_)(Z,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)(g.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)(g.Z.Item,{label:"Password",name:"password",rules:[{required:!0,message:"password required to sign up"}],help:"Create a password for your account",children:(0,t.jsx)(u.Z,{placeholder:"",type:"password",className:"max-w-md"})})]}),(0,t.jsx)("div",{className:"mt-10",children:(0,t.jsx)(f.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},69623:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l$}});var t,a,n=s(57437),r=s(2265),i=s(99376),o=s(27648),d=s(92643),c=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:a,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",a),console.log=function(){};let c="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(c=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",c);let m=[{key:"1",label:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{children:["Role: ",s]}),(0,n.jsxs)("p",{children:["ID: ",l]}),(0,n.jsxs)("p",{children:["Premium User: ",String(a)]})]})},{key:"2",label:(0,n.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=c},children:"Logout"})}];return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,n.jsx)("div",{className:"w-full px-4",children:(0,n.jsxs)("div",{className:"flex justify-between items-center h-14",children:[(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)(o.default,{href:"/",className:"flex items-center",children:[(0,n.jsx)("span",{className:"text-xl",children:"\uD83D\uDE85"}),(0,n.jsx)("span",{className:"ml-2 text-base font-medium text-gray-700",children:"LiteLLM"})]})}),(0,n.jsxs)("div",{className:"flex items-center space-x-6",children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-gray-600 hover:text-gray-800",children:"Docs"}),(0,n.jsx)(d.Z,{menu:{items:m},children:(0,n.jsxs)("button",{className:"flex items-center text-sm text-gray-600 hover:text-gray-800",children:["Admin",(0,n.jsx)("svg",{className:"ml-1 w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})})},m=s(19250),u=s(49804),h=s(67101),x=s(20831),p=s(26637),j=s(87452),g=s(88829),f=s(72208),Z=s(84264),y=s(96761),_=s(29233),b=s(41326),v=s(13634),w=s(41021),S=s(51369),k=s(8104),N=s(20577),I=s(56632),C=s(73002);let{Option:A}=b.default,P=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};var E=e=>{let{userID:l,team:s,userRole:t,accessToken:a,data:i,setData:o}=e,[d]=v.Z.useForm(),[c,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(null),[R,D]=(0,r.useState)(null),[M,F]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[z,V]=(0,r.useState)("you"),[B,q]=(0,r.useState)(P(i)),K=()=>{E(!1),d.resetFields()},W=()=>{E(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==a){let e=(await (0,m.So)(a,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,t]);let H=async e=>{try{var s,t,n;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(n=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==n?n:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(w.ZP.info("Making API Call"),E(!0),"service_account"===z){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 u=await (0,m.wX)(a,l,e);console.log("key create Response:",u),o(e=>e?[...e,u]:[u]),T(u.key),D(u.soft_budget),w.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.log("error in create key:",e),w.ZP.error("Error creating the key: ".concat(e))}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>E(!0),children:"+ Create New Key"}),(0,n.jsx)(S.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,n.jsxs)(v.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Owned By",className:"mb-4",children:(0,n.jsxs)(k.ZP.Group,{onChange:e=>V(e.target.value),value:z,children:[(0,n.jsx)(k.ZP,{value:"you",children:"You"}),(0,n.jsx)(k.ZP,{value:"service_account",children:"Service Account"}),"Admin"===t&&(0,n.jsx)(k.ZP,{value:"another_user",children:"Another User"})]})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",hidden:"another_user"!==z,valuePropName:"user_id",className:"mt-8",rules:[{required:"another_user"===z,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,n.jsx)(p.Z,{placeholder:"User ID",onChange:e=>d.setFieldValue("user_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"you"===z||"another_user"===z?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===z?"key name":"service account ID")}],help:"you"===z?"required":"IDs can include letters, numbers, and hyphens",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",hidden:"another_user"!==z,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,n.jsx)(p.Z,{defaultValue:s?s.team_id:null,onChange:e=>d.setFieldValue("team_id",e.target.value)})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,n.jsx)(A,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,n.jsx)(A,{value:e,children:e},e))]})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.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,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)(v.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,n.jsx)(b.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:B})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),O&&(0,n.jsx)(S.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Save your Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,n.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,n.jsx)(u.Z,{numColSpan:1,children:null!=O?(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:O})}),(0,n.jsx)(_.CopyToClipboard,{text:O,onCopy:()=>{w.ZP.success("API Key copied to clipboard")},children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,n.jsx)(Z.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(7366),T=s(15731),R=s(53410),D=s(23628),M=s(74998),F=s(41649),L=s(12514),U=s(47323),z=s(21626),V=s(97214),B=s(28241),q=s(58834),K=s(69552),W=s(71876),H=s(27281),G=s(57365),J=s(90464);let{Option:Y}=b.default;console.log=function(){};var X=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:a,data:i,setData:o,teams:d,premiumUser:c}=e,[j,g]=(0,r.useState)(!1),[f,k]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[X,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)([]),ed=new Set,[ec,em]=(0,r.useState)(!1),[eu,eh]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)(null),[ej,eg]=(0,r.useState)(null),[ef]=v.Z.useForm(),[eZ,ey]=(0,r.useState)(null),[e_,eb]=(0,r.useState)(ed),ev=e=>!!e.members_with_roles&&e.members_with_roles.some(e=>"admin"===e.role&&e.user_id===l),ew=r.useMemo(()=>{let e=[];return d&&0!==d.length?(d.forEach(l=>{"default-team"!==l.team_id&&ev(l)?ev(l)&&a&&a.team_id===l.team_id&&(e=[...e,...l.keys||[]]):a&&a.team_id===l.team_id&&i&&(e=[...e,...i.filter(e=>e.team_id===l.team_id)])}),!a&&i&&(e=[...i.filter(e=>!e.team_id||"default-team"===e.team_id),...d.filter(e=>ev(e)).flatMap(e=>e.keys||[])]),Array.from(new Map((e=e.filter(e=>"litellm-dashboard"!==e.team_id)).map(e=>[e.token,e])).values())):i},[i,d,a,l]);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",en),(null==ej?void 0:ej.duration)?ey((e=>{if(!e)return null;try{let l;let s=new Date;if(e.endsWith("s"))l=(0,O.Z)(s,{seconds:parseInt(e)});else if(e.endsWith("h"))l=(0,O.Z)(s,{hours:parseInt(e)});else if(e.endsWith("d"))l=(0,O.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}})(ej.duration)):ey(null),console.log("calculateNewExpiryTime:",eZ)},[en,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),eo(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]);let eS=e=>{er(e),em(!0)},ek=async e=>{if(null==t||null==en)return;let l={...en,metadata:e,key:en.token};try{let e=await (0,m.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===en.token?e:l);o(l)}w.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),w.ZP.error("Failed to update model-specific limits")}em(!1),er(null)};(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),eb(e)}},[d]);let eN=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id);let l=null;if(e.budget_duration)switch(e.budget_duration){case"24h":l="daily";break;case"7d":l="weekly";break;case"30d":l="monthly";break;default:l="None"}er({...e,budget_duration:l}),es(!0)},eI=async e=>{if(null==t)return;let l=e.token;if(e.key=l,e.metadata&&"string"==typeof e.metadata)try{e.metadata=JSON.parse(e.metadata)}catch(l){console.error("Error parsing metadata JSON:",l),w.ZP.error("Invalid metadata JSON for formValue "+e.metadata);return}if(e.budget_duration)switch(e.budget_duration){case"daily":e.budget_duration="24h";break;case"weekly":e.budget_duration="7d";break;case"monthly":e.budget_duration="30d"}console.log("handleEditSubmit:",e);let s=await (0,m.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),w.ZP.success("Key updated successfully"),es(!1),er(null)},eC=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(A(e.token),localStorage.removeItem("userData"+l),k(!0))},eA=async()=>{if(null!=I&&null!=i){try{await (0,m.I1)(t,I);let e=i.filter(e=>e.token!==I);o(e)}catch(e){console.error("Error deleting the key:",e)}k(!1),A(null)}},eP=e=>{er(e),ey(null),ef.setFieldsValue({key_alias:e.key_alias,max_budget:e.max_budget,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,duration:e.duration||""}),eh(!0)},eE=(e,l)=>{eg(s=>({...s,[e]:l}))},eO=async()=>{if(!c){w.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=en)try{let e=await ef.validateFields(),l=await (0,m.s0)(t,en.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==en?void 0:en.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),ef.resetFields(),w.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),w.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,n.jsxs)("div",{children:[(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,n.jsxs)(z.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Key Alias"}),(0,n.jsx)(K.Z,{children:"Secret Key"}),(0,n.jsx)(K.Z,{children:"Created"}),(0,n.jsx)(K.Z,{children:"Expires"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Budget Reset"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"Rate Limits"}),(0,n.jsx)(K.Z,{children:"Rate Limits per model"})]})}),(0,n.jsx)(V.Z,{children:ew&&ew.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(a){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(e_.has(e.team_id),", selectedTeam id: ").concat(a.team_id)),(null!=a.team_id||null===e.team_id||e_.has(e.team_id))&&e.team_id!=a.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,n.jsx)(Z.Z,{children:e.key_alias}):(0,n.jsx)(Z.Z,{children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.key_name})}),(0,n.jsx)(B.Z,{children:null!=e.created_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,n.jsx)(B.Z,{children:null!=e.expires?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,n.jsx)(B.Z,{children:null!=e.max_budget?(0,n.jsx)(Z.Z,{children:e.max_budget}):(0,n.jsx)(Z.Z,{children:"Unlimited"})}),(0,n.jsx)(B.Z,{children:null!=e.budget_reset_at?(0,n.jsx)("div",{children:(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,n.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,n.jsx)(B.Z,{children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(n.Fragment,{children:a&&a.models&&a.models.length>0?a.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Team Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{size:"xs",onClick:()=>eS(e),children:"Edit Limits"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{onClick:()=>{er(e),ea(!0)},icon:T.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:et,onCancel:()=>{ea(!1),er(null)},footer:null,width:800,children:en&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(en.spend).toFixed(4)}catch(e){return en.spend}})()})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.max_budget?(0,n.jsxs)(n.Fragment,{children:[en.max_budget,en.budget_duration&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("br",{}),"Budget will be reset at ",en.budget_reset_at?new Date(en.budget_reset_at).toLocaleString():"Never"]})]}):(0,n.jsx)(n.Fragment,{children:"Unlimited"})})})]},e.name),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=en.expires?(0,n.jsx)(n.Fragment,{children:new Date(en.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,n.jsx)(n.Fragment,{children:"Never"})})})]},e.name)]}),(0,n.jsxs)(L.Z,{className:"my-4",children:[(0,n.jsx)(y.Z,{children:"Token Name"}),(0,n.jsx)(Z.Z,{className:"my-1",children:en.key_alias?en.key_alias:en.key_name}),(0,n.jsx)(y.Z,{children:"Token ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.token}),(0,n.jsx)(y.Z,{children:"User ID"}),(0,n.jsx)(Z.Z,{className:"my-1 text-[12px]",children:en.user_id}),(0,n.jsx)(y.Z,{children:"Metadata"}),(0,n.jsx)(Z.Z,{className:"my-1",children:(0,n.jsxs)("pre",{children:[JSON.stringify(en.metadata)," "]})})]}),(0,n.jsx)(x.Z,{className:"mx-auto flex items-center",onClick:()=>{ea(!1),er(null)},children:"Close"})]})}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>eN(e)}),(0,n.jsx)(U.Z,{onClick:()=>eP(e),icon:D.Z,size:"sm"}),(0,n.jsx)(U.Z,{onClick:()=>eC(e),icon:M.Z,size:"sm"})]})]},e.token)})})]}),f&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:eA,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{k(!1),A(null)},children:"Cancel"})]})]})]})})]}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=v.Z.useForm(),[c,m]=(0,r.useState)(a),[u,h]=(0,r.useState)([]),[x,j]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let f=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,n.jsx)(S.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:o,onFinish:eI,initialValues:f,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(Y,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ei.filter(e=>"all-proxy-models"!==e).map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):c.models.map(e=>(0,n.jsx)(Y,{value:e,children:e},e)):ei.map(e=>(0,n.jsx)(Y,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Current Reset Budget: ".concat(t.budget_duration,", budget will be reset: ").concat(t.budget_reset_at?new Date(t.budget_reset_at).toLocaleString():"Never"),children:(0,n.jsxs)(b.default,{placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"daily",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"weekly",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"monthly",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"token",name:"token",hidden:!0}),(0,n.jsx)(v.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,n.jsx)(H.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,n.jsx)(G.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"TPM Limit (tokens per minute)",name:"tpm_limit",help:"tpm_limit cannot exceed team tpm_limit ".concat((null==c?void 0:c.tpm_limit)!==null&&(null==c?void 0:c.tpm_limit)!==void 0?null==c?void 0:c.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.tpm_limit&&l>c.tpm_limit)throw console.log("keyTeam.tpm_limit: ".concat(c.tpm_limit)),Error("tpm_limit cannot exceed team max tpm_limit: $".concat(c.tpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max rpm_limit: ".concat((null==c?void 0:c.rpm_limit)!==null&&(null==c?void 0:c.rpm_limit)!==void 0?null==c?void 0:c.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.rpm_limit&&l>c.rpm_limit)throw console.log("keyTeam.rpm_limit: ".concat(c.rpm_limit)),Error("rpm_limit cannot exceed team max rpm_limit: $".concat(c.rpm_limit))}}],children:(0,n.jsx)(N.Z,{step:1,precision:1,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,n.jsx)(J.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:en,onSubmit:eI}),en&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:a,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,u]=(0,r.useState)([]),[h,p]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(t.metadata){let e=t.metadata.model_tpm_limit||{},l=t.metadata.model_rpm_limit||{},s={};Object.keys({...e,...l}).forEach(t=>{s[t]={tpm:e[t]||0,rpm:l[t]||0}}),d(s)}(async()=>{try{let e=await (0,m.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));u(l)}catch(e){console.error("Error fetching model data:",e),w.ZP.error("Failed to fetch available models")}})()},[t,i]);let j=(e,l,s)=>{d(t=>({...t,[e]:{...t[e],[l]:s||0}}))},g=e=>{d(l=>{let{[e]:s,...t}=l;return t})};return(0,n.jsxs)(S.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model"}),(0,n.jsx)(K.Z,{children:"TPM Limit"}),(0,n.jsx)(K.Z,{children:"RPM Limit"}),(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsxs)(V.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:l}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(N.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(b.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),p(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,n.jsx)(Y,{value:e,children:e},e))})}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:"-"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>p(null),children:"Cancel"})})]})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{p("")},disabled:null!==h,children:"Add Limit"})]}),(0,n.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,n.jsx)(x.Z,{onClick:s,children:"Cancel"}),(0,n.jsx)(x.Z,{onClick:()=>{a({...t.metadata,model_tpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.tpm]})),model_rpm_limit:Object.fromEntries(Object.entries(o).map(e=>{let[l,s]=e;return[l,s.rpm]}))})},children:"Save"})]})]})},{visible:ec,onCancel:()=>em(!1),token:en,onSubmit:ek,accessToken:t}),(0,n.jsx)(S.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),ef.resetFields()},footer:[(0,n.jsx)(x.Z,{onClick:()=>{eh(!1),ef.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,n.jsx)(x.Z,{onClick:eO,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,n.jsxs)(v.Z,{form:ef,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eE("duration",e.duration)},children:[(0,n.jsx)(v.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,n.jsx)(p.Z,{disabled:!0})}),(0,n.jsx)(v.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,n.jsx)(N.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,n.jsx)(N.Z,{style:{width:"100%"}})}),(0,n.jsx)(v.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==en?void 0:en.expires)!=null?new Date(en.expires).toLocaleString():"Never"]}),eZ&&(0,n.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",eZ]})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,n.jsx)(S.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,n.jsx)(x.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Regenerated Key"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,n.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,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Z.Z,{className:"mt-3",children:"Key Alias:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==en?void 0:en.key_alias)||"No alias set"})}),(0,n.jsx)(Z.Z,{className:"mt-3",children:"New API Key:"}),(0,n.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,n.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,n.jsx)(_.CopyToClipboard,{text:ex,onCopy:()=>w.ZP.success("API Key copied to clipboard"),children:(0,n.jsx)(x.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:a,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(a));let[d,c]=(0,r.useState)(null!==a?a:0),[u,h]=(0,r.useState)(o?o.max_budget:null);(0,r.useEffect)(()=>{if(o){if("Default Team"===o.team_alias)h(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&&(h(s.litellm_budget_table.max_budget),e=!0);e||h(o.max_budget)}}},[o,i]);let[x,p]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(!t||!l||!s)return};(async()=>{try{if(null===l||null===s)return;if(null!==t){let e=(await (0,m.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),p(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==a&&c(a)},[a]);let j=[];o&&o.models&&(j=o.models),j&&j.includes("all-proxy-models")?(console.log("user models:",x),j=x):j&&j.includes("all-team-models")?j=o.models:j&&0===j.length&&(j=x);let g=void 0!==d?d.toFixed(4):null;return console.log("spend in view user spend: ".concat(d)),(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,n.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==u?"$".concat(u," limit"):"No limit"})]})]})})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==a){let e=(await (0,m.So)(a,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==t?void 0:t.team_alias}),(null==t?void 0:t.team_id)&&(0,n.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},ee=e=>{let l,{teams:s,setSelectedTeam:t,userRole:a,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let u={models:(null==d?void 0:d.models)||[],team_id:null,team_alias:"Default Team",max_budget:(null==d?void 0:d.max_budget)||null},h=async()=>{null===i&&c&&o(await (0,m.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(u);return console.log("userRole: ".concat(a)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===a?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[u]:s?[...s,u]:[u],(0,n.jsxs)("div",{className:"mt-5 mb-5",children:[(0,n.jsx)(y.Z,{children:"Select Team"}),(0,n.jsx)(Z.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,n.jsxs)(Z.Z,{className:"mt-3 mb-3",children:[(0,n.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,n.jsxs)(Z.Z,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]})},el=s(12011),es=s(14474),et=s(68060);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:a,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:x,setKeys:p,premiumUser:j}=e,[g,f]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let y=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),_=Z.get("invitation_id"),[b,v]=(0,r.useState)(null),[w,S]=(0,r.useState)(null),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)(null),A={models:[],team_alias:"Default Team",team_id:null},[P,O]=(0,r.useState)(t?t[0]:A);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,es.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!a&&!g){let e=sessionStorage.getItem("userModels"+l);if(e)N(JSON.parse(e));else{let e=async()=>{let e;e="Admin"!=s&&"Admin Viewer"!=s?await (0,m.It)(b,l):await (0,m.It)(b),console.log("givenTeams: ".concat(e)),x(e)};(async()=>{try{let e=await (0,m.g)(b);C(e);let t=await (0,m.Br)(b,l,s,!1,null,null);console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),f(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys);let a=[...t.teams];a.length>0?(console.log("response['teams']: ".concat(a)),O(a[0])):O(A),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let n=(await (0,m.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),N(n),console.log("userModels:",k),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})(),e()}}},[l,y,b,a,s]),(0,r.useEffect)(()=>{if(null!==a&&null!=P&&null!==P.team_id){let e=0;for(let l of a)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);S(e)}else if(null!==a){let e=0;for(let l of a)e+=l.spend;S(e)}},[P]),null!=_)return(0,n.jsx)(el.default,{});if(null==l||null==y){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==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(Q,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,n.jsx)($,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:w,selectedTeam:P||null}),(0,n.jsx)(X,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:a,setData:p,premiumUser:j,teams:t}),(0,n.jsx)(E,{userID:l,team:P||null,userRole:s,accessToken:b,data:a,setData:p},P?P.team_id:null),(0,n.jsx)(ee,{teams:t,setSelectedTeam:O,userRole:s,proxySettings:I,setProxySettings:C,userInfo:g,accessToken:b})]})})})},en=s(97765),er=s(53003),ei=s(12485),eo=s(18135),ed=s(35242),ec=s(29706),em=s(77991),eu=s(92414),eh=s(46030),ex=s(75105),ep=s(40278),ej=s(75957),eg=s(69410),ef=s(47451),eZ=s(14301),ey=s(2356),e_=e=>{let{modelID:l,accessToken:s}=e,[t,a]=(0,r.useState)(!1),i=async()=>{try{w.ZP.info("Making API Call"),a(!0);let e=await (0,m.Og)(s,l);console.log("model delete Response:",e),w.ZP.success("Model ".concat(l," deleted successfully")),a(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(U.Z,{onClick:()=>a(!0),icon:M.Z,size:"sm"}),(0,n.jsx)(S.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>a(!1),children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full",children:[(0,n.jsx)(y.Z,{children:"Delete Model"}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("p",{children:["Model ID: ",(0,n.jsx)("b",{children:l})]})})]})})]})},eb=s(3632),ev=s(18502),ew=s(94789),eS=s(59664),ek=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:a}=e;return a?(0,n.jsx)(eS.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,n.jsxs)("div",{children:[(0,n.jsx)(ew.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,n.jsx)(x.Z,{variant:"primary",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eN=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,n.jsx)(n.Fragment,{children:l.map(e=>(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,n.jsx)(p.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eI=s(17906);let{Title:eC,Link:eA}=et.default;(t=a||(a={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",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.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Cohere="Cohere",t.Databricks="Databricks",t.Ollama="Ollama",t.xAI="xAI";let eP={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"},eE={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eO=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},a={};t.model=s;let n="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)n+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eP[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)a[l]=s;else if("custom_model_name"===l)t.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 w.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else if("model_info_params"==l){console.log("model_info_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw w.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 t[l]=s}let r={model_name:n,litellm_params:t,model_info:a},i=await (0,m.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){w.ZP.error("Failed to create model: "+e,10)}};var eT=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:u,premiumUser:j}=e,[g,f]=(0,r.useState)([]),[_]=v.Z.useForm(),[b,k]=(0,r.useState)(null),[I,A]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),O=Object.values(a).filter(e=>isNaN(Number(e))),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[ea,ew]=(0,r.useState)(!1),[eS,eT]=(0,r.useState)(null),[eR,eD]=(0,r.useState)([]),[eM,eF]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[ez,eV]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[eK,eW]=(0,r.useState)([]),[eH,eG]=(0,r.useState)([]),[eJ,eY]=(0,r.useState)([]),[eX,e$]=(0,r.useState)([]),[eQ,e0]=(0,r.useState)([]),[e1,e2]=(0,r.useState)([]),[e4,e5]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e7]=(0,r.useState)(null),[e9,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,la]=(0,r.useState)([]),[ln,lr]=(0,r.useState)(!1),[li,lo]=(0,r.useState)(null),[ld,lc]=(0,r.useState)(null),[lm,lu]=(0,r.useState)([]),lh=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),!s||!o||!i||!l||!t)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),eU(e);let a=null==li?void 0:li.token;void 0===a&&(a=null);let n=ld;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,m.o6)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,m.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,m.N8)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let u=await (0,m.fP)(s,o,i,e,l.toISOString(),t.toISOString(),a,n);if(console.log("slowResponses:",u),e5(u),e){let a=await (0,m.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(a);let n=await (0,m.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{eT(e),es(!0)},lp=e=>{eT(e),ew(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,a]of(e.input_cost_per_million_tokens&&(e.input_cost_per_token=e.input_cost_per_million_tokens/1e6,delete e.input_cost_per_million_tokens),e.output_cost_per_million_tokens&&(e.output_cost_per_token=e.output_cost_per_million_tokens/1e6,delete e.output_cost_per_million_tokens),Object.entries(e)))"model_id"!==s?l[s]=a:t=a;let a={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",a);try{await (0,m.um)(s,a),w.ZP.success("Model updated successfully, restart server to see updates"),es(!1),eT(null)}catch(e){console.log("Error occurred")}},lg=()=>{A(new Date().toLocaleString())},lf=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,m.K_)(s,{router_settings:{model_group_retry_policy:e6}}),w.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),w.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!s||!t||!i||!o)return;let e=async()=>{try{var e,l,t,a,n,r,d,c,h,x,p,j;let g=await (0,m.hy)(s);Y(g);let f=await (0,m.AZ)(s,o,i);console.log("Model data response:",f.data),u(f);let Z=new Set;for(let e=0;e0&&(_=y[y.length-1],console.log("_initial_model_group:",_)),console.log("selectedModelGroup:",eL);let b=await (0,m.o6)(s,o,i,_,null===(e=e8.from)||void 0===e?void 0:e.toISOString(),null===(l=e8.to)||void 0===l?void 0:l.toISOString(),null==li?void 0:li.token,ld);console.log("Model metrics response:",b),eq(b.data),eW(b.all_api_bases);let v=await (0,m.Rg)(s,_,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(a=e8.to)||void 0===a?void 0:a.toISOString());eG(v.data),eY(v.all_api_bases);let w=await (0,m.N8)(s,o,i,_,null===(n=e8.from)||void 0===n?void 0:n.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",w),e$(w.data),e0(w.exception_types);let S=await (0,m.fP)(s,o,i,_,null===(d=e8.from)||void 0===d?void 0:d.toISOString(),null===(c=e8.to)||void 0===c?void 0:c.toISOString(),null==li?void 0:li.token,ld),k=await (0,m.n$)(s,null===(h=e8.from)||void 0===h?void 0:h.toISOString().split("T")[0],null===(x=e8.to)||void 0===x?void 0:x.toISOString().split("T")[0],_);ls(k);let N=await (0,m.v9)(s,null===(p=e8.from)||void 0===p?void 0:p.toISOString().split("T")[0],null===(j=e8.to)||void 0===j?void 0:j.toISOString().split("T")[0],_);la(N),console.log("dailyExceptions:",k),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",S),e5(S);let I=await (0,m.j2)(s);lu(null==I?void 0:I.end_users);let C=(await (0,m.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",C);let A=C.model_group_retry_policy,P=C.num_retries;console.log("model_group_retry_policy:",A),console.log("default_retries:",P),e7(A),le(P)}catch(e){console.error("There was an error fetching the model data",e)}};s&&t&&i&&o&&e();let l=async()=>{let e=await (0,m.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),k(e)};null==b&&l(),lg()},[s,t,i,o,b,I]),!d||!s||!t||!i||!o)return(0,n.jsx)("div",{children:"Loading..."});let lZ=[],ly=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(b)),null!=b&&"object"==typeof b&&e in b)?b[e].litellm_provider:"openai";if(s){let e=s.split("/"),l=e[0];(n=t)||(n=1===e.length?u(s):l)}else n="-";a&&(r=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,o=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}))),d.data[e].provider=n,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,ly.push(n),d.data[e].input_cost&&(d.data[e].input_cost=(1e6*Number(d.data[e].input_cost)).toFixed(2)),d.data[e].output_cost&&(d.data[e].output_cost=(1e6*Number(d.data[e].output_cost)).toFixed(2)),d.data[e].max_tokens=o,d.data[e].max_input_tokens=c,d.data[e].api_base=null==l?void 0:null===(lv=l.litellm_params)||void 0===lv?void 0:lv.api_base,d.data[e].cleanedLitellmParams=m,lZ.push(l.model_name),console.log(d.data[e])}if(d.data&&d.data.length>0&&d.data.sort((e,l)=>e.provider&&l.provider?e.provider.localeCompare(l.provider):e.provider&&!l.provider?-1:!e.provider&&l.provider?1:0),i&&"Admin Viewer"==i){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lw=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(a).find(l=>a[l]===e);if(l){let e=eP[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,a]=l;null!==a&&"object"==typeof a&&"litellm_provider"in a&&(a.litellm_provider===e||a.litellm_provider.includes(e))&&s.push(t)}),"Cohere"==l&&(console.log("adding cohere chat model"),Object.entries(b).forEach(e=>{let[l,t]=e;null!==t&&"object"==typeof t&&"litellm_provider"in t&&"cohere"===t.litellm_provider&&s.push(l)}))),E(s),console.log("providerModels: ".concat(P))}},lS=async()=>{try{w.ZP.info("Running health check..."),ee("");let e=await (0,m.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lk=(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Select API Key Name"}),j?(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,n.jsxs)("div",{children:[(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{lo(null)},children:"All Keys"},"all-keys"),null==c?void 0:c.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,n.jsxs)(G.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,n.jsx)(Z.Z,{className:"mt-1",children:"Select Customer Name"}),(0,n.jsxs)(H.Z,{defaultValue:"all-customers",children:[(0,n.jsx)(G.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,n.jsxs)(G.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:a}=e;if(!a||!t)return null;let r=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,n.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[r&&(0,n.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.toFixed(5);return(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,n.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,n.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:t})]},l)})]})},lI=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";console.log("selectedProvider: ".concat(X)),console.log("providerModels.length: ".concat(P.length));let lC=Object.keys(a).find(e=>a[e]===X);return lC&&(l=M.find(e=>e.name===eP[lC])),(0,n.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(ei.Z,{children:"All Models"}),(0,n.jsx)(ei.Z,{children:"Add Model"}),(0,n.jsx)(ei.Z,{children:(0,n.jsx)("pre",{children:"/health Models"})}),(0,n.jsx)(ei.Z,{children:"Model Analytics"}),(0,n.jsx)(ei.Z,{children:"Model Retry Settings"})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[I&&(0,n.jsxs)(Z.Z,{children:["Last Refreshed: ",I]}),(0,n.jsx)(U.Z,{icon:D.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsxs)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||void 0,onValueChange:e=>eU("all"===e?"all":e),value:eL||void 0,children:[(0,n.jsx)(G.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,n.jsx)(K.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsxs)(K.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,n.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created At":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:j?"Created By":(0,n.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,n.jsx)(K.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,n.jsxs)(W.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.litellm_model_name,children:(0,n.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"===i&&(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsx)(ej.Z,{title:e&&e.api_base,children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.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,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)("p",{className:"text-xs",children:j&&e.model_info.created_by||"-"})}),(0,n.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,n.jsx)(F.Z,{size:"xs",className:"text-white",children:(0,n.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,n.jsx)(F.Z,{size:"xs",className:"text-black",children:(0,n.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,n.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,n.jsxs)(h.Z,{numItems:3,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>lx(e)})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(e_,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,n.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:a}=e,[r]=v.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,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,n.jsx)(S.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"max_retries",name:"max_retries",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.Z.Item,{label:"Input Cost per 1M Tokens",name:"input_cost_per_million_tokens",tooltip:"float (optional) - Input cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"Output Cost per 1M Tokens",name:"output_cost_per_million_tokens",tooltip:"float (optional) - Output cost per 1 million tokens",children:(0,n.jsx)(N.Z,{min:0,step:.01})}),(0,n.jsx)(v.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),eT(null)},model:eS,onSubmit:lj}),(0,n.jsxs)(S.Z,{title:eS&&eS.model_name,visible:ea,width:800,footer:null,onCancel:()=>{ew(!1),eT(null)},children:[(0,n.jsx)(y.Z,{children:"Model Info"}),(0,n.jsx)(eI.Z,{language:"json",children:eS&&JSON.stringify(eS,null,2)})]})]}),(0,n.jsxs)(ec.Z,{className:"h-full",children:[(0,n.jsx)(eC,{level:2,children:"Add new model"}),(0,n.jsx)(L.Z,{children:(0,n.jsxs)(v.Z,{form:_,onFinish:()=>{_.validateFields().then(e=>{eO(e,s,_)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(H.Z,{value:X.toString(),children:O.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>{lw(e),$(e)},children:e},l))})}),(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],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.",className:"mb-0",children:(0,n.jsx)(p.Z,{})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,n.jsxs)(v.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,n.jsx)(v.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,n.jsx)(p.Z,{placeholder:lI(X.toString())}):P.length>0?(0,n.jsxs)(eu.Z,{children:[(0,n.jsx)(eh.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,n.jsx)(eh.Z,{value:e,children:e},l))]}):(0,n.jsx)(p.Z,{placeholder:lI(X.toString())})}),(0,n.jsx)(v.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,n.jsx)(v.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,n.jsx)(p.Z,{placeholder:"Enter custom model name"})})}})]}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==l&&l.fields.length>0&&(0,n.jsx)(eN,{fields:l.fields,selectedProvider:l.name}),"Amazon Bedrock"!=X&&"Vertex AI (Anthropic, Gemini, etc.)"!=X&&"Ollama"!=X&&(void 0===l||0==l.fields.length)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,n.jsx)(p.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization",children:(0,n.jsx)(p.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,n.jsx)(p.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,n.jsx)(p.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,n.jsx)(ev.Z,{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;_.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?w.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&w.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,n.jsx)(C.ZP,{icon:(0,n.jsx)(eb.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsx)(Z.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==X||"OpenAI-Compatible Endpoints (Together AI, etc.)"==X)&&(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,n.jsx)(p.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,n.jsxs)("div",{children:[(0,n.jsx)(v.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,n.jsx)(p.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,n.jsx)(eA,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:"us-east-1"})}),(0,n.jsx)(v.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,n.jsxs)(ef.Z,{children:[(0,n.jsx)(eg.Z,{span:10}),(0,n.jsx)(eg.Z,{span:10,children:(0,n.jsxs)(Z.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,n.jsx)(eA,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,n.jsx)(v.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",children:(0,n.jsx)(J.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]}),(0,n.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,n.jsx)(ej.Z,{title:"Get help on our github",children:(0,n.jsx)(et.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,n.jsx)(x.Z,{onClick:lS,children:"Run `/health`"}),Q&&(0,n.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,n.jsxs)(eg.Z,{className:"ml-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model Group"}),(0,n.jsx)(H.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(eZ.Z,{trigger:"click",content:lk,overlayStyle:{width:"20vw"},children:(0,n.jsx)(x.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Avg. Latency per Token"}),(0,n.jsx)(ei.Z,{value:"2",children:"✨ Time to first token"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,n.jsx)(Z.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eK&&(0,n.jsx)(ex.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(ek,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:j})})]})]})})}),(0,n.jsx)(eg.Z,{children:(0,n.jsx)(L.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Deployment"}),(0,n.jsx)(K.Z,{children:"Success Responses"}),(0,n.jsxs)(K.Z,{children:["Slow Responses ",(0,n.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,n.jsx)(V.Z,{children:e4.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.api_base}),(0,n.jsx)(B.Z,{children:e.total_count}),(0,n.jsx)(B.Z,{children:e.slow_count})]},l))})]})})})]}),(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,n.jsx)(ep.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,n.jsxs)(h.Z,{numItems:1,children:[(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,n.jsx)(eg.Z,{})]})]}),j?(0,n.jsx)(n.Fragment,{children:lt.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,n.jsx)(n.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.api_base}),(0,n.jsx)(h.Z,{numItems:1,children:(0,n.jsxs)(eg.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(Z.Z,{children:"Filter by Public Model Name"}),(0,n.jsx)(H.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eL||eR[0],value:eL||eR[0],onValueChange:e=>eU(e),children:eR.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,n.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,n.jsx)(Z.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eE&&(0,n.jsx)("table",{children:(0,n.jsx)("tbody",{children:Object.entries(eE).map((e,l)=>{var s;let[t,a]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[a];return null==r&&(r=e9),(0,n.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,n.jsx)("td",{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)("td",{children:(0,n.jsx)(N.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(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,n.jsx)(x.Z,{className:"mt-6 mr-8",onClick:lf,children:"Save"})]})]})]})})};function eR(e){let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:a}=e,{Title:r,Paragraph:i}=et.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,n.jsxs)(S.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,n.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"User ID"}),(0,n.jsx)(Z.Z,{children:null==a?void 0:a.user_id})]}),(0,n.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,n.jsx)(Z.Z,{children:"Invitation Link"}),(0,n.jsx)(Z.Z,{children:(0,n.jsx)(Z.Z,{children:o()})})]}),(0,n.jsx)("div",{className:"flex justify-end mt-5",children:(0,n.jsx)(_.CopyToClipboard,{text:o(),onCopy:()=>w.ZP.success("Copied!"),children:(0,n.jsx)(x.Z,{variant:"primary",children:"Copy invitation link"})})})]})}let{Option:eD}=b.default;var eM=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:a}=e,[o,d]=(0,r.useState)(null),[c]=v.Z.useForm(),[u,h]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]),[_,k]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)(),[E,O]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,m.So)(s,l,"any"),t=[];for(let l=0;l{P&&O(new URL("/",window.location.href).toString())},[P]);let T=async e=>{try{var t;w.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let a=await (0,m.Ov)(s,null,e);console.log("user create Response:",a),g(a.key);let n=(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:n,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};A(e),k(!0)}else(0,m.XO)(s,n).then(e=>{e.has_user_setup_sso=!1,A(e),k(!0)});w.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,n.jsxs)(S.Z,{title:"Invite User",visible:u,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,n.jsx)(Z.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,n.jsxs)(v.Z,{form:c,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(v.Z.Item,{label:"User Email",name:"user_email",children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:a&&Object.entries(a).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"team_id",children:(0,n.jsx)(b.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,n.jsx)(eD,{value:e.team_id,children:e.team_alias},e.team_id)):(0,n.jsx)(eD,{value:null,children:"Default Team"},"default")})}),(0,n.jsx)(v.Z.Item,{label:"Metadata",name:"metadata",children:(0,n.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),j&&(0,n.jsx)(eR,{isInvitationLinkModalVisible:_,setIsInvitationLinkModalVisible:k,baseUrl:E,invitationLinkData:N})]})},eF=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:a,onSubmit:i}=e,[o,d]=(0,r.useState)(a),[c]=v.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[a]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return a?(0,n.jsx)(S.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+a.user_id,width:1e3,children:(0,n.jsx)(v.Z,{form:c,onFinish:u,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"User Role",name:"user_role",children:(0,n.jsx)(b.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,n.jsx)(G.Z,{value:l,title:s,children:(0,n.jsxs)("div",{className:"flex",children:[s," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)(v.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,n.jsx)(N.Z,{min:0,step:1})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eL=e=>{let{accessToken:l,token:s,keys:t,userRole:a,userID:i,teams:o,setKeys:d}=e,[c,u]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)(1),[_,b]=r.useState(null),[v,S]=(0,r.useState)(null),[k,N]=(0,r.useState)(!1),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(!1),[E,O]=(0,r.useState)(null),[T,D]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let H=e=>{O(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,m.Eb)(l,[E]),w.ZP.success("User deleted successfully"),p){let e=p.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),w.ZP.error("Failed to delete user")}P(!1),O(null)},J=async()=>{C(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&a&&i){try{await (0,m.pf)(l,e,null),w.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}p&&j(p.map(l=>l.user_id===e.user_id?e:l)),C(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!a||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(Z));if(e){let l=JSON.parse(e);u(l),j(l.users||[])}else{let e=await (0,m.Br)(l,null,a,!0,Z,25);sessionStorage.setItem("userList_".concat(Z),JSON.stringify(e)),u(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)D(JSON.parse(s));else{let e=await (0,m.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,Z]),p&&l&&s&&a&&i)?(0,n.jsx)("div",{style:{width:"100%"},children:(0,n.jsxs)(h.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,n.jsx)(eM,{userID:i,accessToken:l,teams:o,possibleUIRoles:T}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,n.jsx)("div",{className:"mb-4 mt-1"}),(0,n.jsx)(eo.Z,{children:(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(z.Z,{className:"mt-5",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"User ID"}),(0,n.jsx)(K.Z,{children:"User Email"}),(0,n.jsx)(K.Z,{children:"Role"}),(0,n.jsx)(K.Z,{children:"User Spend ($ USD)"}),(0,n.jsx)(K.Z,{children:"User Max Budget ($ USD)"}),(0,n.jsx)(K.Z,{children:"API Keys"}),(0,n.jsx)(K.Z,{})]})}),(0,n.jsx)(V.Z,{children:p.map(e=>{var l,s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id||"-"}),(0,n.jsx)(B.Z,{children:e.user_email||"-"}),(0,n.jsx)(B.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,n.jsx)(B.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,n.jsx)(B.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(h.Z,{numItems:2,children:e.key_count>0?(0,n.jsxs)(F.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,n.jsx)(F.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,onClick:()=>{C(e),N(!0)},children:"View Keys"}),(0,n.jsx)(U.Z,{icon:M.Z,onClick:()=>H(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,n.jsx)(eF,{visible:k,possibleUIRoles:T,onCancel:J,user:I,onSubmit:Y}),A&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,n.jsxs)("div",{className:"mt-2",children:[(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,n.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{P(!1),O(null)},children:"Cancel"})]})]})]})})]}),function(){if(!p)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),y(e)};return(0,n.jsxs)("div",{className:"flex justify-between items-center",children:[(0,n.jsxs)("div",{children:["Showing Page ",Z," of ",e]}),(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===Z,onClick:()=>l(Z-1),children:"← Prev"}),(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:Z===e,onClick:()=>l(Z+1),children:"Next →"})]})]})}()]})}):(0,n.jsx)("div",{children:"Loading..."})},eU=e=>{var l,s;let{visible:t,onCancel:a,onSubmit:r,initialData:i,mode:o}=e,[d]=v.Z.useForm(),c=async e=>{try{let l={email:e.user_email,id:e.user_id,role:e.role};r(l),d.resetFields(),w.ZP.success("Successfully ".concat("add"===o?"added":"updated"," team member"))}catch(e){w.ZP.error("Failed to submit form"),console.error("Form submission error:",e)}};return(0,n.jsx)(S.Z,{title:"add"===o?"Add Team Member":"Edit Team Member",visible:t,width:800,footer:null,onCancel:a,children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{user_email:(null==i?void 0:null===(l=i.email)||void 0===l?void 0:l.trim())||"",user_id:(null==i?void 0:null===(s=i.id)||void 0===s?void 0:s.trim())||"",role:(null==i?void 0:i.role)||"user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",rules:[{type:"email",message:"Please enter a valid email!"}],children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full",placeholder:"user@example.com",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)("div",{className:"text-center mb-4",children:(0,n.jsx)(Z.Z,{children:"OR"})}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full",placeholder:"user_123",onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",rules:[{required:!0,message:"Please select a role!"}],children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})}),(0,n.jsxs)("div",{style:{textAlign:"right",marginTop:"20px"},children:[(0,n.jsx)(C.ZP,{onClick:a,style:{marginRight:8},children:"Cancel"}),(0,n.jsx)(C.ZP,{type:"primary",htmlType:"submit",children:"add"===o?"Add Member":"Save Changes"})]})]})})};console.log=function(){};var ez=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:a,userID:i,userRole:o}=e;(0,r.useEffect)(()=>{console.log("inside useeffect - ".concat(l)),null===l&&t&&(async()=>{let e;e="Admin"!=o&&"Admin Viewer"!=o?await (0,m.It)(t,i):await (0,m.It)(t),console.log("givenTeams: ".concat(e)),a(e)})()},[l]);let[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:y,Paragraph:_}=et.default,[k,A]=(0,r.useState)(""),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(l?l[0]:null),[D,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)([]),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(null),[ed,ec]=(0,r.useState)({}),em=e=>{T(e),E(!0)},eu=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let n=await (0,m.Gh)(t,e);l&&a(l.map(e=>e.team_id===s?n.data:e)),w.ZP.success("Team updated successfully"),E(!1),T(null)},eh=()=>{X(!1),Q(!1),c.resetFields()},ex=async e=>{er(e),ea(!0)},ep=async()=>{if(null!=en&&null!=l&&null!=t){try{await (0,m.rs)(t,en);let e=l.filter(e=>e.team_id!==en);a(e)}catch(e){console.error("Error deleting the team:",e)}ea(!1),er(null)}};(0,r.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,m.It)(t,i):await (0,m.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,m.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eg=async e=>{try{if(console.log("formValues: ".concat(JSON.stringify(e))),null!=t){var s;let n=null==e?void 0:e.team_alias,r=null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[],i=null==e?void 0:e.organization_id;if(""===i||"string"!=typeof i?e.organization_id=null:e.organization_id=i.trim(),r.includes(n))throw Error("Team alias ".concat(n," already exists, please pick another alias"));w.ZP.info("Creating Team");let o=await (0,m.hT)(t,e);null!==l?a([...l,o]):a([o]),console.log("response for team create call: ".concat(o)),w.ZP.success("Team created"),J(!1)}}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the team: "+e,20)}},ef=async(e,s)=>{try{if(null!=t&&null!=l){let n;w.ZP.info("Adding Member");let r={role:e.role,user_email:e.user_email,user_id:e.user_id};"add"==s?(n=await (0,m.cu)(t,O.team_id,r),w.ZP.success("Member added")):(n=await (0,m.sN)(t,O.team_id,{role:e.role,user_id:e.id,user_email:e.email}),w.ZP.success("Member updated"));let i=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(n.data.team_id)),e.team_id===n.data.team_id));if(console.log("foundIndex: ".concat(i)),-1!==i){let e=[...l];e[i]=n.data,a(e),T(n.data)}X(!1)}}catch(e){console.error("Error creating the team:",e)}},eZ=async e=>{ef(e,"add")},ey=async e=>{ef(e,"edit")};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"All Teams"}),(0,n.jsxs)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Team Name"}),(0,n.jsx)(K.Z,{children:"Team ID"}),(0,n.jsx)(K.Z,{children:"Spend (USD)"}),(0,n.jsx)(K.Z,{children:"Budget (USD)"}),(0,n.jsx)(K.Z,{children:"Models"}),(0,n.jsx)(K.Z,{children:"TPM / RPM Limits"}),(0,n.jsx)(K.Z,{children:"Info"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,n.jsx)(ej.Z,{title:e.team_id,children:e.team_id})}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,n.jsx)(B.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,n.jsx)(B.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"All Proxy Models"})},l):(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,n.jsx)(B.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,n.jsxs)(Z.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,n.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].keys&&ed[e.team_id].keys.length," ","Keys"]}),(0,n.jsxs)(Z.Z,{children:[ed&&e.team_id&&ed[e.team_id]&&ed[e.team_id].members_with_roles&&ed[e.team_id].members_with_roles.length," ","Members"]})]}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>em(e)}),(0,n.jsx)(U.Z,{onClick:()=>ex(e.team_id),icon:M.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),es&&(0,n.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,n.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,n.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,n.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,n.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,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)(x.Z,{onClick:ep,color:"red",className:"ml-2",children:"Delete"}),(0,n.jsx)(x.Z,{onClick:()=>{ea(!1),er(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>J(!0),children:"+ Create New Team"}),(0,n.jsx)(S.Z,{title:"Create Team",visible:D,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:eg,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Additional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,n.jsx)(v.Z.Item,{label:"Organization ID",name:"organization_id",help:"Assign team to an organization. Found in the 'Organization' tab.",children:(0,n.jsx)(p.Z,{placeholder:"",onChange:e=>{e.target.value=e.target.value.trim()}})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(y,{level:4,children:"Team Members"}),(0,n.jsx)(_,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,n.jsx)(H.Z,{defaultValue:"0",children:l.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{T(e)},children:e.team_alias},l))}):(0,n.jsxs)(_,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:O?O.members_with_roles.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsx)(B.Z,{children:e.role}),(0,n.jsx)(B.Z,{children:"Admin"==o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{Q(!0),eo({id:e.user_id,email:e.user_email,role:e.role})}}),(0,n.jsx)(U.Z,{onClick:()=>{},icon:M.Z,size:"sm"})]}):null})]},l)):null})]})}),(0,n.jsx)(eU,{visible:$,onCancel:eh,onSubmit:ey,initialData:ei,mode:"edit"}),O&&(0,n.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:a}=e,[r]=v.Z.useForm();return(0,n.jsx)(S.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{a({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,n.jsxs)(v.Z,{form:r,onFinish:eu,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),ee&&ee.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:P,onCancel:()=>{E(!1),T(null)},team:O,onSubmit:eu})]}),(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"==o||O&&(e=>{for(let l=0;lX(!0),children:"+ Add member"}):null,(0,n.jsx)(S.Z,{title:"Add member",visible:Y,width:800,footer:null,onOk:()=>{X(!1),Q(!1),c.resetFields()},onCancel:eh,children:(0,n.jsxs)(v.Z,{form:d,onFinish:eZ,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"admin",children:"admin"}),(0,n.jsx)(b.default.Option,{value:"user",children:"user"})]})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})};let eV=async(e,l,s)=>{if(null!=l)try{w.ZP.info("Creating Organization"),console.log("formValues: "+JSON.stringify(e));let t=await (0,m.H1)(l,e);console.log("response for organization create call: ".concat(t)),w.ZP.success("Organization created"),sessionStorage.removeItem("organizations"),s(!1)}catch(e){console.error("Error creating the organization:",e),w.ZP.error("Error creating the organization: "+e,20)}};var eB=e=>{let{title:l="Create Organization",onCancel:s,accessToken:t,availableModels:a=[],initialValues:i={},submitButtonText:o="Create",modelSelectionType:d="multiple"}=e,[c]=v.Z.useForm(),[m,u]=(0,r.useState)(!1),[h,j]=(0,r.useState)({name:i.name||"",models:i.models||[],maxBudget:i.maxBudget||null,budgetDuration:i.budgetDuration||null,tpmLimit:i.tpmLimit||null,rpmLimit:i.rpmLimit||null});console.log("availableModels: ".concat(a));let g=async e=>{null!=t&&(await eV(e,t,u),u(!1))};return(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)(x.Z,{onClick:()=>u(!0),className:"mx-auto",type:"button",children:["+ Create New ",l]}),(0,n.jsx)(S.Z,{title:"Create ".concat(l),visible:m,width:800,footer:null,onCancel:()=>{u(!1),s&&s()},children:(0,n.jsxs)(v.Z,{form:c,onFinish:g,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"".concat(l," Name"),name:"organization_alias",rules:[{required:!0,message:"Please input a ".concat(l," name")}],children:(0,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Models",name:"models",children:(0,n.jsxs)(b.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,n.jsx)(b.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),a.map(e=>(0,n.jsx)(b.default.Option,{value:e,children:e},e))]})}),(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})}),(0,n.jsx)(v.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})}),(0,n.jsx)(v.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,n.jsx)(N.Z,{step:1,width:400})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:o})})]})})]})};let eq=(e,l)=>{for(let s=0;s{let{userRole:l,userID:s,selectedOrganization:t,onMemberAdd:a}=e,[i,o]=r.useState(!1),[d]=v.Z.useForm();return(0,n.jsxs)(u.Z,{numColSpan:1,children:["Admin"===l||t&&eq(t,s)?(0,n.jsx)(x.Z,{className:"mx-auto mb-5",onClick:()=>o(!0),children:"+ Add member"}):null,(0,n.jsxs)(S.Z,{title:"Add member",visible:i,width:800,footer:null,onOk:()=>{d.submit()},onCancel:()=>{d.resetFields(),o(!1)},children:[(0,n.jsx)(Z.Z,{className:"mb-2",children:"User must exist in proxy. Get User ID from 'Users' tab."}),(0,n.jsxs)(v.Z,{form:d,onFinish:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"internal_user"},children:[(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,n.jsx)(v.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,n.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,n.jsx)(v.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,n.jsxs)(b.default,{defaultValue:"user",children:[(0,n.jsx)(b.default.Option,{value:"org_admin",children:(0,n.jsxs)("div",{className:"flex",children:["Org Admin"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can add and remove members, and change their roles."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can view/create keys for themselves within organization."})]})}),(0,n.jsx)(b.default.Option,{value:"internal_user_viewer",children:(0,n.jsxs)("div",{className:"flex",children:["Internal User Viewer"," ",(0,n.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:"Can only view their keys within organization."})]})})]})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})]})]})},eW=e=>{var l;let{selectedEntity:s,onEditSubmit:t,editModalComponent:a,entityType:i}=e,[o,d]=r.useState(!1);return(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"team"===i?"Team Member":"Organization Member"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:(null!==(l=null==s?void 0:s.members)&&void 0!==l?l:[]).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_id}),(0,n.jsx)(B.Z,{children:e.user_role})]},"".concat(e.user_id,"-").concat(l)))})]})}),s&&(0,n.jsx)(a,{visible:o,onCancel:()=>{d(!1)},entity:s,onSubmit:e=>{t(e),d(!1)}})]})},eH=e=>{let{data:l,columns:s,actions:t,emptyMessage:a="No data available",deleteModal:r}=e,i=(e,l)=>{let s=l[e.accessor];return e.cellRenderer?e.cellRenderer(s,l):Array.isArray(s)?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===s.length?(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"red",children:(0,n.jsx)(Z.Z,{children:"None"})}):s.map((e,l)=>(0,n.jsx)(F.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,n.jsx)(Z.Z,{children:String(e).length>30?"".concat(String(e).slice(0,30),"..."):e})},l))}):(null==s?void 0:s.toString())||""};return(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[40vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[s.map((e,l)=>(0,n.jsx)(K.Z,{children:e.header},l)),t&&t.length>0&&(0,n.jsx)(K.Z,{children:"Actions"})]})}),(0,n.jsx)(V.Z,{children:l&&l.length>0?l.map((e,l)=>(0,n.jsxs)(W.Z,{children:[s.map((l,s)=>(0,n.jsx)(B.Z,{style:{maxWidth:l.width||"4px",whiteSpace:"pre-wrap",overflow:"hidden",...l.style},children:"id"===l.accessor?(0,n.jsx)(ej.Z,{title:e[l.accessor],children:i(l,e)}):i(l,e)},s)),t&&t.length>0&&(0,n.jsx)(B.Z,{children:t.map((l,s)=>{var t;return(null===(t=l.condition)||void 0===t?void 0:t.call(l,e))!==!1&&(0,n.jsx)(ej.Z,{title:l.tooltip,children:(0,n.jsx)(U.Z,{icon:l.icon,size:"sm",onClick:()=>l.onClick(e),className:"cursor-pointer mx-1"})},s)})})]},l)):(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:s.length+(t?1:0),children:(0,n.jsx)(Z.Z,{className:"text-center",children:a})})})})]})})};console.log=function(){};let eG=e=>{let{visible:l,onCancel:s,entity:t,onSubmit:a}=e;return(0,n.jsx)("div",{})},eJ=e=>{let{organizations:l,userRole:s,onEdit:t,onDelete:a,isDeleteModalOpen:r,setIsDeleteModalOpen:i,selectedOrganization:o,setSelectedOrganization:d}=e,c=[...t&&"Admin"===s?[{icon:void 0,onClick:e=>t(e),condition:()=>"Admin"===s,tooltip:"Edit organization"}]:[],...a&&"Admin"===s?[{icon:void 0,onClick:e=>a(e),condition:()=>"Admin"===s,tooltip:"Delete organization"}]:[]];return(0,n.jsx)(eH,{data:l,columns:[{header:"Organization Name",accessor:"organization_alias",width:"4px",style:{whiteSpace:"pre-wrap",overflow:"hidden"}},{header:"Organization ID",accessor:"organization_id",width:"4px",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"}},{header:"Spend (USD)",accessor:"spend"},{header:"Budget (USD)",accessor:"max_budget",cellRenderer:e=>null!=e?e:"No limit"},{header:"Models",accessor:"models"},{header:"TPM / RPM Limits",accessor:"limits",cellRenderer:(e,l)=>(0,n.jsxs)("div",{className:"text-sm",children:[(0,n.jsxs)("span",{children:["TPM: ",l.tpm_limit?l.tpm_limit:"Unlimited"]}),(0,n.jsx)("br",{}),(0,n.jsxs)("span",{children:["RPM: ",l.rpm_limit?l.rpm_limit:"Unlimited"]})]})},{header:"Info",accessor:"info",cellRenderer:(e,l)=>{var s;return(0,n.jsx)("div",{className:"space-y-1",children:(0,n.jsxs)("div",{className:"text-sm",children:[(null===(s=l.members)||void 0===s?void 0:s.length)||0," Members"]})})}}],actions:c,emptyMessage:"No organizations available",deleteModal:{isOpen:r,onConfirm:()=>{o&&a&&a(o),i(!1),d(null)},onCancel:()=>{i(!1),d(null)},title:"Delete Organization",message:"Are you sure you want to delete this organization?"}})};var eY=e=>{let{accessToken:l,userID:s,userRole:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),{Title:d,Paragraph:c}=et.default,[x,p]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[f,y]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!l||!s||!t)return;let e=async()=>{try{let e=(await (0,m.So)(l,s,t)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}catch(e){console.error("Error fetching user models:",e)}},n=async()=>{let e;e=await (0,m.r6)(l),console.log("givenOrganizations: ".concat(e)),o(e),sessionStorage.setItem("organizations",JSON.stringify(e))};a&&(e(),n())},[l]);let _=async e=>{if(j&&l)try{let s={user_email:e.user_email,user_id:e.user_id,role:e.role};await (0,m.vh)(l,j.organization_id,s),w.ZP.success("Member added")}catch(e){console.error("Error creating the team:",e),w.ZP.error("Error creating the organization: "+e)}};return(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"✨ All Organizations"}),(0,n.jsxs)(Z.Z,{className:"mb-2",children:["This is a LiteLLM Enterprise feature, and requires a valid key to use. Get a trial key ",(0,n.jsx)("a",{href:"https://www.litellm.ai/#trial",className:"text-blue-600 hover:text-blue-800 underline",target:"_blank",rel:"noopener noreferrer",children:"here"})]}),t?eJ({organizations:i,userRole:t,isDeleteModalOpen:x,setIsDeleteModalOpen:p,selectedOrganization:j,setSelectedOrganization:g}):null]}),"Admin"==t&&l&&a?(0,n.jsx)(eB,{title:"Organization",accessToken:l,availableModels:f,submitButtonText:"Create Organization"}):null,a?(0,n.jsxs)(u.Z,{numColSpan:1,children:[(0,n.jsx)(d,{level:4,children:"Organization Members"}),(0,n.jsx)(c,{children:"If you belong to multiple organizations, this setting controls which organizations' members you see."}),i&&i.length>0?(0,n.jsx)(H.Z,{children:i.map((e,l)=>(0,n.jsx)(G.Z,{value:String(l),onClick:()=>{g(e)},children:e.organization_alias},l))}):(0,n.jsxs)(c,{children:["No team created. ",(0,n.jsx)("b",{children:"Defaulting to personal account."})]})]}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eK,{userRole:t,userID:s,selectedOrganization:j,onMemberAdd:_}):null,"Admin"==t&&s&&j&&a?(0,n.jsx)(eW,{selectedEntity:j,onEditSubmit:()=>{},editModalComponent:eG,entityType:"organization"}):null]})})},eX=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:a,premiumUser:o}=e,[d]=v.Z.useForm(),[c]=v.Z.useForm(),{Title:p,Paragraph:j}=et.default,[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)(null),[b,k]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[O,T]=(0,r.useState)(!1),[D,M]=(0,r.useState)(!1),[F,J]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,ea]=(0,r.useState)(!1),[en,er]=(0,r.useState)([]),[ei,eo]=(0,r.useState)(null),ed=(0,i.useRouter)(),[ec,em]=(0,r.useState)(null);console.log=function(){};let[eu,eh]=(0,r.useState)(""),ex="All IP Addresses Allowed";try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let ep=async()=>{try{if(!0!==o){w.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,m.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),w.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,m.eH)(t,e.ip);let l=await (0,m.PT)(t);er(l),w.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),w.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),ea(!0)},ef=async()=>{if(ei&&t)try{await (0,m.$I)(t,ei);let e=await (0,m.PT)(t);er(e.length>0?e:[ex]),w.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),w.ZP.error("Failed to delete IP address ".concat(e))}finally{ea(!1),eo(null)}},eZ=()=>{X(!1)},ey=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(ed){let{protocol:e,host:l}=window.location;eh("".concat(e,"//").concat(l))}},[ed]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,m.Xd)(t,"proxy_admin_viewer");console.log("proxy admin viewer response: ",l);let s=l.users;console.log("proxy viewers response: ".concat(s)),s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(s));let a=(await (0,m.Xd)(t,"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)),_(e),em(await (0,m.lg)(t))}})()},[t]);let e_=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(v.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,n.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,n.jsxs)(v.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,n.jsx)(H.Z,{value:l,children:ey.map((e,l)=>(0,n.jsx)(G.Z,{value:e,children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,n.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ek=async e=>{try{if(null!=t&&null!=y){w.ZP.info("Making API Call");let l=await (0,m.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),y.push(l),_(y)),w.ZP.success("Refresh tab to see updated user role"),M(!1)}}catch(e){console.error("Error creating the key:",e)}},eN=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call");let s=await (0,m.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)});let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=y){var l;w.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,m.pf)(t,e,"proxy_admin"),a=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,m.XO)(t,a).then(e=>{k(e),A(!0)}),console.log("response for team create call: ".concat(s));let n=y.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(a)),e.user_id===s.user_id));console.log("foundIndex: ".concat(n)),-1==n&&(console.log("updates admin with new user"),y.push(s),_(y)),d.resetFields(),T(!1)}}catch(e){console.error("Error creating the key:",e)}},eC=async e=>{if(null==t)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,m.K_)(t,l)};return console.log("admins: ".concat(null==y?void 0:y.length)),(0,n.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,n.jsx)(p,{level:4,children:"Admin Access "}),(0,n.jsxs)(j,{children:[a&&(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,n.jsx)("br",{}),(0,n.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(L.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Member Name"}),(0,n.jsx)(K.Z,{children:"Role"})]})}),(0,n.jsx)(V.Z,{children:y?y.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,n.jsxs)(B.Z,{children:[" ",(null==ec?void 0:null===(s=ec[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>M(!0)}),(0,n.jsx)(S.Z,{title:"Update role",visible:D,width:800,footer:null,onOk:e_,onCancel:eb,children:eS(ek,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)("div",{className:"flex justify-start",children:[(0,n.jsx)(x.Z,{className:"mr-4 mb-5",onClick:()=>T(!0),children:"+ Add admin"}),(0,n.jsx)(S.Z,{title:"Add admin",visible:O,width:800,footer:null,onOk:()=>{T(!1),c.resetFields(),d.resetFields()},onCancel:()=>{T(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,n.jsx)(eR,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,n.jsx)(x.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,n.jsx)(S.Z,{title:"Add viewer",visible:P,width:800,footer:null,onOk:()=>{E(!1),c.resetFields(),d.resetFields()},onCancel:()=>{E(!1),c.resetFields(),d.resetFields()},children:ev(eN)})]})})]}),(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(p,{level:4,children:" ✨ Security Settings"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:()=>!0===o?J(!0):w.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,n.jsx)("div",{children:(0,n.jsx)(x.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,n.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,n.jsx)(S.Z,{title:"Add SSO",visible:F,width:800,footer:null,onOk:()=>{J(!1),d.resetFields()},onCancel:()=>{J(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:e=>{eI(e),eC(e),J(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,n.jsx)(I.Z,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,n.jsx)(I.Z.Password,{})}),(0,n.jsx)(v.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,n.jsx)(I.Z.Password,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,n.jsxs)(S.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:eZ,onCancel:()=>{X(!1)},children:[(0,n.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,n.jsx)(Z.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{onClick:eZ,children:"Done"})})]}),(0,n.jsx)(S.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,n.jsx)(x.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"IP Address"}),(0,n.jsx)(K.Z,{className:"text-right",children:"Action"})]})}),(0,n.jsx)(V.Z,{children:en.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e}),(0,n.jsx)(B.Z,{className:"text-right",children:e!==ex&&(0,n.jsx)(x.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,n.jsx)(S.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,n.jsxs)(v.Z,{onFinish:ej,children:[(0,n.jsx)(v.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,n.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,n.jsx)(v.Z.Item,{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,n.jsx)(S.Z,{title:"Confirm Delete",visible:es,onCancel:()=>ea(!1),onOk:ef,footer:[(0,n.jsx)(x.Z,{className:"mx-1",onClick:()=>ef(),children:"Yes"},"delete"),(0,n.jsx)(x.Z,{onClick:()=>ea(!1),children:"Close"},"close")],children:(0,n.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,n.jsxs)(ew.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,n.jsxs)("a",{href:l,target:"_blank",children:[(0,n.jsx)("b",{children:l})," "]})]})]})]})},e$=s(92858),eQ=s(44643),e0=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:a,premiumUser:r}=e,[i]=v.Z.useForm();return(0,n.jsxs)(v.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{align:"center",children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,n.jsx)(v.Z.Item,{name:e.field_name,children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,n.jsx)(v.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,n.jsx)(B.Z,{children:"Integer"===e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,n.jsx)(e$.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,n.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,n.jsx)("div",{children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},e1=e=>{let{accessToken:l,premiumUser:s}=e,[t,a]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,m.RQ)(l).then(e=>{a(e)})},[l]),(0,n.jsx)(e0,{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:n,...r}=a;console.log("slack_alerting: ".concat(n,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,m.jA)(l,"alerting_args",r),"boolean"==typeof n&&(!0==n?(0,m.jA)(l,"alerting",["slack"]):(0,m.jA)(l,"alerting",[])),w.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},e2=s(86582);let{Title:e4,Paragraph:e5}=et.default;console.log=function(){};var e8=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[u,j]=(0,r.useState)(!1),[g]=v.Z.useForm(),[f,y]=(0,r.useState)(null),[_,k]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,O]=(0,r.useState)([]),[T,D]=(0,r.useState)(!1),[M,F]=(0,r.useState)([]),[H,J]=(0,r.useState)(null),[Y,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),es=e=>{E.includes(e)?O(E.filter(l=>l!==e)):O([...E,e])},et={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,r.useEffect)(()=>{l&&s&&t&&(0,m.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),F(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),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ea=e=>E&&E.includes(e),en=()=>{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,m.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Email settings updated successfully")},er=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,m.K_)(l,{environment_variables:s}),w.ZP.success("Callback added successfully"),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eu=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,m.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),w.ZP.success("Callback ".concat(s," added successfully")),j(!1),g.resetFields(),y(null)}catch(e){w.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),y(e.litellm_callback_name),console.log("all callbacks",M),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",Y)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,n.jsxs)("div",{className:"w-full mx-4",children:[(0,n.jsx)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Logging Callbacks"}),(0,n.jsx)(ei.Z,{value:"2",children:"Alerting Types"}),(0,n.jsx)(ei.Z,{value:"3",children:"Alerting Settings"}),(0,n.jsx)(ei.Z,{value:"4",children:"Email Alerts"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsxs)(ec.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Active Logging Callbacks"}),(0,n.jsx)(h.Z,{numItems:2,children:(0,n.jsx)(L.Z,{className:"max-h-[50vh]",children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(K.Z,{children:"Callback Name"})})}),(0,n.jsx)(V.Z,{children:i.map((e,s)=>(0,n.jsxs)(W.Z,{className:"flex justify-between",children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.name})}),(0,n.jsx)(B.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"flex justify-between",children:[(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>D(!0),children:"Add Callback"})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(Z.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,n.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{}),(0,n.jsx)(K.Z,{children:"Slack Webhook URL"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:"region_outage_alerts"==s?a?(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)}):(0,n.jsx)(x.Z,{className:"flex items-center justify-center",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,n.jsx)(e$.Z,{id:"switch",name:"switch",checked:ea(s),onChange:()=>es(s)})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:t})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,n.jsx)(x.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,a=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",a);let n=(null==a?void 0:a.value)||"";console.log("newWebhookValue",n),e[s]=n}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,m.K_)(l,s)}catch(e){w.ZP.error("Failed to update alerts: "+e,20)}w.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(e1,{accessToken:l,premiumUser:a})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(e4,{level:4,children:"Email Settings"}),(0,n.jsxs)(Z.Z,{children:[(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,n.jsx)("br",{})]}),(0,n.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,n.jsx)(B.Z,{children:(0,n.jsx)("ul",{children:(0,n.jsx)(h.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,n.jsxs)("li",{className:"mx-2 my-2",children:[!0!=a&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,n.jsxs)("div",{children:[(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,n.jsxs)(Z.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)(Z.Z,{className:"mt-2",children:l}),(0,n.jsx)(p.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,n.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,n.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,n.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,n.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,n.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,n.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,n.jsx)(x.Z,{className:"mt-2",onClick:()=>en(),children:"Save Changes"}),(0,n.jsx)(x.Z,{onClick:()=>(0,m.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,n.jsxs)(S.Z,{title:"Add Logging Callback",visible:T,width:800,onCancel:()=>D(!1),footer:null,children:[(0,n.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,n.jsx)(v.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e2.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,n.jsx)(b.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,n.jsx)(G.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,n.jsx)(e2.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,n.jsx)(p.Z,{type:"password"})},e)),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,n.jsx)(S.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,n.jsxs)(v.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsx)(n.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,n.jsx)(e2.Z,{label:l,name:l,children:(0,n.jsx)(p.Z,{type:"password",defaultValue:s})},l)})}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:e3}=b.default;var e6=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:a}=e,[i]=v.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,n.jsx)(S.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,n.jsxs)(v.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:n}=e,r=[...t.fallbacks||[],{[l]:n}],o={...t,fallbacks:r};console.log(o);try{(0,m.K_)(s,{router_settings:o}),a(o)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,n.jsx)(H.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,n.jsx)(G.Z,{value:e,onClick:()=>u(e),children:e},l))})}),(0,n.jsx)(v.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,n.jsx)(eu.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},e7=s(33619);async function e9(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new e7.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});w.ZP.success((0,n.jsxs)("span",{children:["Test model=",(0,n.jsx)("strong",{children:e}),", received model=",(0,n.jsx)("strong",{children:l.model}),". See"," ",(0,n.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let le={ttl:3600,lowest_latency_buffer:0},ll=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,n.jsx)(g.Z,{children:"latency-based-routing"==l?(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,n.jsx)(Z.Z,{children:"No specific settings"})})]})};var ls=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)(!1),[b]=v.Z.useForm(),[S,k]=(0,r.useState)(null),[I,C]=(0,r.useState)(null),[A,P]=(0,r.useState)(null),E={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,m.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,m.YU)(l).then(e=>{g(e)}))},[l,s,t]);let O=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,m.K_)(l,{router_settings:i}),o({...i}),C(i.routing_strategy),w.ZP.success("Router settings updated successfully")}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}}},T=(e,l)=>{g(j.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=j[s].field_value;if(null!=t&&void 0!=t)try{(0,m.jA)(l,e,t);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},D=(e,s)=>{if(l)try{(0,m.ao)(l,e);let s=j.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},J=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,I];if("routing_strategy_args"==l&&"latency-based-routing"==I){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,m.K_)(l,{router_settings:s})}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("router settings updated successfully")};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsxs)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,n.jsxs)(ed.Z,{variant:"line",defaultValue:"1",children:[(0,n.jsx)(ei.Z,{value:"1",children:"Loadbalancing"}),(0,n.jsx)(ei.Z,{value:"2",children:"Fallbacks"}),(0,n.jsx)(ei.Z,{value:"3",children:"General"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,n.jsx)(y.Z,{children:"Router Settings"}),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"})]})}),(0,n.jsx)(V.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,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:l}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,n.jsx)(B.Z,{children:"routing_strategy"==l?(0,n.jsxs)(H.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:C,children:[(0,n.jsx)(G.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,n.jsx)(G.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,n.jsx)(G.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,n.jsx)(p.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,n.jsx)(ll,{selectedStrategy:I,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:le,paramExplanation:E})]}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(x.Z,{className:"mt-2",onClick:()=>J(i),children:"Save Changes"})})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Model Name"}),(0,n.jsx)(K.Z,{children:"Fallbacks"})]})}),(0,n.jsx)(V.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,a]=e;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:t}),(0,n.jsx)(B.Z,{children:Array.isArray(a)?a.join(", "):a}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(x.Z,{onClick:()=>e9(t,l),children:"Test Fallback"})}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>O(t)})})]},s.toString()+t)}))})]}),(0,n.jsx)(e6,{models:(null==a?void 0:a.data)?a.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,n.jsx)(ec.Z,{children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Setting"}),(0,n.jsx)(K.Z,{children:"Value"}),(0,n.jsx)(K.Z,{children:"Status"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:j.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(Z.Z,{children:e.field_name}),(0,n.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,n.jsx)(B.Z,{children:"Integer"==e.field_type?(0,n.jsx)(N.Z,{step:1,value:e.field_value,onChange:l=>T(e.field_name,l)}):null}),(0,n.jsx)(B.Z,{children:!0==e.stored_in_db?(0,n.jsx)(F.Z,{icon:eQ.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,n.jsx)(F.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,n.jsxs)(B.Z,{children:[(0,n.jsx)(x.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>D(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lt=s(93142),la=s(45246),ln=s(96473),lr=e=>{let{value:l={},onChange:s}=e,[t,a]=(0,r.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,n)=>{let r=[...t];r[e]=[l,n],a(r),null==s||s(Object.fromEntries(r))};return(0,n.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,n.jsxs)(lt.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,n.jsx)(p.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,n.jsx)(p.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,n.jsx)(la.Z,{onClick:()=>i(l)})]},l)}),(0,n.jsx)(C.ZP,{type:"dashed",onClick:()=>{a([...t,["",""]])},icon:(0,n.jsx)(ln.Z,{}),children:"Add Header"})]})};let{Option:li}=b.default;var lo=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[a]=v.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,n.jsxs)("div",{children:[(0,n.jsx)(x.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,n.jsx)(S.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),a.resetFields()},onCancel:()=>{o(!1),a.resetFields()},children:(0,n.jsxs)(v.Z,{form:a,onFinish:e=>{console.log(e);let n=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,m.Vt)(l,e),s(n)}catch(e){w.ZP.error("Failed to update router settings: "+e,20)}w.ZP.success("Pass through endpoint successfully added"),o(!1),a.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(p.Z,{})}),(0,n.jsx)(v.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,n.jsx)(lr,{})})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},ld=e=>{let{accessToken:l,userRole:s,userID:t,modelData:a}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,m.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,m.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),w.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,n.jsx)("div",{className:"w-full mx-4",children:(0,n.jsx)(eo.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Path"}),(0,n.jsx)(K.Z,{children:"Target"}),(0,n.jsx)(K.Z,{children:"Headers"}),(0,n.jsx)(K.Z,{children:"Action"})]})}),(0,n.jsx)(V.Z,{children:i.map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:(0,n.jsx)(Z.Z,{children:e.path})}),(0,n.jsx)(B.Z,{children:e.target}),(0,n.jsx)(B.Z,{children:JSON.stringify(e.headers)}),(0,n.jsx)(B.Z,{children:(0,n.jsx)(U.Z,{icon:M.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,n.jsx)(lo,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},lc=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a}=e,[r]=v.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call");let l=await (0,m.Zr)(s,e);console.log("key create Response:",l),a(e=>e?[...e,l]:[l]),w.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,n.jsxs)(v.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lm=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:a,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=v.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{w.ZP.info("Making API Call"),t(!0);let l=await (0,m.qI)(s,e);a(e=>e?[...e,l]:[l]),w.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),w.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.jsx)(S.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,n.jsxs)(v.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.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,n.jsx)(p.Z,{placeholder:""})}),(0,n.jsx)(v.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,n.jsx)(N.Z,{step:1,precision:2,width:200})}),(0,n.jsxs)(j.Z,{className:"mt-20 mb-8",children:[(0,n.jsx)(f.Z,{children:(0,n.jsx)("b",{children:"Optional Settings"})}),(0,n.jsxs)(g.Z,{children:[(0,n.jsx)(v.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,n.jsx)(N.Z,{step:.01,precision:2,width:200})}),(0,n.jsx)(v.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,n.jsxs)(b.default,{defaultValue:null,placeholder:"n/a",children:[(0,n.jsx)(b.default.Option,{value:"24h",children:"daily"}),(0,n.jsx)(b.default.Option,{value:"7d",children:"weekly"}),(0,n.jsx)(b.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,n.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,n.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},lu=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[a,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,u]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,m.O3)(l).then(e=>{u(e)})},[l]);let h=async(e,s)=>{console.log("budget_id",e),null!=l&&(d(c.find(l=>l.budget_id===e)||null),i(!0))},p=async(e,s)=>{if(null==l)return;w.ZP.info("Request made"),await (0,m.NV)(l,e);let t=[...c];t.splice(s,1),u(t),w.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,m.O3)(l).then(e=>{u(e)})};return(0,n.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,n.jsx)(x.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,n.jsx)(lc,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:u}),o&&(0,n.jsx)(lm,{accessToken:l,isModalVisible:a,setIsModalVisible:i,setBudgetList:u,existingBudget:o,handleUpdateCall:j}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(Z.Z,{children:"Create a budget to assign to customers."}),(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Budget ID"}),(0,n.jsx)(K.Z,{children:"Max Budget"}),(0,n.jsx)(K.Z,{children:"TPM"}),(0,n.jsx)(K.Z,{children:"RPM"})]})}),(0,n.jsx)(V.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.budget_id}),(0,n.jsx)(B.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,n.jsx)(B.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,n.jsx)(B.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,n.jsx)(U.Z,{icon:R.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,n.jsx)(U.Z,{icon:M.Z,size:"sm",onClick:()=>p(e.budget_id,l)})]},l))})]})]}),(0,n.jsxs)("div",{className:"mt-5",children:[(0,n.jsx)(Z.Z,{className:"text-base",children:"How to use budget id"}),(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"Assign Budget to Customer"}),(0,n.jsx)(ei.Z,{children:"Test it (Curl)"}),(0,n.jsx)(ei.Z,{children:"Test it (OpenAI SDK)"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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)'})})]})]})]})]})},lh=s(77398),lx=s.n(lh),lp=s(24525),lj=s(71594);let lg=e=>e?"string"==typeof e?e:"object"==typeof e?e.text?e.text:e.content?e.content:JSON.stringify(e):String(e):"N/A",lf=e=>{let{data:l}=e,s=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e};return(0,n.jsxs)("div",{className:"p-6 bg-gray-50 space-y-6",children:[(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Request"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.request),null,2)})]}),(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Response"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"mr-2 px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Expand"}),(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})]})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(s(l.response),null,2)})]}),l.metadata&&Object.keys(l.metadata).length>0&&(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,n.jsx)("h3",{className:"text-lg font-medium",children:"Metadata"}),(0,n.jsx)("div",{children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"JSON"})})]}),(0,n.jsx)("pre",{className:"p-4 overflow-auto text-sm",children:JSON.stringify(l.metadata,null,2)})]})]})};var lZ=e=>{let{accessToken:l,token:s,userRole:t,userID:a}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)(!0),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(null);(0,lp.Cl)();let j=[{header:"Time",accessorKey:"startTime",cell:e=>(0,n.jsx)("span",{children:lx()(e.getValue()).format("MMM DD HH:mm:ss")})},{header:"Request ID",accessorKey:"request_id",cell:e=>(0,n.jsx)("span",{className:"font-mono text-xs",children:String(e.getValue()||"")})},{header:"Type",accessorKey:"call_type",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Request",accessorKey:"messages",cell:e=>{let l=e.getValue();try{let e="string"==typeof l?JSON.parse(l):l,t="";if(Array.isArray(e)){var s;t=lg(null===(s=e[0])||void 0===s?void 0:s.content)}else t=lg(e);return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:t})}catch(e){return(0,n.jsx)("span",{className:"truncate max-w-md text-sm",children:lg(l)})}}},{header:"Model",accessorKey:"model",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"")})},{header:"Tokens",accessorKey:"total_tokens",cell:e=>{let l=e.row.original;return(0,n.jsxs)("span",{className:"text-sm",children:[String(l.total_tokens||"0"),(0,n.jsxs)("span",{className:"text-gray-400 text-xs ml-1",children:["(",String(l.prompt_tokens||"0"),"+",String(l.completion_tokens||"0"),")"]})]})}},{header:"User",accessorKey:"user",cell:e=>(0,n.jsx)("span",{children:String(e.getValue()||"-")})},{header:"Cost",accessorKey:"spend",cell:e=>(0,n.jsxs)("span",{children:["$",Number(e.getValue()||0).toFixed(6)]})},{header:"Tags",accessorKey:"request_tags",cell:e=>{let l=e.getValue();return l&&0!==Object.keys(l).length?(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(l).map(e=>{let[l,s]=e;return(0,n.jsxs)("span",{className:"px-2 py-1 bg-gray-100 rounded-full text-xs",children:[l,": ",String(s)]},l)})}):"-"}}];return((0,lj.b7)({data:i,columns:j,state:{sorting:u},onSortingChange:h,getCoreRowModel:(0,lp.sC)(),getSortedRowModel:(0,lp.tj)()}),(0,r.useEffect)(()=>{(async()=>{if(!l||!s||!t||!a){console.log("got None values for one of accessToken, token, userRole, userID");return}try{c(!0);let e=lx()().format("YYYY-MM-DD HH:mm:ss"),n=lx()().subtract(24,"hours").format("YYYY-MM-DD HH:mm:ss"),r=await (0,m.h3)(l,s,t,a,n,e);console.log("response from uiSpendLogsCall:",r);let i=r.map((e,l)=>({...e,key:l.toString()}));o(i)}catch(e){console.error("Error fetching logs:",e)}finally{c(!1)}})()},[l,s,t,a]),l&&s&&t&&a)?(0,n.jsx)("div",{className:"w-[90%] mx-auto px-4",children:(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow w-full",children:[(0,n.jsxs)("div",{className:"p-4 border-b flex justify-between items-center",children:[(0,n.jsxs)("div",{className:"flex space-x-4 items-center",children:[(0,n.jsx)("input",{type:"text",placeholder:"Search by request ID, model, or user...",className:"px-4 py-2 border rounded-lg w-80"}),(0,n.jsxs)("button",{className:"px-4 py-2 border rounded-lg flex items-center gap-2",children:[(0,n.jsx)("span",{children:"Filters"}),(0,n.jsx)("span",{className:"text-xs bg-gray-100 px-2 py-1 rounded",children:"0"})]}),(0,n.jsxs)("select",{className:"px-4 py-2 border rounded-lg",children:[(0,n.jsx)("option",{children:"Last 24 hours"}),(0,n.jsx)("option",{children:"Last 7 days"}),(0,n.jsx)("option",{children:"Last 30 days"})]})]}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("button",{className:"px-3 py-1 text-sm border rounded hover:bg-gray-50",children:"Export"})})]}),(0,n.jsx)("div",{className:"overflow-x-auto w-full",children:i.length>0?(0,n.jsxs)(z.Z,{className:"w-full table-fixed",children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:j.map(e=>(0,n.jsx)(K.Z,{className:"".concat("Request ID"===e.header?"w-32":""," whitespace-nowrap"),children:e.header},e.header))})}),(0,n.jsx)(V.Z,{children:i.map(e=>(0,n.jsxs)(r.Fragment,{children:[(0,n.jsx)(W.Z,{className:"cursor-pointer hover:bg-gray-50",onClick:()=>p(x===e.request_id?null:e.request_id),children:j.map(l=>{var s;return(0,n.jsx)(B.Z,{className:"Request ID"===l.header?"w-32 truncate":"",children:l.cell?l.cell({getValue:()=>e[l.accessorKey],row:{original:e}}):(0,n.jsx)("span",{children:String(null!==(s=e[l.accessorKey])&&void 0!==s?s:"")})},l.header)})}),x===e.request_id&&(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{colSpan:j.length,className:"p-0",children:(0,n.jsx)(lf,{data:{request:"string"==typeof e.messages?JSON.parse(e.messages):e.messages,response:"string"==typeof e.response?JSON.parse(e.response):e.response,metadata:e.metadata}})})})]},e.request_id||e.startTime))})]}):(0,n.jsxs)("div",{className:"p-8 text-center text-gray-500",children:[(0,n.jsx)("p",{children:"No SpendLogs messages available."}),(0,n.jsxs)("p",{className:"text-sm mt-2",children:["To enable this, set ",(0,n.jsx)("code",{children:"`general_settings.store_prompts_in_spend_logs: true`"})," in your config.yaml"]})]})})]})}):(console.log("got None values for one of accessToken, token, userRole, userID"),null)},ly=s(92699),l_=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,n.jsx)(Z.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,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ei.Z,{children:"OpenAI Python SDK"}),(0,n.jsx)(ei.Z,{children:"LlamaIndex"}),(0,n.jsx)(ei.Z,{children:"Langchain Py"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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,n.jsx)(ec.Z,{children:(0,n.jsx)(eI.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 ')})})]})]})]})})})},lb=s(243),lv=s(94263);async function lw(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let a=window.location.origin,n=new e7.ZP.OpenAI({apiKey:t,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let t of(await n.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){w.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lS=e=>{let{accessToken:l,token:s,userRole:t,userID:a,disabledPersonalKeyCreation:i}=e,[o,d]=(0,r.useState)(i?"custom":"session"),[c,j]=(0,r.useState)(""),[g,f]=(0,r.useState)(""),[y,_]=(0,r.useState)([]),[v,S]=(0,r.useState)(void 0),[k,N]=(0,r.useState)([]),I=(0,r.useRef)(null);(0,r.useEffect)(()=>{l&&s&&t&&a&&(async()=>{try{let e=await (0,m.So)(l,a,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=new Map;e.data.forEach(e=>{l.set(e.id,{value:e.id,label:e.id})});let s=Array.from(l.values());s.sort((e,l)=>e.label.localeCompare(l.label)),N(s),S(s[0].value)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,a,t]),(0,r.useEffect)(()=>{I.current&&setTimeout(()=>{var e;null===(e=I.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"end"})},100)},[y]);let C=(e,l,s)=>{_(t=>{let a=t[t.length-1];return a&&a.role===e?[...t.slice(0,t.length-1),{role:e,content:a.content+l,model:s}]:[...t,{role:e,content:l,model:s}]})},A=async()=>{if(""===g.trim()||!s||!t||!a)return;let e="session"===o?l:c;if(!e){w.ZP.error("Please provide an API key or select Current UI Session");return}let n=[...y,{role:"user",content:g}];_(n);try{v&&await lw(n,(e,l)=>C("assistant",e,l),v,e)}catch(e){console.error("Error fetching model response",e),C("assistant","Error fetching model response")}f("")};if(t&&"Admin Viewer"===t){let{Title:e,Paragraph:l}=et.default;return(0,n.jsxs)("div",{children:[(0,n.jsx)(e,{level:1,children:"Access Denied"}),(0,n.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,n.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,n.jsx)(h.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,n.jsx)(L.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsx)(ed.Z,{children:(0,n.jsx)(ei.Z,{children:"Chat"})}),(0,n.jsx)(em.Z,{children:(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)("div",{className:"sm:max-w-2xl",children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"API Key Source"}),(0,n.jsx)(b.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,n.jsx)(p.Z,{className:"mt-2",placeholder:"Enter custom API key",type:"password",onValueChange:j,value:c})]}),(0,n.jsxs)(u.Z,{className:"mx-2",children:[(0,n.jsx)(Z.Z,{children:"Select Model:"}),(0,n.jsx)(b.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),S(e)},options:k,style:{width:"350px"},showSearch:!0})]})]}),(0,n.jsx)(x.Z,{onClick:()=>{_([]),w.ZP.success("Chat history cleared.")},className:"mt-4",children:"Clear Chat"})]}),(0,n.jsxs)(z.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,n.jsx)(q.Z,{children:(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{})})}),(0,n.jsxs)(V.Z,{children:[y.map((e,l)=>(0,n.jsx)(W.Z,{children:(0,n.jsxs)(B.Z,{children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,n.jsx)("strong",{children:e.role}),"assistant"===e.role&&e.model&&(0,n.jsx)("span",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f5f5f5",padding:"2px 6px",borderRadius:"4px",fontWeight:"normal"},children:e.model})]}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"100%"},children:(0,n.jsx)(lb.U,{components:{code(e){let{node:l,inline:s,className:t,children:a,...r}=e,i=/language-(\w+)/.exec(t||"");return!s&&i?(0,n.jsx)(eI.Z,{style:lv.Z,language:i[1],PreTag:"div",...r,children:String(a).replace(/\n$/,"")}):(0,n.jsx)("code",{className:t,...r,children:a})}},children:e.content})})]})},l)),(0,n.jsx)(W.Z,{children:(0,n.jsx)(B.Z,{children:(0,n.jsx)("div",{ref:I,style:{height:"1px"}})})})]})]}),(0,n.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,n.jsxs)("div",{className:"flex",style:{marginTop:"16px"},children:[(0,n.jsx)(p.Z,{type:"text",value:g,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"Type your message..."}),(0,n.jsx)(x.Z,{onClick:A,className:"ml-2",children:"Send"})]})})]})})]})})})})},lk=s(19226),lN=s(61787),lI=s(92403),lC=s(28595),lA=s(68208),lP=s(9775),lE=s(41361),lO=s(37527),lT=s(15883),lR=s(12660),lD=s(88009),lM=s(41169),lF=s(48231),lL=s(44625),lU=s(55322);let{Sider:lz}=lk.default,lV=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lB=[{key:"1",page:"api-keys",label:"Virtual Keys",icon:(0,n.jsx)(lI.Z,{})},{key:"3",page:"llm-playground",label:"Test Key",icon:(0,n.jsx)(lC.Z,{})},{key:"2",page:"models",label:"Models",icon:(0,n.jsx)(lA.Z,{}),roles:lV},{key:"4",page:"usage",label:"Usage",icon:(0,n.jsx)(lP.Z,{})},{key:"6",page:"teams",label:"Teams",icon:(0,n.jsx)(lE.Z,{})},{key:"17",page:"organizations",label:"Organizations",icon:(0,n.jsx)(lO.Z,{}),roles:lV},{key:"5",page:"users",label:"Internal Users",icon:(0,n.jsx)(lT.Z,{}),roles:lV},{key:"14",page:"api_ref",label:"API Reference",icon:(0,n.jsx)(lR.Z,{})},{key:"16",page:"model-hub",label:"Model Hub",icon:(0,n.jsx)(lD.Z,{})},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,n.jsx)(lM.Z,{}),roles:lV,children:[{key:"15",page:"logs",label:"Logs",icon:(0,n.jsx)(lF.Z,{}),roles:lV},{key:"9",page:"caching",label:"Caching",icon:(0,n.jsx)(lL.Z,{}),roles:lV},{key:"10",page:"budgets",label:"Budgets",icon:(0,n.jsx)(lO.Z,{}),roles:lV}]},{key:"settings",page:"settings",label:"Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV,children:[{key:"11",page:"general-settings",label:"Router Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"12",page:"pass-through-settings",label:"Pass-Through",icon:(0,n.jsx)(lR.Z,{}),roles:lV},{key:"8",page:"settings",label:"Logging & Alerts",icon:(0,n.jsx)(lU.Z,{}),roles:lV},{key:"13",page:"admin-panel",label:"Admin Settings",icon:(0,n.jsx)(lU.Z,{}),roles:lV}]}];var lq=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,a=(e=>{let l=lB.find(l=>l.page===e);if(l)return l.key;for(let l of lB)if(l.children){let s=l.children.find(l=>l.page===e);if(s)return s.key}return"1"})(t),r=lB.filter(e=>!e.roles||e.roles.includes(s));return(0,n.jsx)(lk.default,{style:{minHeight:"100vh"},children:(0,n.jsx)(lz,{theme:"light",width:220,children:(0,n.jsx)(lN.Z,{mode:"inline",selectedKeys:[a],style:{borderRight:0,backgroundColor:"transparent",fontSize:"14px"},items:r.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)}}})})})})},lK=s(96889),lW=s(14042);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lH=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lG=e=>{let{accessToken:l,token:s,userRole:t,userID:a,keys:i,premiumUser:o}=e,d=new Date,[c,p]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[f,_]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[w,S]=(0,r.useState)([]),[k,N]=(0,r.useState)([]),[I,C]=(0,r.useState)([]),[A,P]=(0,r.useState)([]),[E,O]=(0,r.useState)([]),[T,R]=(0,r.useState)([]),[D,M]=(0,r.useState)({}),[F,U]=(0,r.useState)([]),[J,Y]=(0,r.useState)(""),[X,Q]=(0,r.useState)(["all-tags"]),[ee,el]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[es,et]=(0,r.useState)(null),ea=new Date(d.getFullYear(),d.getMonth(),1),ej=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(ea),ef=ev(ej);function eZ(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 ey=async()=>{if(l)try{let e=await (0,m.g)(l);return console.log("usage tab: proxy_settings",e),e}catch(e){console.error("Error fetching proxy settings:",e)}};(0,r.useEffect)(()=>{eb(ee.from,ee.to)},[ee,X]);let e_=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,m.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",a),v(a)},eb=async(e,s)=>{if(!e||!s||!l)return;let t=await ey();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,m.J$)(l,e.toISOString(),s.toISOString(),0===X.length?void 0:X)).spend_per_tag),console.log("Tag spend data updated successfully"))};function ev(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(eg)),console.log("End date is ".concat(ef));let ew=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},eS=()=>ew(()=>l?(0,m.FC)(l):Promise.reject("No access token"),p,"Error fetching overall spend"),ek=()=>ew(()=>l&&s?(0,m.OU)(l,s,eg,ef):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await ew(async()=>(await (0,m.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend})),g,"Error fetching top keys")},eI=async()=>{l&&await ew(async()=>(await (0,m.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),_,"Error fetching top models")},eC=async()=>{l&&await ew(async()=>{let e=await (0,m.mR)(l);return S(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},O,"Error fetching team spend")},eA=()=>{l&&ew(async()=>(await (0,m.X)(l)).tag_names,C,"Error fetching tag names")},eP=()=>{l&&ew(()=>{var e,s;return(0,m.J$)(l,null===(e=ee.from)||void 0===e?void 0:e.toISOString(),null===(s=ee.to)||void 0===s?void 0:s.toISOString(),void 0)},e=>N(e.spend_per_tag),"Error fetching top tags")},eE=()=>{l&&ew(()=>(0,m.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eO=()=>{l&&ew(()=>(0,m.wd)(l,eg,ef),M,"Error fetching global activity")},eT=()=>{l&&ew(()=>(0,m.xA)(l,eg,ef),U,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&a){let e=await ey();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),eS(),ek(),eN(),eI(),eO(),eT(),lH(t)&&(eC(),eA(),eP(),eE()))}})()},[l,s,t,a,eg,ef]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,n.jsxs)(Z.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,n.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,n.jsx)(x.Z,{className:"mt-4",children:(0,n.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,n.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{className:"mt-2",children:[(0,n.jsx)(ei.Z,{children:"All Up"}),lH(t)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ei.Z,{children:"Team Based Usage"}),(0,n.jsx)(ei.Z,{children:"Customer Usage"}),(0,n.jsx)(ei.Z,{children:"Tag Based Usage"})]}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{})})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(eo.Z,{children:[(0,n.jsxs)(ed.Z,{variant:"solid",className:"mt-1",children:[(0,n.jsx)(ei.Z,{children:"Cost"}),(0,n.jsx)(ei.Z,{children:"Activity"})]}),(0,n.jsxs)(em.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,n.jsx)($,{userID:a,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Monthly Spend"}),(0,n.jsx)(ep.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top API Keys"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Top Models"}),(0,n.jsx)(ep.Z,{className:"mt-4 h-40",data:f,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,n.jsx)(u.Z,{numColSpan:1}),(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(lW.Z,{className:"mt-4 h-40",variant:"pie",data:T,index:"provider",category:"spend"})}),(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsxs)(z.Z,{children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Provider"}),(0,n.jsx)(K.Z,{children:"Spend"})]})}),(0,n.jsx)(V.Z,{children:T.map(e=>(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.provider}),(0,n.jsx)(B.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"All Up"}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(D.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(D.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:D.daily_data,valueFormatter:eZ,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,n.jsx)(n.Fragment,{children:F.map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,n.jsx)(n.Fragment,{children:F&&F.length>0&&F.slice(0,1).map((e,l)=>(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,n.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,n.jsx)(x.Z,{variant:"primary",className:"mb-2",children:(0,n.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:e.model}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eZ(e.sum_api_requests)]}),(0,n.jsx)(ex.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eZ,onValueChange:e=>console.log(e)})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(en.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eZ(e.sum_total_tokens)]}),(0,n.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eZ,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,n.jsxs)(u.Z,{numColSpan:2,children:[(0,n.jsxs)(L.Z,{className:"mb-2",children:[(0,n.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,n.jsx)(lK.Z,{data:E})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,n.jsx)(ep.Z,{className:"h-72",data:w,showLegend:!0,index:"date",categories:A,yAxisWidth:80,stack:!0})]})]}),(0,n.jsx)(u.Z,{numColSpan:2})]})}),(0,n.jsxs)(ec.Z,{children:[(0,n.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,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Time Range"}),(0,n.jsx)(er.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),e_(e.from,e.to,null)}})]}),(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{children:"Select Key"}),(0,n.jsxs)(H.Z,{defaultValue:"all-keys",children:[(0,n.jsx)(G.Z,{value:"all-keys",onClick:()=>{e_(ee.from,ee.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,n.jsx)(G.Z,{value:String(l),onClick:()=>{e_(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,n.jsx)(L.Z,{className:"mt-4",children:(0,n.jsxs)(z.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,n.jsx)(q.Z,{children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(K.Z,{children:"Customer"}),(0,n.jsx)(K.Z,{children:"Spend"}),(0,n.jsx)(K.Z,{children:"Total Events"})]})}),(0,n.jsx)(V.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(B.Z,{children:e.end_user}),(0,n.jsx)(B.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,n.jsx)(B.Z,{children:e.total_count})]},l)})})]})})]}),(0,n.jsxs)(ec.Z,{children:[(0,n.jsxs)(h.Z,{numItems:2,children:[(0,n.jsx)(u.Z,{numColSpan:1,children:(0,n.jsx)(er.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,n.jsx)(u.Z,{children:o?(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsx)(eh.Z,{value:String(e),children:e},e))]})}):(0,n.jsx)("div",{children:(0,n.jsxs)(eu.Z,{value:X,onValueChange:e=>Q(e),children:[(0,n.jsx)(eh.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,n.jsxs)(G.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,n.jsxs)(h.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,n.jsx)(u.Z,{numColSpan:2,children:(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(y.Z,{children:"Spend Per Tag"}),(0,n.jsxs)(Z.Z,{children:["Get Started Tracking cost per tag ",(0,n.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,n.jsx)(ep.Z,{className:"h-72",data:k,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,n.jsx)(u.Z,{numColSpan:2})]})]})]})]})})};let lJ=e=>{if(e)return e.toISOString().split("T")[0]};function lY(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lX=e=>{let{accessToken:l,token:s,userRole:t,userID:a,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,x]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,f]=(0,r.useState)([]),[Z,y]=(0,r.useState)("0"),[_,b]=(0,r.useState)("0"),[v,w]=(0,r.useState)("0"),[S,k]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&S&&(async()=>{f(await (0,m.zg)(l,lJ(S.from),lJ(S.to)))})()},[l]);let N=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.api_key)&&void 0!==l?l:""}))),I=Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.model)&&void 0!==l?l:""})));Array.from(new Set(g.map(e=>{var l;return null!==(l=null==e?void 0:e.call_type)&&void 0!==l?l:""})));let C=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),f(await (0,m.zg)(l,lJ(e),lJ(s))))};return(0,r.useEffect)(()=>{console.log("DATA IN CACHE DASHBOARD",g);let e=g;c.length>0&&(e=e.filter(e=>c.includes(e.api_key))),p.length>0&&(e=e.filter(e=>p.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 n=e.find(e=>e.name===a.call_type);return n?(n["LLM API requests"]+=(a.total_rows||0)-(a.cache_hit_true_rows||0),n["Cache hit"]+=a.cache_hit_true_rows||0,n["Cached Completion Tokens"]+=a.cached_completion_tokens||0,n["Generated Completion Tokens"]+=a.generated_completion_tokens||0):e.push({name:a.call_type,"LLM API requests":(a.total_rows||0)-(a.cache_hit_true_rows||0),"Cache hit":a.cache_hit_true_rows||0,"Cached Completion Tokens":a.cached_completion_tokens||0,"Generated Completion Tokens":a.generated_completion_tokens||0}),e},[]);y(lY(s)),b(lY(t));let n=s+l;n>0?w((s/n*100).toFixed(2)):w("0"),d(a),console.log("PROCESSED DATA IN CACHE DASHBOARD",a)},[c,p,S,g]),(0,n.jsxs)(L.Z,{children:[(0,n.jsxs)(h.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select API Keys",value:c,onValueChange:x,children:N.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(eu.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,n.jsx)(eh.Z,{value:e,children:e},e))})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(er.Z,{enableSelect:!0,value:S,onValueChange:e=>{k(e),C(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:Z})})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,n.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,n.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:_})})]})]}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,n.jsx)(ep.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,n.jsx)(en.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,n.jsx)(ep.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lY,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l$=()=>{let{Title:e,Paragraph:l}=et.default,[s,t]=(0,r.useState)(""),[a,o]=(0,r.useState)(!1),[d,u]=(0,r.useState)(!1),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,f]=(0,r.useState)(null),[Z,y]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[_,b]=(0,r.useState)(!0),v=(0,i.useSearchParams)(),[w,S]=(0,r.useState)({data:[]}),[k,N]=(0,r.useState)(null),I=v.get("userID"),C=v.get("invitation_id"),[A,P]=(0,r.useState)(()=>v.get("page")||"api-keys"),[E,O]=(0,r.useState)(null);return(0,r.useEffect)(()=>{N(function(e){let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"))},[]),(0,r.useEffect)(()=>{if(!k)return;let e=(0,es.o)(k);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),O(e.key),u(e.disabled_non_admin_personal_key_creation),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&P("usage")}else console.log("User role not defined");e.user_email?x(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?b("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user),e.auth_header_name&&(0,m.K8)(e.auth_header_name)}},[k]),(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)("div",{children:"Loading..."}),children:C?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):(0,n.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,n.jsx)(c,{userID:I,userRole:s,userEmail:h,premiumUser:a,setProxySettings:y,proxySettings:Z}),(0,n.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,n.jsx)("div",{className:"mt-8",children:(0,n.jsx)(lq,{setPage:e=>{let l=new URLSearchParams(v);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),P(e)},userRole:s,defaultSelectedKey:A})}),"api-keys"==A?(0,n.jsx)(ea,{userID:I,userRole:s,premiumUser:a,teams:p,keys:g,setUserRole:t,userEmail:h,setUserEmail:x,setTeams:j,setKeys:f}):"models"==A?(0,n.jsx)(eT,{userID:I,userRole:s,token:k,keys:g,accessToken:E,modelData:w,setModelData:S,premiumUser:a}):"llm-playground"==A?(0,n.jsx)(lS,{userID:I,userRole:s,token:k,accessToken:E,disabledPersonalKeyCreation:d}):"users"==A?(0,n.jsx)(eL,{userID:I,userRole:s,token:k,keys:g,teams:p,accessToken:E,setKeys:f}):"teams"==A?(0,n.jsx)(ez,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s}):"organizations"==A?(0,n.jsx)(eY,{teams:p,setTeams:j,searchParams:v,accessToken:E,userID:I,userRole:s,premiumUser:a}):"admin-panel"==A?(0,n.jsx)(eX,{setTeams:j,searchParams:v,accessToken:E,showSSOBanner:_,premiumUser:a}):"api_ref"==A?(0,n.jsx)(l_,{proxySettings:Z}):"settings"==A?(0,n.jsx)(e8,{userID:I,userRole:s,accessToken:E,premiumUser:a}):"budgets"==A?(0,n.jsx)(lu,{accessToken:E}):"general-settings"==A?(0,n.jsx)(ls,{userID:I,userRole:s,accessToken:E,modelData:w}):"model-hub"==A?(0,n.jsx)(ly.Z,{accessToken:E,publicPage:!1,premiumUser:a}):"caching"==A?(0,n.jsx)(lX,{userID:I,userRole:s,token:k,accessToken:E,premiumUser:a}):"pass-through-settings"==A?(0,n.jsx)(ld,{userID:I,userRole:s,accessToken:E,modelData:w}):"logs"==A?(0,n.jsx)(lZ,{userID:I,userRole:s,token:k,accessToken:E}):(0,n.jsx)(lG,{userID:I,userRole:s,token:k,accessToken:E,keys:g,premiumUser:a})]})]})})}}},function(e){e.O(0,[665,990,42,261,755,978,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 5e2c2d24b7d..202c0821724 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 96cf942cfb6..3e70cd4614d 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[69623,["665","static/chunks/3014691f-879b58d3fc1547e5.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-4c9a56afdf4d8d5b.js","261","static/chunks/261-1a8c5eb3e86e9745.js","755","static/chunks/755-c7e0ae255f32cb18.js","978","static/chunks/978-8a30252ea2e72994.js","250","static/chunks/250-14d49cbd51f2ae7d.js","699","static/chunks/699-bf55769caf9128ce.js","931","static/chunks/app/page-f3fef89bb008195a.js"],"default",1]
+3:I[69623,["665","static/chunks/3014691f-879b58d3fc1547e5.js","990","static/chunks/13b76428-ebdf3012af0e4489.js","42","static/chunks/42-4c9a56afdf4d8d5b.js","261","static/chunks/261-1a8c5eb3e86e9745.js","755","static/chunks/755-c7e0ae255f32cb18.js","978","static/chunks/978-8a30252ea2e72994.js","250","static/chunks/250-14d49cbd51f2ae7d.js","699","static/chunks/699-bf55769caf9128ce.js","931","static/chunks/app/page-7af065b71201666b.js"],"default",1]
4:I[4707,[],""]
5:I[36423,[],""]
-0:["mtFU-WaJL2V39gBiXh0cn",[[["",{"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/04831c41b377e329.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:["0Ao-pNdjmYzz5_ojxRT0i",[[["",{"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/04831c41b377e329.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 13f85f7e78c..b30d16fff84 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 4e395443b5a..a771151da6f 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-4c9a56afdf4d8d5b.js","261","static/chunks/261-1a8c5eb3e86e9745.js","250","static/chunks/250-14d49cbd51f2ae7d.js","699","static/chunks/699-bf55769caf9128ce.js","418","static/chunks/app/model_hub/page-227e49e1b9d01e96.js"],"default",1]
4:I[4707,[],""]
5:I[36423,[],""]
-0:["mtFU-WaJL2V39gBiXh0cn",[[["",{"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/04831c41b377e329.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:["0Ao-pNdjmYzz5_ojxRT0i",[[["",{"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/04831c41b377e329.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 1e6be751359..3ab72ec5024 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 792bf9c9856..a20fc7ebb38 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-879b58d3fc1547e5.js","42","static/chunks/42-4c9a56afdf4d8d5b.js","755","static/chunks/755-c7e0ae255f32cb18.js","250","static/chunks/250-14d49cbd51f2ae7d.js","461","static/chunks/app/onboarding/page-ae78048a415c7f25.js"],"default",1]
4:I[4707,[],""]
5:I[36423,[],""]
-0:["mtFU-WaJL2V39gBiXh0cn",[[["",{"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/04831c41b377e329.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:["0Ao-pNdjmYzz5_ojxRT0i",[[["",{"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/04831c41b377e329.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