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/8r6NWZjV65MfTM9OwdJEV/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_buildManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/8r6NWZjV65MfTM9OwdJEV/_buildManifest.js
rename to litellm/proxy/_experimental/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_buildManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/8r6NWZjV65MfTM9OwdJEV/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_ssgManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/8r6NWZjV65MfTM9OwdJEV/_ssgManifest.js
rename to litellm/proxy/_experimental/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_ssgManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-276b2ef886aa0b4e.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-0ad2ec54b8904803.js
similarity index 85%
rename from litellm/proxy/_experimental/out/_next/static/chunks/app/page-276b2ef886aa0b4e.js
rename to litellm/proxy/_experimental/out/_next/static/chunks/app/page-0ad2ec54b8904803.js
index 887cef923c68..3d012e48ee2d 100644
--- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-276b2ef886aa0b4e.js
+++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-0ad2ec54b8904803.js
@@ -1 +1 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,79642))},62105:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return f}});var t=s(57437),n=s(2265),a=s(16463),r=s(15606),i=s(85272),o=s(75203),d=s(56745),c=s(46430),m=s(29312),u=s(50586),h=s(99295),x=s(23152),p=s(38939),j=s(49714),g=s(26267),Z=s(46682);function f(){let[e]=g.Z.useForm(),l=(0,a.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"),[f,_]=(0,n.useState)(null),[y,b]=(0,n.useState)(""),[v,S]=(0,n.useState)(""),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(""),[A,C]=(0,n.useState)("");return(0,n.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);C(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),S(t.user_email),w(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:",f,"token:",A,"formValues:",e),f&&A&&(e.user_email=v,k&&s&&(0,p.m_)(f,s,k,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="+A,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)(Z.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},79642:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l_}});var t,n,a=s(57437),r=s(2265),i=s(16463),o=s(87138),d=s(71774),c=s(23288),m=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:n,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",n),console.log=function(){};let m="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(m=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",m);let u=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})},{key:"2",label:(0,a.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=m},children:"Logout"})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(o.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[n?null:(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterprise license"})}),(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:u},children:(0,a.jsx)(c.Z,{children:t||s})})})]})]})},u=s(38939),h=s(56745),x=s(46430),p=s(15606),j=s(50586),g=s(58759),Z=s(58748),f=s(32850),_=s(29312),y=s(99295),b=s(45789),v=s(29525),S=s(26267),k=s(58569),w=s(45076),N=s(59733),I=s(82832),A=s(62250),C=s(46682);let{Option:P}=v.default,E=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 T=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)(null),[M,D]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[V,B]=(0,r.useState)("you"),[z,q]=(0,r.useState)(E(i)),K=()=>{m(!1),d.resetFields()},W=()=>{m(!1),O(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),D(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let H=async e=>{try{var s,t,a;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!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(k.ZP.info("Making API Call"),m(!0),"service_account"===V){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 h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),O(h.key),F(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,a.jsxs)(S.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Owned By",className:"mb-4",children:(0,a.jsxs)(N.ZP.Group,{onChange:e=>B(e.target.value),value:V,children:[(0,a.jsx)(N.ZP,{value:"you",children:"You"}),(0,a.jsx)(N.ZP,{value:"service_account",children:"Service Account"})]})}),(0,a.jsx)(S.Z.Item,{label:"you"===V?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===V?"key name":"service account ID")}],help:"you"===V?"required":"IDs can include letters, numbers, and hyphens",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(P,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,a.jsx)(P,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)(S.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,a.jsx)(v.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:z})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),T&&(0,a.jsx)(w.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.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,a.jsx)(h.Z,{numColSpan:1,children:null!=T?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:T})}),(0,a.jsx)(b.CopyToClipboard,{text:T,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(17539),R=s(88795),F=s(94157),M=s(10823),D=s(17164),L=s(12299),U=s(75203),V=s(11887),B=s(38193),z=s(76971),q=s(49368),K=s(4207),W=s(72056),H=s(5594),G=s(39858),J=s(24155),Y=s(90797);let{Option:X}=v.default;console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d,premiumUser:c}=e,[m,g]=(0,r.useState)(!1),[Z,f]=(0,r.useState)(!1),[N,I]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[T,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,en]=(0,r.useState)(!1),[ea,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),[eZ]=S.Z.useForm(),[ef,e_]=(0,r.useState)(null),[ey,eb]=(0,r.useState)(ed);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",ea),(null==ej?void 0:ej.duration)?e_((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)):e_(null),console.log("calculateNewExpiryTime:",ef)},[ea,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.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 ev=e=>{er(e),em(!0)},eS=async e=>{if(null==t||null==ea)return;let l={...ea,metadata:e,key:ea.token};try{let e=await (0,u.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===ea.token?e:l);o(l)}k.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),k.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 ek=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)},ew=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),k.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,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),es(!1),er(null)},eN=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(I(e.token),localStorage.removeItem("userData"+l),f(!0))},eI=async()=>{if(null!=N&&null!=i){try{await (0,u.I1)(t,N);let e=i.filter(e=>e.token!==N);o(e)}catch(e){console.error("Error deleting the key:",e)}f(!1),I(null)}},eA=e=>{er(e),e_(null),eZ.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)},eC=(e,l)=>{eg(s=>({...s,[e]:l}))},eP=async()=>{if(!c){k.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=ea)try{let e=await eZ.validateFields(),l=await (0,u.s0)(t,ea.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==ea?void 0:ea.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),eZ.resetFields(),k.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),k.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(B.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Key Alias"}),(0,a.jsx)(W.Z,{children:"Secret Key"}),(0,a.jsx)(W.Z,{children:"Created"}),(0,a.jsx)(W.Z,{children:"Expires"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Budget Reset"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"Rate Limits"}),(0,a.jsx)(W.Z,{children:"Rate Limits per model"})]})}),(0,a.jsx)(z.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(ey.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||ey.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(q.Z,{children:null!=e.created_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,a.jsx)(q.Z,{children:null!=e.expires?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(q.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(q.Z,{children:null!=e.budget_reset_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{size:"xs",onClick:()=>ev(e),children:"Edit Limits"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{onClick:()=>{er(e),en(!0)},icon:R.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:et,onCancel:()=>{en(!1),er(null)},footer:null,width:800,children:ea&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(ea.spend).toFixed(4)}catch(e){return ea.spend}})()})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.max_budget?(0,a.jsxs)(a.Fragment,{children:[ea.max_budget,ea.budget_duration&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"Budget will be reset at ",ea.budget_reset_at?new Date(ea.budget_reset_at).toLocaleString():"Never"]})]}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.expires?(0,a.jsx)(a.Fragment,{children:new Date(ea.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(U.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:ea.key_alias?ea.key_alias:ea.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.token}),(0,a.jsx)(y.Z,{children:"User ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.user_id}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(ea.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{en(!1),er(null)},children:"Close"})]})}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>ek(e)}),(0,a.jsx)(V.Z,{onClick:()=>eA(e),icon:M.Z,size:"sm"}),(0,a.jsx)(V.Z,{onClick:()=>eN(e),icon:D.Z,size:"sm"})]})]},e.token)})})]}),Z&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:eI,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{f(!1),I(null)},children:"Cancel"})]})]})]})})]}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let Z=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,a.jsx)(w.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,a.jsxs)(S.Z,{form:o,onFinish:ew,initialValues:Z,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(X,{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,a.jsx)(X,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(X,{value:e,children:e},e)):ei.map(e=>(0,a.jsx)(X,{value:e,children:e},e))]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"daily",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"weekly",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"monthly",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,a.jsx)(G.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(J.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max tpm_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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,a.jsx)(Y.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:ea,onSubmit:ew}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:n,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,m]=(0,r.useState)([]),[h,x]=(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,u.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));m(l)}catch(e){console.error("Error fetching model data:",e),k.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,a.jsxs)(w.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model"}),(0,a.jsx)(W.Z,{children:"TPM Limit"}),(0,a.jsx)(W.Z,{children:"RPM Limit"}),(0,a.jsx)(W.Z,{children:"Actions"})]})}),(0,a.jsxs)(z.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:l}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(v.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),x(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,a.jsx)(X,{value:e,children:e},e))})}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>x(null),children:"Cancel"})})]})]})]}),(0,a.jsx)(p.Z,{onClick:()=>{x("")},disabled:null!==h,children:"Add Limit"})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,a.jsx)(p.Z,{onClick:s,children:"Cancel"}),(0,a.jsx)(p.Z,{onClick:()=>{n({...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:ea,onSubmit:eS,accessToken:t}),(0,a.jsx)(w.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),eZ.resetFields()},footer:[(0,a.jsx)(p.Z,{onClick:()=>{eh(!1),eZ.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,a.jsx)(p.Z,{onClick:eP,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,a.jsxs)(S.Z,{form:eZ,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eC("duration",e.duration)},children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{disabled:!0})}),(0,a.jsx)(S.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,a.jsx)(A.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==ea?void 0:ea.expires)!=null?new Date(ea.expires).toLocaleString():"Never"]}),ef&&(0,a.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",ef]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,a.jsx)(w.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,a.jsx)(p.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Regenerated Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,a.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,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"Key Alias:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==ea?void 0:ea.key_alias)||"No alias set"})}),(0,a.jsx)(_.Z,{className:"mt-3",children:"New API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,a.jsx)(b.CopyToClipboard,{text:ex,onCopy:()=>k.ZP.success("API Key copied to clipboard"),children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(n));let[d,c]=(0,r.useState)(null!==n?n:0),[m,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,u.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!==n&&c(n)},[n]);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,a.jsx)("div",{className:"flex items-center",children:(0,a.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})};console.log=function(){};var ee=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,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,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.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,a.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},el=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let m={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,u.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(m);return console.log("userRole: ".concat(n)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===n?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[m]:s?[...s,m]:[m],(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(_.Z,{className:"mt-3 mb-3",children:[(0,a.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,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},es=s(62105),et=s(49714),en=s(16330);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,premiumUser:j}=e,[g,Z]=(0,r.useState)(null),f=(0,i.useSearchParams)();f.get("viewSpend"),(0,i.useRouter)();let _=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),y=f.get("invitation_id"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)(null),C={models:[],team_alias:"Default Team",team_id:null},[P,E]=(0,r.useState)(t?t[0]:C);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(_){let e=(0,et.o)(_);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&&!n&&!g){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.g)(b);A(e);let t=await (0,u.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))),Z(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),E(n[0])):E(C),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,_,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=P&&null!==P.team_id){let e=0;for(let l of n)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[P]),null!=y)return(0,a.jsx)(es.default,{});if(null==l||null==_){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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(ee,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,a.jsx)(Q,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:S,selectedTeam:P||null}),(0,a.jsx)($,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:n,setData:p,premiumUser:j,teams:t}),(0,a.jsx)(T,{userID:l,team:P||null,userRole:s,accessToken:b,data:n,setData:p},P?P.team_id:null),(0,a.jsx)(el,{teams:t,setSelectedTeam:E,userRole:s,proxySettings:I,setProxySettings:A,userInfo:g,accessToken:b})]})})})},er=s(92411),ei=s(95299),eo=s(63789),ed=s(93466),ec=s(51782),em=s(174),eu=s(28260),eh=s(55083),ex=s(38848),ep=s(16039),ej=s(91499),eg=s(68551),eZ=s(95381),ef=s(77733),e_=s(69332),ey=s(46229),eb=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(V.Z,{onClick:()=>n(!0),icon:D.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ev=s(1071),eS=s(44611),ek=s(85272),ew=s(7416),eN=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ew.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,a.jsxs)("div",{children:[(0,a.jsx)(ek.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,a.jsx)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eI=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eA=s(28040);let{Title:eC,Link:eP}=en.default;(t=n||(n={})).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 eE={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"},eT={"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={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eE[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)n[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 k.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 t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eR=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:m,premiumUser:h}=e,[g,Z]=(0,r.useState)([]),[f]=S.Z.useForm(),[b,v]=(0,r.useState)(null),[N,I]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),T=Object.values(n).filter(e=>isNaN(Number(e))),[O,D]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[ek,ew]=(0,r.useState)(null),[eR,eF]=(0,r.useState)([]),[eM,eD]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[eV,eB]=(0,r.useState)([]),[ez,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)([]),[e5,e4]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e9]=(0,r.useState)(null),[e7,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,ln]=(0,r.useState)([]),[la,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 n=null==li?void 0:li.token;void 0===n&&(n=null);let a=ld;void 0===a&&(a=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,u.o6)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,u.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,u.N8)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let m=await (0,u.fP)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);if(console.log("slowResponses:",m),e4(m),e){let n=await (0,u.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(n);let a=await (0,u.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ln(a)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{ew(e),es(!0)},lp=e=>{ew(e),ea(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,n]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]=n:t=n;let n={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",n);try{await (0,u.um)(s,n),k.ZP.success("Model updated successfully, restart server to see updates"),es(!1),ew(null)}catch(e){console.log("Error occurred")}},lg=()=>{I(new Date().toLocaleString())},lZ=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,u.K_)(s,{router_settings:{model_group_retry_policy:e6}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.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,n,a,r,d,c,h,x,p,j;let g=await (0,u.hy)(s);D(g);let Z=await (0,u.AZ)(s,o,i);console.log("Model data response:",Z.data),m(Z);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",eL);let b=await (0,u.o6)(s,o,i,y,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,u.Rg)(s,y,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(n=e8.to)||void 0===n?void 0:n.toISOString());eG(v.data),eY(v.all_api_bases);let S=await (0,u.N8)(s,o,i,y,null===(a=e8.from)||void 0===a?void 0:a.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",S),e$(S.data),e0(S.exception_types);let k=await (0,u.fP)(s,o,i,y,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),w=await (0,u.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],y);ls(w);let N=await (0,u.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],y);ln(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e4(k);let I=await (0,u.j2)(s);lu(null==I?void 0:I.end_users);let A=(await (0,u.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e9(C),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,u.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),v(e)};null==b&&l(),lg()},[s,t,i,o,b,N]),!d||!s||!t||!i||!o)return(0,a.jsx)("div",{children:"Loading..."});let lf=[],l_=[];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];(a=t)||(a=1===e.length?u(s):l)}else a="-";n&&(r=null==n?void 0:n.input_cost_per_token,i=null==n?void 0:n.output_cost_per_token,o=null==n?void 0:n.max_tokens,c=null==n?void 0:n.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=a,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,l_.push(a),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,lf.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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lS=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eE[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.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))}},lk=async()=>{try{k.ZP.info("Running health check..."),ee("");let e=await (0,u.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lw=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),h?(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsx)(J.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsxs)(J.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsxs)(J.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!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,a.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,a.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,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.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 lA=Object.keys(n).find(e=>n[e]===X);return lA&&(l=O.find(e=>e.name===eE[lA])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eo.Z,{children:"All Models"}),(0,a.jsx)(eo.Z,{children:"Add Model"}),(0,a.jsx)(eo.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eo.Z,{children:"Model Analytics"}),(0,a.jsx)(eo.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[N&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",N]}),(0,a.jsx)(V.Z,{icon:M.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(G.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,a.jsx)(J.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,a.jsxs)(H.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.litellm_model_name,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.api_base,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&e.model_info.created_by||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(L.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(L.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:R.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(eb,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.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,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),ew(null)},model:ek,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:ek&&ek.model_name,visible:et,width:800,footer:null,onCancel:()=>{ea(!1),ew(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eA.Z,{language:"json",children:ek&&JSON.stringify(ek,null,2)})]})]}),(0,a.jsxs)(em.Z,{className:"h-full",children:[(0,a.jsx)(eC,{level:2,children:"Add new model"}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(S.Z,{form:f,onFinish:()=>{f.validateFields().then(e=>{eO(e,s,f)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(G.Z,{value:X.toString(),children:T.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lS(e),$(e)},children:e},l))})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsxs)(S.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,a.jsx)(S.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,a.jsx)(j.Z,{placeholder:lI(X.toString())}):P.length>0?(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(ex.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,a.jsx)(ex.Z,{value:e,children:e},l))]}):(0,a.jsx)(j.Z,{placeholder:lI(X.toString())})}),(0,a.jsx)(S.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,a.jsx)(S.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,a.jsx)(j.Z,{placeholder:"Enter custom model name"})})}})]}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eP,{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,a.jsx)(eI,{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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(eS.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;f.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(C.ZP,{icon:(0,a.jsx)(ev.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eP,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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,a.jsx)(Y.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eg.Z,{title:"Get help on our github",children:(0,a.jsx)(en.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:lk,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,a.jsxs)(eZ.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(G.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(e_.Z,{trigger:"click",content:lw,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eo.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ez&&eK&&(0,a.jsx)(ep.Z,{title:"Model Latency",className:"h-72",data:ez,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eN,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:h})})]})]})})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Deployment"}),(0,a.jsx)(W.Z,{children:"Success Responses"}),(0,a.jsxs)(W.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(z.Z,{children:e5.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.api_base}),(0,a.jsx)(q.Z,{children:e.total_count}),(0,a.jsx)(q.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,a.jsx)(ej.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eZ.Z,{})]})]}),h?(0,a.jsx)(a.Fragment,{children:lt.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(G.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,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eT&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eT).map((e,l)=>{var s;let[t,n]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[n];return null==r&&(r=e7),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(A.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e9(l=>{var s;let t=null!==(s=null==l?void 0:l[eL])&&void 0!==s?s:{};return{...null!=l?l:{},[eL]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eF=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=en.default,o=()=>(null==n?void 0:n.has_user_setup_sso)?"".concat(t,"/ui"):"".concat(t,"/ui?invitation_id=").concat(null==n?void 0:n.id);return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsx)(_.Z,{children:(0,a.jsx)(_.Z,{children:o()})})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:o(),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eM}=v.default;var eD=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o,d]=(0,r.useState)(null),[c]=S.Z.useForm(),[m,h]=(0,r.useState)(!1),[x,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)();console.log=function(){};let[E,T]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(P){let{protocol:e,host:l}=window.location;T("".concat(e,"/").concat(l))}},[P]);let O=async e=>{try{var t;k.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),g(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:a,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),b(!0)}else(0,u.XO)(s,a).then(e=>{e.has_user_setup_sso=!1,A(e),b(!0)});k.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eM,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eM,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),x&&(0,a.jsx)(eF,{isInvitationLinkModalVisible:y,setIsInvitationLinkModalVisible:b,baseUrl:E,invitationLinkData:N})]})},eL=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eU=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)(null),[f,_]=(0,r.useState)(1),[y,b]=r.useState(null),[v,S]=(0,r.useState)(null),[w,N]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(!1),[E,T]=(0,r.useState)(null),[O,R]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{T(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,u.Eb)(l,[E]),k.ZP.success("User deleted successfully"),h){let e=h.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),k.ZP.error("Failed to delete user")}P(!1),T(null)},J=async()=>{A(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}h&&j(h.map(l=>l.user_id===e.user_id?e:l)),A(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(f));if(e){let l=JSON.parse(e);m(l),j(l.users||[])}else{let e=await (0,u.Br)(l,null,n,!0,f,25);sessionStorage.setItem("userList_".concat(f),JSON.stringify(e)),m(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)R(JSON.parse(s));else{let e=await (0,u.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),R(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,f]),h&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eD,{userID:i,accessToken:l,teams:o,possibleUIRoles:O}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(ed.Z,{children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(B.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"User ID"}),(0,a.jsx)(W.Z,{children:"User Email"}),(0,a.jsx)(W.Z,{children:"Role"}),(0,a.jsx)(W.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(W.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(W.Z,{children:"API Keys"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:h.map(e=>{var l,s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_id||"-"}),(0,a.jsx)(q.Z,{children:e.user_email||"-"}),(0,a.jsx)(q.Z,{children:(null==O?void 0:null===(l=O[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(q.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(q.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e.key_count>0?(0,a.jsxs)(L.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,a.jsx)(L.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,onClick:()=>{A(e),N(!0)},children:"View Keys"}),(0,a.jsx)(V.Z,{icon:D.Z,onClick:()=>M(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,a.jsx)(eL,{visible:w,possibleUIRoles:O,onCancel:J,user:I,onSubmit:Y}),C&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,a.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{P(!1),T(null)},children:"Cancel"})]})]})]})})]}),function(){if(!h)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),_(e)};return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",f," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.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===f,onClick:()=>l(f-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:f===e,onClick:()=>l(f+1),children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})};console.log=function(){};var eV=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,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,u.It)(t,i):await (0,u.It)(t),console.log("givenTeams: ".concat(e)),n(e)})()},[l]);let[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=en.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[N,P]=(0,r.useState)(l?l[0]:null),[E,T]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)(!1),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)({}),et=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{ee(e),$(!0)},ei=async()=>{if(null!=Q&&null!=l&&null!=t){try{await (0,u.rs)(t,Q);let e=l.filter(e=>e.team_id!==Q);n(e)}catch(e){console.error("Error deleting the team:",e)}$(!1),ee(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,u.It)(t,i):await (0,u.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),Y(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),T(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:e.role,user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,N.team_id,s);k.ZP.success("Member added"),console.log("response for team create call: ".concat(a.data));let r=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}R(!1)}}catch(e){console.error("Error creating the team:",e)}};return(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Team Name"}),(0,a.jsx)(W.Z,{children:"Team ID"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(W.Z,{children:"Info"})]})}),(0,a.jsx)(z.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,a.jsx)(eg.Z,{title:e.team_id,children:e.team_id})}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(q.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,a.jsx)(q.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].keys&&el[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].members_with_roles&&el[e.team_id].members_with_roles.length," ","Members"]})]}),(0,a.jsx)(q.Z,{children:"Admin"==o?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>et(e)}),(0,a.jsx)(V.Z,{onClick:()=>er(e.team_id),icon:D.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),X&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{$(!1),ee(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>T(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:E,width:800,footer:null,onOk:()=>{T(!1),d.resetFields()},onCancel:()=>{T(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:N?N.members_with_roles.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(q.Z,{children:e.role})]},l)):null})]})}),N&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M&&M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:N,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:["Admin"==o||N&&(e=>{for(let l=0;lR(!0),children:"+ Add member"}):null,(0,a.jsx)(w.Z,{title:"Add member",visible:O,width:800,footer:null,onOk:()=>{R(!1),c.resetFields()},onCancel:()=>{R(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)(S.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,a.jsxs)(v.default,{defaultValue:"user",children:[(0,a.jsx)(v.default.Option,{value:"admin",children:"admin"}),(0,a.jsx)(v.default.Option,{value:"user",children:"user"})]})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eB=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n,premiumUser:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:j}=en.default,[g,Z]=(0,r.useState)(""),[f,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,M]=(0,r.useState)(!1),[D,L]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,et]=(0,r.useState)(!1),[ea,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){k.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,u.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),k.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,u.eH)(t,e.ip);let l=await (0,u.PT)(t);er(l),k.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),k.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),et(!0)},eZ=async()=>{if(ei&&t)try{await (0,u.$I)(t,ei);let e=await (0,u.PT)(t);er(e.length>0?e:[ex]),k.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),k.ZP.error("Failed to delete IP address ".concat(e))}finally{et(!1),eo(null)}},ef=()=>{X(!1)},e_=["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,u.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 n=(await (0,u.Xd)(t,"proxy_admin")).users;n.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(n)),console.log("combinedList: ".concat(e)),y(e),em(await (0,u.lg)(t))}})()},[t]);let ey=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(G.Z,{value:l,children:e_.map((e,l)=>(0,a.jsx)(J.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ew=async e=>{try{if(null!=t&&null!=f){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=f.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"),f.push(l),y(f)),k.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!=f){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)});let a=f.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(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=f){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)}),console.log("response for team create call: ".concat(s));let a=f.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eA=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,u.K_)(t,l)};return console.log("admins: ".concat(null==f?void 0:f.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(m,{level:4,children:"Admin Access "}),(0,a.jsxs)(j,{children:[n&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:f?f.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(q.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,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>M(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ey,onCancel:eb,children:eS(ew,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),c.resetFields(),d.resetFields()},onCancel:()=>{O(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,a.jsx)(eF,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,a.jsx)(w.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,a.jsxs)(x.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(m,{level:4,children:" ✨ Security Settings"}),(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:()=>!0===o?L(!0):k.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(w.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{L(!1),d.resetFields()},onCancel:()=>{L(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:e=>{eI(e),eA(e),L(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(I.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(I.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:ef,onCancel:()=>{X(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{onClick:ef,children:"Done"})})]}),(0,a.jsx)(w.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,a.jsx)(p.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"IP Address"}),(0,a.jsx)(W.Z,{className:"text-right",children:"Action"})]})}),(0,a.jsx)(z.Z,{children:ea.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e}),(0,a.jsx)(q.Z,{className:"text-right",children:e!==ex&&(0,a.jsx)(p.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,a.jsx)(w.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,a.jsxs)(S.Z,{onFinish:ej,children:[(0,a.jsx)(S.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,a.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,a.jsx)(S.Z.Item,{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,a.jsx)(w.Z,{title:"Confirm Delete",visible:es,onCancel:()=>et(!1),onOk:eZ,footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>eZ(),children:"Yes"},"delete"),(0,a.jsx)(p.Z,{onClick:()=>et(!1),children:"Close"},"close")],children:(0,a.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,a.jsxs)(ek.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},ez=s(22054),eq=s(26706),eK=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.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."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{align:"center",children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(S.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eW=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eK,{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))),n(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);n(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 n={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(n)));let{slack_alerting:a,...r}=n;console.log("slack_alerting: ".concat(a,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,u.jA)(l,"alerting_args",r),"boolean"==typeof a&&(!0==a?(0,u.jA)(l,"alerting",["slack"]):(0,u.jA)(l,"alerting",[])),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},eH=s(36031);let{Title:eG,Paragraph:eJ}=en.default;console.log=function(){};var eY=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)(!1),[M,D]=(0,r.useState)([]),[L,G]=(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)?T(E.filter(l=>l!==e)):T([...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,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),D(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),T(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let en=e=>E&&E.includes(e),ea=()=>{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,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.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,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},ei=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,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(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,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eo.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eo.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(eo.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(U.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(W.Z,{children:"Callback Name"})})}),(0,a.jsx)(z.Z,{children:i.map((e,s)=>(0,a.jsxs)(H.Z,{className:"flex justify-between",children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>R(!0),children:"Add Callback"})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(_.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)}):(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eW,{accessToken:l,premiumUser:n})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(q.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.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,a.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,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ea(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:O,width:800,onCancel:()=>R(!1),footer:null,children:[(0,a.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,a.jsx)(S.Z,{form:g,onFinish:ei,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eH.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,a.jsx)(J.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,a.jsx)(eH.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(eH.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eX}=v.default;var e$=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(G.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(eh.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eQ=s(45595);async function e0(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new eQ.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});k.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let e1={ttl:3600,lowest_latency_buffer:0},e2=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var e5=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,I]=(0,r.useState)(null),[C,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,u.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,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let T=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,u.K_)(l,{router_settings:i}),o({...i}),I(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},O=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},F=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},M=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eo.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eo.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.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,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,a.jsx)(q.Z,{children:"routing_strategy"==l?(0,a.jsxs)(G.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(J.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(J.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(J.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e2,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:e1,paramExplanation:E})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>M(i),children:"Save Changes"})})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model Name"}),(0,a.jsx)(W.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(z.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:t}),(0,a.jsx)(q.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>e0(t,l),children:"Test Fallback"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(e$,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"}),(0,a.jsx)(W.Z,{children:"Status"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(q.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>O(e.field_name,l)}):null}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>F(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e4=s(16873),e8=s(56115),e3=e=>{let{value:l={},onChange:s}=e,[t,n]=(0,r.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);n(l),null==s||s(Object.fromEntries(l))},o=(e,l,a)=>{let r=[...t];r[e]=[l,a],n(r),null==s||s(Object.fromEntries(r))};return(0,a.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(c.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,a.jsx)(j.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,a.jsx)(j.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,a.jsx)(e4.Z,{onClick:()=>i(l)})]},l)}),(0,a.jsx)(C.ZP,{type:"dashed",onClick:()=>{n([...t,["",""]])},icon:(0,a.jsx)(e8.Z,{}),children:"Add Header"})]})};let{Option:e6}=v.default;var e9=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,a.jsx)(w.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),n.resetFields()},onCancel:()=>{o(!1),n.resetFields()},children:(0,a.jsxs)(S.Z,{form:n,onFinish:e=>{console.log(e);let a=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,u.Vt)(l,e),s(a)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("Pass through endpoint successfully added"),o(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(e3,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},e7=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,u.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,u.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),k.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Path"}),(0,a.jsx)(W.Z,{children:"Target"}),(0,a.jsx)(W.Z,{children:"Headers"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:i.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.path})}),(0,a.jsx)(q.Z,{children:e.target}),(0,a.jsx)(q.Z,{children:JSON.stringify(e.headers)}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,a.jsx)(e9,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},le=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},ll=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=S.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call"),t(!0);let l=await (0,u.qI)(s,e);n(e=>e?[...e,l]:[l]),k.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Budget"})})]})})},ls=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{m(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))},x=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...c];t.splice(s,1),m(t),k.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,u.O3)(l).then(e=>{m(e)})};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(le,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,a.jsx)(ll,{accessToken:l,isModalVisible:n,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:j}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Budget ID"}),(0,a.jsx)(W.Z,{children:"Max Budget"}),(0,a.jsx)(W.Z,{children:"TPM"}),(0,a.jsx)(W.Z,{children:"RPM"})]})}),(0,a.jsx)(z.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.budget_id}),(0,a.jsx)(q.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(q.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(q.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>x(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eo.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eo.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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)'})})]})]})]})]})},lt=s(48357),ln=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(_.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,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eo.Z,{children:"LlamaIndex"}),(0,a.jsx)(eo.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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 ')})})]})]})]})})})};async function la(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let n=window.location.origin,a=new eQ.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lr=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await la(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(ec.Z,{children:(0,a.jsx)(eo.Z,{children:"Chat"})}),(0,a.jsx)(eu.Z,{children:(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(B.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{})})}),(0,a.jsx)(z.Z,{children:m.map((e,l)=>(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},li=s(16384),lo=s(71646);let{Sider:ld}=li.default,lc=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lm=[{key:"1",page:"api-keys",label:"Virtual Keys"},{key:"3",page:"llm-playground",label:"Test Key"},{key:"2",page:"models",label:"Models",roles:lc},{key:"4",page:"usage",label:"Usage"},{key:"6",page:"teams",label:"Teams"},{key:"5",page:"users",label:"Internal Users",roles:lc},{key:"8",page:"settings",label:"Logging & Alerts",roles:lc},{key:"9",page:"caching",label:"Caching",roles:lc},{key:"10",page:"budgets",label:"Budgets",roles:lc},{key:"11",page:"general-settings",label:"Router Settings",roles:lc},{key:"12",page:"pass-through-settings",label:"Pass-Through",roles:lc},{key:"13",page:"admin-panel",label:"Admin Settings",roles:lc},{key:"14",page:"api_ref",label:"API Reference"},{key:"16",page:"model-hub",label:"Model Hub"}];var lu=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,n=lm.find(e=>e.page===t),r=(null==n?void 0:n.key)||"1",i=lm.filter(e=>!e.roles||e.roles.includes(s));return(0,a.jsx)(li.default,{style:{minHeight:"100vh",maxWidth:"Admin Viewer"===s?"120px":"145px"},children:(0,a.jsx)(ld,{width:"Admin Viewer"===s?120:145,children:(0,a.jsx)(lo.Z,{mode:"inline",selectedKeys:[r],style:{height:"100%",borderRight:0},children:i.map(e=>(0,a.jsx)(lo.Z.Item,{onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)},children:(0,a.jsx)(_.Z,{children:e.label})},e.key))})})})},lh=s(90402),lx=s(64476);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lp=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lj=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,M]=(0,r.useState)({}),[D,L]=(0,r.useState)([]),[V,Y]=(0,r.useState)(""),[X,$]=(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),en=new Date(d.getFullYear(),d.getMonth(),1),ea=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(en),eZ=ev(ea);function ef(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 e_=async()=>{if(l)try{let e=await (0,u.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 ey=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 n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},eb=async(e,s)=>{e&&s&&l&&(null==es||!es.DISABLE_EXPENSIVE_DB_QUERIES)&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.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(eZ));let eS=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},ek=()=>eS(()=>l?(0,u.FC)(l):Promise.reject("No access token"),m,"Error fetching overall spend"),ew=()=>eS(()=>l&&s?(0,u.OU)(l,s,eg,eZ):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await eS(async()=>(await (0,u.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 eS(async()=>(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),f,"Error fetching top models")},eA=async()=>{l&&await eS(async()=>{let e=await (0,u.mR)(l);return k(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},T,"Error fetching team spend")},eC=()=>{l&&eS(async()=>(await (0,u.X)(l)).tag_names,A,"Error fetching tag names")},eP=()=>{l&&eS(()=>{var e,s;return(0,u.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&&eS(()=>(0,u.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eT=()=>{l&&eS(()=>(0,u.wd)(l,eg,eZ),M,"Error fetching global activity")},eO=()=>{l&&eS(()=>(0,u.xA)(l,eg,eZ),L,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&n){let e=await e_();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),ek(),ew(),eN(),eI(),eT(),eO(),lp(t)&&(eA(),eC(),eP(),eE()))}})()},[l,s,t,n,eg,eZ]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,a.jsxs)(_.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,a.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,a.jsx)(p.Z,{className:"mt-4",children:(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{className:"mt-2",children:[(0,a.jsx)(eo.Z,{children:"All Up"}),lp(t)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eo.Z,{children:"Team Based Usage"}),(0,a.jsx)(eo.Z,{children:"Customer Usage"}),(0,a.jsx)(eo.Z,{children:"Tag Based Usage"})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{})})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eo.Z,{children:"Cost"}),(0,a.jsx)(eo.Z,{children:"Activity"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(Q,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ej.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ej.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,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ej.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(lx.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Provider"}),(0,a.jsx)(W.Z,{children:"Spend"})]})}),(0,a.jsx)(z.Z,{children:O.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.provider}),(0,a.jsx)(q.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(F.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(F.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:D.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ef,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:D&&D.length>0&&D.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:ef,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lh.Z,{data:E})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ej.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.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,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),ey(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.Z,{value:"all-keys",onClick:()=>{ey(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,a.jsx)(J.Z,{value:String(l),onClick:()=>{ey(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(U.Z,{className:"mt-4",children:(0,a.jsxs)(B.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Customer"}),(0,a.jsx)(W.Z,{children:"Spend"}),(0,a.jsx)(W.Z,{children:"Total Events"})]})}),(0,a.jsx)(z.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.end_user}),(0,a.jsx)(q.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(q.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ei.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(ex.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(J.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ej.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})};let lg=e=>{if(e)return e.toISOString().split("T")[0]};function lZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lf=e=>{let{accessToken:l,token:s,userRole:t,userID:n,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,m]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,Z]=(0,r.useState)([]),[f,_]=(0,r.useState)("0"),[y,b]=(0,r.useState)("0"),[v,S]=(0,r.useState)("0"),[k,w]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&k&&(async()=>{Z(await (0,u.zg)(l,lg(k.from),lg(k.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 A=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,u.zg)(l,lg(e),lg(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,n=e.reduce((e,n)=>{console.log("Processing item:",n),n.call_type||(console.log("Item has no call_type:",n),n.call_type="Unknown"),l+=(n.total_rows||0)-(n.cache_hit_true_rows||0),s+=n.cache_hit_true_rows||0,t+=n.cached_completion_tokens||0;let a=e.find(e=>e.name===n.call_type);return a?(a["LLM API requests"]+=(n.total_rows||0)-(n.cache_hit_true_rows||0),a["Cache hit"]+=n.cache_hit_true_rows||0,a["Cached Completion Tokens"]+=n.cached_completion_tokens||0,a["Generated Completion Tokens"]+=n.generated_completion_tokens||0):e.push({name:n.call_type,"LLM API requests":(n.total_rows||0)-(n.cache_hit_true_rows||0),"Cache hit":n.cache_hit_true_rows||0,"Cached Completion Tokens":n.cached_completion_tokens||0,"Generated Completion Tokens":n.generated_completion_tokens||0}),e},[]);_(lZ(s)),b(lZ(t));let a=s+l;a>0?S((s/a*100).toFixed(2)):S("0"),d(n),console.log("PROCESSED DATA IN CACHE DASHBOARD",n)},[c,p,k,g]),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(x.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:N.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(ei.Z,{enableSelect:!0,value:k,onValueChange:e=>{w(e),A(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:f})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:y})})]})]}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,a.jsx)(ej.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,a.jsx)(ej.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l_=()=>{let{Title:e,Paragraph:l}=en.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[f,_]=(0,r.useState)(!0),y=(0,i.useSearchParams)(),[b,v]=(0,r.useState)({data:[]}),S=y.get("userID"),k=y.get("invitation_id"),w=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),[N,I]=(0,r.useState)(()=>y.get("page")||"api-keys"),[A,C]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(w){let e=(0,et.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),C(e.key),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&&I("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?_("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,u.K8)(e.auth_header_name)}}},[w]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:k?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:S,userRole:s,userEmail:d,premiumUser:n,setProxySettings:Z,proxySettings:g}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lu,{setPage:e=>{let l=new URLSearchParams(y);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),I(e)},userRole:s,defaultSelectedKey:N})}),"api-keys"==N?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):"models"==N?(0,a.jsx)(eR,{userID:S,userRole:s,token:w,keys:p,accessToken:A,modelData:b,setModelData:v,premiumUser:n}):"llm-playground"==N?(0,a.jsx)(lr,{userID:S,userRole:s,token:w,accessToken:A}):"users"==N?(0,a.jsx)(eU,{userID:S,userRole:s,token:w,keys:p,teams:h,accessToken:A,setKeys:j}):"teams"==N?(0,a.jsx)(eV,{teams:h,setTeams:x,searchParams:y,accessToken:A,userID:S,userRole:s}):"admin-panel"==N?(0,a.jsx)(eB,{setTeams:x,searchParams:y,accessToken:A,showSSOBanner:f,premiumUser:n}):"api_ref"==N?(0,a.jsx)(ln,{proxySettings:g}):"settings"==N?(0,a.jsx)(eY,{userID:S,userRole:s,accessToken:A,premiumUser:n}):"budgets"==N?(0,a.jsx)(ls,{accessToken:A}):"general-settings"==N?(0,a.jsx)(e5,{userID:S,userRole:s,accessToken:A,modelData:b}):"model-hub"==N?(0,a.jsx)(lt.Z,{accessToken:A,publicPage:!1,premiumUser:n}):"caching"==N?(0,a.jsx)(lf,{userID:S,userRole:s,token:w,accessToken:A,premiumUser:n}):"pass-through-settings"==N?(0,a.jsx)(e7,{userID:S,userRole:s,accessToken:A,modelData:b}):(0,a.jsx)(lj,{userID:S,userRole:s,token:w,accessToken:A,keys:p,premiumUser:n})]})]})})}},48357:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(57437),n=s(2265),a=s(16463),r=s(38939),i=s(15606),o=s(75203),d=s(63789),c=s(93466),m=s(51782),u=s(174),h=s(28260),x=s(29312),p=s(99295),j=s(97673),g=s(25858),Z=s(68551),f=s(45076),_=s(28040),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,E]=(0,n.useState)(null),T=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{E(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},F=()=>{I(!1),C(!1),E(null)},M=()=>{I(!1),C(!1),E(null)},D=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>D(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:F,onCancel:M,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{T.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:F,onCancel:M,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(P.model_group,'", # 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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="'.concat(P.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # 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="http://0.0.0.0:4000",\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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="http://0.0.0.0:4000",\n model = "'.concat(P.model_group,'",\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 ')})})]})]})]})})]})}}},function(e){e.O(0,[665,569,852,748,17,939,971,23,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,79642))},62105:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return f}});var t=s(57437),n=s(2265),a=s(16463),r=s(15606),i=s(85272),o=s(75203),d=s(56745),c=s(46430),m=s(29312),u=s(50586),h=s(99295),x=s(23152),p=s(38939),j=s(49714),g=s(26267),Z=s(46682);function f(){let[e]=g.Z.useForm(),l=(0,a.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"),[f,_]=(0,n.useState)(null),[y,b]=(0,n.useState)(""),[v,S]=(0,n.useState)(""),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(""),[A,C]=(0,n.useState)("");return(0,n.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);C(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),S(t.user_email),w(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:",f,"token:",A,"formValues:",e),f&&A&&(e.user_email=v,k&&s&&(0,p.m_)(f,s,k,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="+A,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)(Z.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},79642:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l_}});var t,n,a=s(57437),r=s(2265),i=s(16463),o=s(87138),d=s(71774),c=s(23288),m=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:n,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",n),console.log=function(){};let m="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(m=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",m);let u=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})},{key:"2",label:(0,a.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=m},children:"Logout"})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(o.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[n?null:(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterprise license"})}),(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:u},children:(0,a.jsx)(c.Z,{children:t||s})})})]})]})},u=s(38939),h=s(56745),x=s(46430),p=s(15606),j=s(50586),g=s(58759),Z=s(58748),f=s(32850),_=s(29312),y=s(99295),b=s(45789),v=s(29525),S=s(26267),k=s(58569),w=s(45076),N=s(59733),I=s(82832),A=s(62250),C=s(46682);let{Option:P}=v.default,E=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 T=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)(null),[M,D]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[V,B]=(0,r.useState)("you"),[z,q]=(0,r.useState)(E(i)),K=()=>{m(!1),d.resetFields()},W=()=>{m(!1),O(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),D(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let H=async e=>{try{var s,t,a;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!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(k.ZP.info("Making API Call"),m(!0),"service_account"===V){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 h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),O(h.key),F(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,a.jsxs)(S.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Owned By",className:"mb-4",children:(0,a.jsxs)(N.ZP.Group,{onChange:e=>B(e.target.value),value:V,children:[(0,a.jsx)(N.ZP,{value:"you",children:"You"}),(0,a.jsx)(N.ZP,{value:"service_account",children:"Service Account"})]})}),(0,a.jsx)(S.Z.Item,{label:"you"===V?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===V?"key name":"service account ID")}],help:"you"===V?"required":"IDs can include letters, numbers, and hyphens",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(P,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,a.jsx)(P,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)(S.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,a.jsx)(v.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:z})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),T&&(0,a.jsx)(w.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.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,a.jsx)(h.Z,{numColSpan:1,children:null!=T?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:T})}),(0,a.jsx)(b.CopyToClipboard,{text:T,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(17539),R=s(88795),F=s(94157),M=s(10823),D=s(17164),L=s(12299),U=s(75203),V=s(11887),B=s(38193),z=s(76971),q=s(49368),K=s(4207),W=s(72056),H=s(5594),G=s(39858),J=s(24155),Y=s(90797);let{Option:X}=v.default;console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d,premiumUser:c}=e,[m,g]=(0,r.useState)(!1),[Z,f]=(0,r.useState)(!1),[N,I]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[T,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,en]=(0,r.useState)(!1),[ea,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),[eZ]=S.Z.useForm(),[ef,e_]=(0,r.useState)(null),[ey,eb]=(0,r.useState)(ed);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",ea),(null==ej?void 0:ej.duration)?e_((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)):e_(null),console.log("calculateNewExpiryTime:",ef)},[ea,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.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 ev=e=>{er(e),em(!0)},eS=async e=>{if(null==t||null==ea)return;let l={...ea,metadata:e,key:ea.token};try{let e=await (0,u.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===ea.token?e:l);o(l)}k.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),k.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 ek=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)},ew=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),k.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,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),es(!1),er(null)},eN=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(I(e.token),localStorage.removeItem("userData"+l),f(!0))},eI=async()=>{if(null!=N&&null!=i){try{await (0,u.I1)(t,N);let e=i.filter(e=>e.token!==N);o(e)}catch(e){console.error("Error deleting the key:",e)}f(!1),I(null)}},eA=e=>{er(e),e_(null),eZ.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)},eC=(e,l)=>{eg(s=>({...s,[e]:l}))},eP=async()=>{if(!c){k.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=ea)try{let e=await eZ.validateFields(),l=await (0,u.s0)(t,ea.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==ea?void 0:ea.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),eZ.resetFields(),k.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),k.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(B.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Key Alias"}),(0,a.jsx)(W.Z,{children:"Secret Key"}),(0,a.jsx)(W.Z,{children:"Created"}),(0,a.jsx)(W.Z,{children:"Expires"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Budget Reset"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"Rate Limits"}),(0,a.jsx)(W.Z,{children:"Rate Limits per model"})]})}),(0,a.jsx)(z.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(ey.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||ey.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(q.Z,{children:null!=e.created_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,a.jsx)(q.Z,{children:null!=e.expires?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(q.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(q.Z,{children:null!=e.budget_reset_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{size:"xs",onClick:()=>ev(e),children:"Edit Limits"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{onClick:()=>{er(e),en(!0)},icon:R.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:et,onCancel:()=>{en(!1),er(null)},footer:null,width:800,children:ea&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(ea.spend).toFixed(4)}catch(e){return ea.spend}})()})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.max_budget?(0,a.jsxs)(a.Fragment,{children:[ea.max_budget,ea.budget_duration&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"Budget will be reset at ",ea.budget_reset_at?new Date(ea.budget_reset_at).toLocaleString():"Never"]})]}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.expires?(0,a.jsx)(a.Fragment,{children:new Date(ea.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(U.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:ea.key_alias?ea.key_alias:ea.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.token}),(0,a.jsx)(y.Z,{children:"User ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.user_id}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(ea.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{en(!1),er(null)},children:"Close"})]})}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>ek(e)}),(0,a.jsx)(V.Z,{onClick:()=>eA(e),icon:M.Z,size:"sm"}),(0,a.jsx)(V.Z,{onClick:()=>eN(e),icon:D.Z,size:"sm"})]})]},e.token)})})]}),Z&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:eI,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{f(!1),I(null)},children:"Cancel"})]})]})]})})]}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let Z=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,a.jsx)(w.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,a.jsxs)(S.Z,{form:o,onFinish:ew,initialValues:Z,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(X,{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,a.jsx)(X,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(X,{value:e,children:e},e)):ei.map(e=>(0,a.jsx)(X,{value:e,children:e},e))]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"daily",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"weekly",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"monthly",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,a.jsx)(G.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(J.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max tpm_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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,a.jsx)(Y.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:ea,onSubmit:ew}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:n,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,m]=(0,r.useState)([]),[h,x]=(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,u.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));m(l)}catch(e){console.error("Error fetching model data:",e),k.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,a.jsxs)(w.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model"}),(0,a.jsx)(W.Z,{children:"TPM Limit"}),(0,a.jsx)(W.Z,{children:"RPM Limit"}),(0,a.jsx)(W.Z,{children:"Actions"})]})}),(0,a.jsxs)(z.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:l}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(v.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),x(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,a.jsx)(X,{value:e,children:e},e))})}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>x(null),children:"Cancel"})})]})]})]}),(0,a.jsx)(p.Z,{onClick:()=>{x("")},disabled:null!==h,children:"Add Limit"})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,a.jsx)(p.Z,{onClick:s,children:"Cancel"}),(0,a.jsx)(p.Z,{onClick:()=>{n({...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:ea,onSubmit:eS,accessToken:t}),(0,a.jsx)(w.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),eZ.resetFields()},footer:[(0,a.jsx)(p.Z,{onClick:()=>{eh(!1),eZ.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,a.jsx)(p.Z,{onClick:eP,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,a.jsxs)(S.Z,{form:eZ,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eC("duration",e.duration)},children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{disabled:!0})}),(0,a.jsx)(S.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,a.jsx)(A.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==ea?void 0:ea.expires)!=null?new Date(ea.expires).toLocaleString():"Never"]}),ef&&(0,a.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",ef]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,a.jsx)(w.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,a.jsx)(p.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Regenerated Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,a.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,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"Key Alias:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==ea?void 0:ea.key_alias)||"No alias set"})}),(0,a.jsx)(_.Z,{className:"mt-3",children:"New API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,a.jsx)(b.CopyToClipboard,{text:ex,onCopy:()=>k.ZP.success("API Key copied to clipboard"),children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(n));let[d,c]=(0,r.useState)(null!==n?n:0),[m,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,u.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!==n&&c(n)},[n]);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,a.jsx)("div",{className:"flex items-center",children:(0,a.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})};console.log=function(){};var ee=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,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,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.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,a.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},el=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let m={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,u.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(m);return console.log("userRole: ".concat(n)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===n?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[m]:s?[...s,m]:[m],(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(_.Z,{className:"mt-3 mb-3",children:[(0,a.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,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},es=s(62105),et=s(49714),en=s(16330);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,premiumUser:j}=e,[g,Z]=(0,r.useState)(null),f=(0,i.useSearchParams)();f.get("viewSpend"),(0,i.useRouter)();let _=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),y=f.get("invitation_id"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)(null),C={models:[],team_alias:"Default Team",team_id:null},[P,E]=(0,r.useState)(t?t[0]:C);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(_){let e=(0,et.o)(_);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&&!n&&!g){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.g)(b);A(e);let t=await (0,u.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))),Z(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),E(n[0])):E(C),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,_,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=P&&null!==P.team_id){let e=0;for(let l of n)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[P]),null!=y)return(0,a.jsx)(es.default,{});if(null==l||null==_){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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(ee,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,a.jsx)(Q,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:S,selectedTeam:P||null}),(0,a.jsx)($,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:n,setData:p,premiumUser:j,teams:t}),(0,a.jsx)(T,{userID:l,team:P||null,userRole:s,accessToken:b,data:n,setData:p},P?P.team_id:null),(0,a.jsx)(el,{teams:t,setSelectedTeam:E,userRole:s,proxySettings:I,setProxySettings:A,userInfo:g,accessToken:b})]})})})},er=s(92411),ei=s(95299),eo=s(63789),ed=s(93466),ec=s(51782),em=s(174),eu=s(28260),eh=s(55083),ex=s(38848),ep=s(16039),ej=s(91499),eg=s(68551),eZ=s(95381),ef=s(77733),e_=s(69332),ey=s(46229),eb=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(V.Z,{onClick:()=>n(!0),icon:D.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ev=s(1071),eS=s(44611),ek=s(85272),ew=s(7416),eN=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ew.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,a.jsxs)("div",{children:[(0,a.jsx)(ek.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,a.jsx)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eI=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eA=s(28040);let{Title:eC,Link:eP}=en.default;(t=n||(n={})).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 eE={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"},eT={"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={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eE[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)n[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 k.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 t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eR=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:m,premiumUser:h}=e,[g,Z]=(0,r.useState)([]),[f]=S.Z.useForm(),[b,v]=(0,r.useState)(null),[N,I]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),T=Object.values(n).filter(e=>isNaN(Number(e))),[O,D]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[ek,ew]=(0,r.useState)(null),[eR,eF]=(0,r.useState)([]),[eM,eD]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[eV,eB]=(0,r.useState)([]),[ez,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)([]),[e5,e4]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e9]=(0,r.useState)(null),[e7,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,ln]=(0,r.useState)([]),[la,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 n=null==li?void 0:li.token;void 0===n&&(n=null);let a=ld;void 0===a&&(a=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,u.o6)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,u.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,u.N8)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let m=await (0,u.fP)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);if(console.log("slowResponses:",m),e4(m),e){let n=await (0,u.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(n);let a=await (0,u.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ln(a)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{ew(e),es(!0)},lp=e=>{ew(e),ea(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,n]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]=n:t=n;let n={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",n);try{await (0,u.um)(s,n),k.ZP.success("Model updated successfully, restart server to see updates"),es(!1),ew(null)}catch(e){console.log("Error occurred")}},lg=()=>{I(new Date().toLocaleString())},lZ=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,u.K_)(s,{router_settings:{model_group_retry_policy:e6}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.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,n,a,r,d,c,h,x,p,j;let g=await (0,u.hy)(s);D(g);let Z=await (0,u.AZ)(s,o,i);console.log("Model data response:",Z.data),m(Z);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",eL);let b=await (0,u.o6)(s,o,i,y,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,u.Rg)(s,y,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(n=e8.to)||void 0===n?void 0:n.toISOString());eG(v.data),eY(v.all_api_bases);let S=await (0,u.N8)(s,o,i,y,null===(a=e8.from)||void 0===a?void 0:a.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",S),e$(S.data),e0(S.exception_types);let k=await (0,u.fP)(s,o,i,y,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),w=await (0,u.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],y);ls(w);let N=await (0,u.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],y);ln(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e4(k);let I=await (0,u.j2)(s);lu(null==I?void 0:I.end_users);let A=(await (0,u.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e9(C),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,u.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),v(e)};null==b&&l(),lg()},[s,t,i,o,b,N]),!d||!s||!t||!i||!o)return(0,a.jsx)("div",{children:"Loading..."});let lf=[],l_=[];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];(a=t)||(a=1===e.length?u(s):l)}else a="-";n&&(r=null==n?void 0:n.input_cost_per_token,i=null==n?void 0:n.output_cost_per_token,o=null==n?void 0:n.max_tokens,c=null==n?void 0:n.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=a,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,l_.push(a),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,lf.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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lS=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eE[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.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))}},lk=async()=>{try{k.ZP.info("Running health check..."),ee("");let e=await (0,u.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lw=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),h?(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsx)(J.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsxs)(J.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsxs)(J.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!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,a.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,a.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,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.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 lA=Object.keys(n).find(e=>n[e]===X);return lA&&(l=O.find(e=>e.name===eE[lA])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eo.Z,{children:"All Models"}),(0,a.jsx)(eo.Z,{children:"Add Model"}),(0,a.jsx)(eo.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eo.Z,{children:"Model Analytics"}),(0,a.jsx)(eo.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[N&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",N]}),(0,a.jsx)(V.Z,{icon:M.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(G.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,a.jsx)(J.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,a.jsxs)(H.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.litellm_model_name,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.api_base,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&e.model_info.created_by||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(L.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(L.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:R.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(eb,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.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,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),ew(null)},model:ek,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:ek&&ek.model_name,visible:et,width:800,footer:null,onCancel:()=>{ea(!1),ew(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eA.Z,{language:"json",children:ek&&JSON.stringify(ek,null,2)})]})]}),(0,a.jsxs)(em.Z,{className:"h-full",children:[(0,a.jsx)(eC,{level:2,children:"Add new model"}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(S.Z,{form:f,onFinish:()=>{f.validateFields().then(e=>{eO(e,s,f)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(G.Z,{value:X.toString(),children:T.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lS(e),$(e)},children:e},l))})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsxs)(S.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,a.jsx)(S.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,a.jsx)(j.Z,{placeholder:lI(X.toString())}):P.length>0?(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(ex.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,a.jsx)(ex.Z,{value:e,children:e},l))]}):(0,a.jsx)(j.Z,{placeholder:lI(X.toString())})}),(0,a.jsx)(S.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,a.jsx)(S.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,a.jsx)(j.Z,{placeholder:"Enter custom model name"})})}})]}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eP,{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,a.jsx)(eI,{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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(eS.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;f.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(C.ZP,{icon:(0,a.jsx)(ev.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eP,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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,a.jsx)(Y.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eg.Z,{title:"Get help on our github",children:(0,a.jsx)(en.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:lk,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,a.jsxs)(eZ.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(G.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(e_.Z,{trigger:"click",content:lw,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eo.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ez&&eK&&(0,a.jsx)(ep.Z,{title:"Model Latency",className:"h-72",data:ez,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eN,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:h})})]})]})})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Deployment"}),(0,a.jsx)(W.Z,{children:"Success Responses"}),(0,a.jsxs)(W.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(z.Z,{children:e5.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.api_base}),(0,a.jsx)(q.Z,{children:e.total_count}),(0,a.jsx)(q.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,a.jsx)(ej.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eZ.Z,{})]})]}),h?(0,a.jsx)(a.Fragment,{children:lt.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(G.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,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eT&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eT).map((e,l)=>{var s;let[t,n]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[n];return null==r&&(r=e7),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(A.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e9(l=>{var s;let t=null!==(s=null==l?void 0:l[eL])&&void 0!==s?s:{};return{...null!=l?l:{},[eL]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eF=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=en.default,o=()=>(null==n?void 0:n.has_user_setup_sso)?"".concat(t,"/ui"):"".concat(t,"/ui?invitation_id=").concat(null==n?void 0:n.id);return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsx)(_.Z,{children:(0,a.jsx)(_.Z,{children:o()})})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:o(),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eM}=v.default;var eD=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o,d]=(0,r.useState)(null),[c]=S.Z.useForm(),[m,h]=(0,r.useState)(!1),[x,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)();console.log=function(){};let[E,T]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(P){let{protocol:e,host:l}=window.location;T("".concat(e,"/").concat(l))}},[P]);let O=async e=>{try{var t;k.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),g(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:a,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),b(!0)}else(0,u.XO)(s,a).then(e=>{e.has_user_setup_sso=!1,A(e),b(!0)});k.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eM,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eM,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),x&&(0,a.jsx)(eF,{isInvitationLinkModalVisible:y,setIsInvitationLinkModalVisible:b,baseUrl:E,invitationLinkData:N})]})},eL=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eU=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)(null),[f,_]=(0,r.useState)(1),[y,b]=r.useState(null),[v,S]=(0,r.useState)(null),[w,N]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(!1),[E,T]=(0,r.useState)(null),[O,R]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{T(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,u.Eb)(l,[E]),k.ZP.success("User deleted successfully"),h){let e=h.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),k.ZP.error("Failed to delete user")}P(!1),T(null)},J=async()=>{A(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}h&&j(h.map(l=>l.user_id===e.user_id?e:l)),A(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(f));if(e){let l=JSON.parse(e);m(l),j(l.users||[])}else{let e=await (0,u.Br)(l,null,n,!0,f,25);sessionStorage.setItem("userList_".concat(f),JSON.stringify(e)),m(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)R(JSON.parse(s));else{let e=await (0,u.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),R(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,f]),h&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eD,{userID:i,accessToken:l,teams:o,possibleUIRoles:O}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(ed.Z,{children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(B.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"User ID"}),(0,a.jsx)(W.Z,{children:"User Email"}),(0,a.jsx)(W.Z,{children:"Role"}),(0,a.jsx)(W.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(W.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(W.Z,{children:"API Keys"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:h.map(e=>{var l,s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_id||"-"}),(0,a.jsx)(q.Z,{children:e.user_email||"-"}),(0,a.jsx)(q.Z,{children:(null==O?void 0:null===(l=O[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(q.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(q.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e.key_count>0?(0,a.jsxs)(L.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,a.jsx)(L.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,onClick:()=>{A(e),N(!0)},children:"View Keys"}),(0,a.jsx)(V.Z,{icon:D.Z,onClick:()=>M(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,a.jsx)(eL,{visible:w,possibleUIRoles:O,onCancel:J,user:I,onSubmit:Y}),C&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,a.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{P(!1),T(null)},children:"Cancel"})]})]})]})})]}),function(){if(!h)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),_(e)};return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",f," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.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===f,onClick:()=>l(f-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:f===e,onClick:()=>l(f+1),children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})};console.log=function(){};var eV=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,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,u.It)(t,i):await (0,u.It)(t),console.log("givenTeams: ".concat(e)),n(e)})()},[l]);let[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=en.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[N,P]=(0,r.useState)(l?l[0]:null),[E,T]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)(!1),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)({}),et=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{ee(e),$(!0)},ei=async()=>{if(null!=Q&&null!=l&&null!=t){try{await (0,u.rs)(t,Q);let e=l.filter(e=>e.team_id!==Q);n(e)}catch(e){console.error("Error deleting the team:",e)}$(!1),ee(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,u.It)(t,i):await (0,u.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),Y(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),T(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:e.role,user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,N.team_id,s);k.ZP.success("Member added"),console.log("response for team create call: ".concat(a.data));let r=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}R(!1)}}catch(e){console.error("Error creating the team:",e)}};return(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Team Name"}),(0,a.jsx)(W.Z,{children:"Team ID"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(W.Z,{children:"Info"})]})}),(0,a.jsx)(z.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,a.jsx)(eg.Z,{title:e.team_id,children:e.team_id})}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(q.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,a.jsx)(q.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].keys&&el[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].members_with_roles&&el[e.team_id].members_with_roles.length," ","Members"]})]}),(0,a.jsx)(q.Z,{children:"Admin"==o?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>et(e)}),(0,a.jsx)(V.Z,{onClick:()=>er(e.team_id),icon:D.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),X&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{$(!1),ee(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>T(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:E,width:800,footer:null,onOk:()=>{T(!1),d.resetFields()},onCancel:()=>{T(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:N?N.members_with_roles.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(q.Z,{children:e.role})]},l)):null})]})}),N&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M&&M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:N,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:["Admin"==o||N&&(e=>{for(let l=0;lR(!0),children:"+ Add member"}):null,(0,a.jsx)(w.Z,{title:"Add member",visible:O,width:800,footer:null,onOk:()=>{R(!1),c.resetFields()},onCancel:()=>{R(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)(S.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,a.jsxs)(v.default,{defaultValue:"user",children:[(0,a.jsx)(v.default.Option,{value:"admin",children:"admin"}),(0,a.jsx)(v.default.Option,{value:"user",children:"user"})]})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eB=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n,premiumUser:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:j}=en.default,[g,Z]=(0,r.useState)(""),[f,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,M]=(0,r.useState)(!1),[D,L]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,et]=(0,r.useState)(!1),[ea,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){k.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,u.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),k.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,u.eH)(t,e.ip);let l=await (0,u.PT)(t);er(l),k.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),k.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),et(!0)},eZ=async()=>{if(ei&&t)try{await (0,u.$I)(t,ei);let e=await (0,u.PT)(t);er(e.length>0?e:[ex]),k.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),k.ZP.error("Failed to delete IP address ".concat(e))}finally{et(!1),eo(null)}},ef=()=>{X(!1)},e_=["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,u.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 n=(await (0,u.Xd)(t,"proxy_admin")).users;n.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(n)),console.log("combinedList: ".concat(e)),y(e),em(await (0,u.lg)(t))}})()},[t]);let ey=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(G.Z,{value:l,children:e_.map((e,l)=>(0,a.jsx)(J.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ew=async e=>{try{if(null!=t&&null!=f){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=f.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"),f.push(l),y(f)),k.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!=f){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)});let a=f.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(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=f){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)}),console.log("response for team create call: ".concat(s));let a=f.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eA=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,u.K_)(t,l)};return console.log("admins: ".concat(null==f?void 0:f.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(m,{level:4,children:"Admin Access "}),(0,a.jsxs)(j,{children:[n&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:f?f.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(q.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,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>M(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ey,onCancel:eb,children:eS(ew,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),c.resetFields(),d.resetFields()},onCancel:()=>{O(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,a.jsx)(eF,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,a.jsx)(w.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,a.jsxs)(x.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(m,{level:4,children:" ✨ Security Settings"}),(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:()=>!0===o?L(!0):k.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(w.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{L(!1),d.resetFields()},onCancel:()=>{L(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:e=>{eI(e),eA(e),L(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(I.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(I.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:ef,onCancel:()=>{X(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{onClick:ef,children:"Done"})})]}),(0,a.jsx)(w.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,a.jsx)(p.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"IP Address"}),(0,a.jsx)(W.Z,{className:"text-right",children:"Action"})]})}),(0,a.jsx)(z.Z,{children:ea.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e}),(0,a.jsx)(q.Z,{className:"text-right",children:e!==ex&&(0,a.jsx)(p.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,a.jsx)(w.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,a.jsxs)(S.Z,{onFinish:ej,children:[(0,a.jsx)(S.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,a.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,a.jsx)(S.Z.Item,{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,a.jsx)(w.Z,{title:"Confirm Delete",visible:es,onCancel:()=>et(!1),onOk:eZ,footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>eZ(),children:"Yes"},"delete"),(0,a.jsx)(p.Z,{onClick:()=>et(!1),children:"Close"},"close")],children:(0,a.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,a.jsxs)(ek.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},ez=s(22054),eq=s(26706),eK=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.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."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{align:"center",children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(S.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eW=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eK,{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))),n(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);n(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 n={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(n)));let{slack_alerting:a,...r}=n;console.log("slack_alerting: ".concat(a,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,u.jA)(l,"alerting_args",r),"boolean"==typeof a&&(!0==a?(0,u.jA)(l,"alerting",["slack"]):(0,u.jA)(l,"alerting",[])),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},eH=s(36031);let{Title:eG,Paragraph:eJ}=en.default;console.log=function(){};var eY=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)(!1),[M,D]=(0,r.useState)([]),[L,G]=(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)?T(E.filter(l=>l!==e)):T([...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,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),D(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),T(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let en=e=>E&&E.includes(e),ea=()=>{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,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.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,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},ei=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,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(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,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eo.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eo.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(eo.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(U.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(W.Z,{children:"Callback Name"})})}),(0,a.jsx)(z.Z,{children:i.map((e,s)=>(0,a.jsxs)(H.Z,{className:"flex justify-between",children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>R(!0),children:"Add Callback"})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(_.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)}):(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eW,{accessToken:l,premiumUser:n})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(q.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.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,a.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,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ea(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:O,width:800,onCancel:()=>R(!1),footer:null,children:[(0,a.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,a.jsx)(S.Z,{form:g,onFinish:ei,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eH.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,a.jsx)(J.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,a.jsx)(eH.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(eH.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eX}=v.default;var e$=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(G.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(eh.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eQ=s(45595);async function e0(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new eQ.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});k.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let e1={ttl:3600,lowest_latency_buffer:0},e2=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var e5=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,I]=(0,r.useState)(null),[C,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,u.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,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let T=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,u.K_)(l,{router_settings:i}),o({...i}),I(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},O=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},F=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},M=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eo.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eo.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.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,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,a.jsx)(q.Z,{children:"routing_strategy"==l?(0,a.jsxs)(G.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(J.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(J.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(J.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e2,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:e1,paramExplanation:E})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>M(i),children:"Save Changes"})})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model Name"}),(0,a.jsx)(W.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(z.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:t}),(0,a.jsx)(q.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>e0(t,l),children:"Test Fallback"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(e$,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"}),(0,a.jsx)(W.Z,{children:"Status"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(q.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>O(e.field_name,l)}):null}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>F(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e4=s(16873),e8=s(56115),e3=e=>{let{value:l={},onChange:s}=e,[t,n]=(0,r.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);n(l),null==s||s(Object.fromEntries(l))},o=(e,l,a)=>{let r=[...t];r[e]=[l,a],n(r),null==s||s(Object.fromEntries(r))};return(0,a.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(c.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,a.jsx)(j.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,a.jsx)(j.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,a.jsx)(e4.Z,{onClick:()=>i(l)})]},l)}),(0,a.jsx)(C.ZP,{type:"dashed",onClick:()=>{n([...t,["",""]])},icon:(0,a.jsx)(e8.Z,{}),children:"Add Header"})]})};let{Option:e6}=v.default;var e9=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,a.jsx)(w.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),n.resetFields()},onCancel:()=>{o(!1),n.resetFields()},children:(0,a.jsxs)(S.Z,{form:n,onFinish:e=>{console.log(e);let a=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,u.Vt)(l,e),s(a)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("Pass through endpoint successfully added"),o(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(e3,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},e7=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,u.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,u.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),k.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Path"}),(0,a.jsx)(W.Z,{children:"Target"}),(0,a.jsx)(W.Z,{children:"Headers"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:i.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.path})}),(0,a.jsx)(q.Z,{children:e.target}),(0,a.jsx)(q.Z,{children:JSON.stringify(e.headers)}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,a.jsx)(e9,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},le=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},ll=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=S.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call"),t(!0);let l=await (0,u.qI)(s,e);n(e=>e?[...e,l]:[l]),k.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Budget"})})]})})},ls=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{m(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))},x=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...c];t.splice(s,1),m(t),k.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,u.O3)(l).then(e=>{m(e)})};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(le,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,a.jsx)(ll,{accessToken:l,isModalVisible:n,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:j}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Budget ID"}),(0,a.jsx)(W.Z,{children:"Max Budget"}),(0,a.jsx)(W.Z,{children:"TPM"}),(0,a.jsx)(W.Z,{children:"RPM"})]})}),(0,a.jsx)(z.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.budget_id}),(0,a.jsx)(q.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(q.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(q.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>x(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eo.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eo.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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)'})})]})]})]})]})},lt=s(48357),ln=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(_.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,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eo.Z,{children:"LlamaIndex"}),(0,a.jsx)(eo.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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 ')})})]})]})]})})})};async function la(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let n=window.location.origin,a=new eQ.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lr=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await la(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(ec.Z,{children:(0,a.jsx)(eo.Z,{children:"Chat"})}),(0,a.jsx)(eu.Z,{children:(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(B.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{})})}),(0,a.jsx)(z.Z,{children:m.map((e,l)=>(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},li=s(16384),lo=s(71646);let{Sider:ld}=li.default,lc=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lm=[{key:"1",page:"api-keys",label:"Virtual Keys"},{key:"3",page:"llm-playground",label:"Test Key"},{key:"2",page:"models",label:"Models",roles:lc},{key:"4",page:"usage",label:"Usage"},{key:"6",page:"teams",label:"Teams"},{key:"5",page:"users",label:"Internal Users",roles:lc},{key:"8",page:"settings",label:"Logging & Alerts",roles:lc},{key:"9",page:"caching",label:"Caching",roles:lc},{key:"10",page:"budgets",label:"Budgets",roles:lc},{key:"11",page:"general-settings",label:"Router Settings",roles:lc},{key:"12",page:"pass-through-settings",label:"Pass-Through",roles:lc},{key:"13",page:"admin-panel",label:"Admin Settings",roles:lc},{key:"14",page:"api_ref",label:"API Reference"},{key:"16",page:"model-hub",label:"Model Hub"}];var lu=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,n=lm.find(e=>e.page===t),r=(null==n?void 0:n.key)||"1",i=lm.filter(e=>!e.roles||e.roles.includes(s));return(0,a.jsx)(li.default,{style:{minHeight:"100vh",maxWidth:"Admin Viewer"===s?"120px":"145px"},children:(0,a.jsx)(ld,{width:"Admin Viewer"===s?120:145,children:(0,a.jsx)(lo.Z,{mode:"inline",selectedKeys:[r],style:{height:"100%",borderRight:0},children:i.map(e=>(0,a.jsx)(lo.Z.Item,{onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)},children:(0,a.jsx)(_.Z,{children:e.label})},e.key))})})})},lh=s(90402),lx=s(64476);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lp=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lj=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,M]=(0,r.useState)({}),[D,L]=(0,r.useState)([]),[V,Y]=(0,r.useState)(""),[X,$]=(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),en=new Date(d.getFullYear(),d.getMonth(),1),ea=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(en),eZ=ev(ea);function ef(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 e_=async()=>{if(l)try{let e=await (0,u.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 ey=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 n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},eb=async(e,s)=>{if(!e||!s||!l)return;let t=await e_();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.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(eZ));let eS=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},ek=()=>eS(()=>l?(0,u.FC)(l):Promise.reject("No access token"),m,"Error fetching overall spend"),ew=()=>eS(()=>l&&s?(0,u.OU)(l,s,eg,eZ):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await eS(async()=>(await (0,u.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 eS(async()=>(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),f,"Error fetching top models")},eA=async()=>{l&&await eS(async()=>{let e=await (0,u.mR)(l);return k(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},T,"Error fetching team spend")},eC=()=>{l&&eS(async()=>(await (0,u.X)(l)).tag_names,A,"Error fetching tag names")},eP=()=>{l&&eS(()=>{var e,s;return(0,u.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&&eS(()=>(0,u.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eT=()=>{l&&eS(()=>(0,u.wd)(l,eg,eZ),M,"Error fetching global activity")},eO=()=>{l&&eS(()=>(0,u.xA)(l,eg,eZ),L,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&n){let e=await e_();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),ek(),ew(),eN(),eI(),eT(),eO(),lp(t)&&(eA(),eC(),eP(),eE()))}})()},[l,s,t,n,eg,eZ]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,a.jsxs)(_.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,a.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,a.jsx)(p.Z,{className:"mt-4",children:(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{className:"mt-2",children:[(0,a.jsx)(eo.Z,{children:"All Up"}),lp(t)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eo.Z,{children:"Team Based Usage"}),(0,a.jsx)(eo.Z,{children:"Customer Usage"}),(0,a.jsx)(eo.Z,{children:"Tag Based Usage"})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{})})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eo.Z,{children:"Cost"}),(0,a.jsx)(eo.Z,{children:"Activity"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(Q,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ej.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ej.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,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ej.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(lx.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Provider"}),(0,a.jsx)(W.Z,{children:"Spend"})]})}),(0,a.jsx)(z.Z,{children:O.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.provider}),(0,a.jsx)(q.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(F.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(F.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:D.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ef,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:D&&D.length>0&&D.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:ef,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lh.Z,{data:E})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ej.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.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,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),ey(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.Z,{value:"all-keys",onClick:()=>{ey(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,a.jsx)(J.Z,{value:String(l),onClick:()=>{ey(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(U.Z,{className:"mt-4",children:(0,a.jsxs)(B.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Customer"}),(0,a.jsx)(W.Z,{children:"Spend"}),(0,a.jsx)(W.Z,{children:"Total Events"})]})}),(0,a.jsx)(z.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.end_user}),(0,a.jsx)(q.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(q.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ei.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(ex.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(J.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ej.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})};let lg=e=>{if(e)return e.toISOString().split("T")[0]};function lZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lf=e=>{let{accessToken:l,token:s,userRole:t,userID:n,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,m]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,Z]=(0,r.useState)([]),[f,_]=(0,r.useState)("0"),[y,b]=(0,r.useState)("0"),[v,S]=(0,r.useState)("0"),[k,w]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&k&&(async()=>{Z(await (0,u.zg)(l,lg(k.from),lg(k.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 A=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,u.zg)(l,lg(e),lg(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,n=e.reduce((e,n)=>{console.log("Processing item:",n),n.call_type||(console.log("Item has no call_type:",n),n.call_type="Unknown"),l+=(n.total_rows||0)-(n.cache_hit_true_rows||0),s+=n.cache_hit_true_rows||0,t+=n.cached_completion_tokens||0;let a=e.find(e=>e.name===n.call_type);return a?(a["LLM API requests"]+=(n.total_rows||0)-(n.cache_hit_true_rows||0),a["Cache hit"]+=n.cache_hit_true_rows||0,a["Cached Completion Tokens"]+=n.cached_completion_tokens||0,a["Generated Completion Tokens"]+=n.generated_completion_tokens||0):e.push({name:n.call_type,"LLM API requests":(n.total_rows||0)-(n.cache_hit_true_rows||0),"Cache hit":n.cache_hit_true_rows||0,"Cached Completion Tokens":n.cached_completion_tokens||0,"Generated Completion Tokens":n.generated_completion_tokens||0}),e},[]);_(lZ(s)),b(lZ(t));let a=s+l;a>0?S((s/a*100).toFixed(2)):S("0"),d(n),console.log("PROCESSED DATA IN CACHE DASHBOARD",n)},[c,p,k,g]),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(x.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:N.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(ei.Z,{enableSelect:!0,value:k,onValueChange:e=>{w(e),A(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:f})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:y})})]})]}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,a.jsx)(ej.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,a.jsx)(ej.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l_=()=>{let{Title:e,Paragraph:l}=en.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[f,_]=(0,r.useState)(!0),y=(0,i.useSearchParams)(),[b,v]=(0,r.useState)({data:[]}),S=y.get("userID"),k=y.get("invitation_id"),w=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),[N,I]=(0,r.useState)(()=>y.get("page")||"api-keys"),[A,C]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(w){let e=(0,et.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),C(e.key),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&&I("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?_("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,u.K8)(e.auth_header_name)}}},[w]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:k?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:S,userRole:s,userEmail:d,premiumUser:n,setProxySettings:Z,proxySettings:g}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lu,{setPage:e=>{let l=new URLSearchParams(y);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),I(e)},userRole:s,defaultSelectedKey:N})}),"api-keys"==N?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):"models"==N?(0,a.jsx)(eR,{userID:S,userRole:s,token:w,keys:p,accessToken:A,modelData:b,setModelData:v,premiumUser:n}):"llm-playground"==N?(0,a.jsx)(lr,{userID:S,userRole:s,token:w,accessToken:A}):"users"==N?(0,a.jsx)(eU,{userID:S,userRole:s,token:w,keys:p,teams:h,accessToken:A,setKeys:j}):"teams"==N?(0,a.jsx)(eV,{teams:h,setTeams:x,searchParams:y,accessToken:A,userID:S,userRole:s}):"admin-panel"==N?(0,a.jsx)(eB,{setTeams:x,searchParams:y,accessToken:A,showSSOBanner:f,premiumUser:n}):"api_ref"==N?(0,a.jsx)(ln,{proxySettings:g}):"settings"==N?(0,a.jsx)(eY,{userID:S,userRole:s,accessToken:A,premiumUser:n}):"budgets"==N?(0,a.jsx)(ls,{accessToken:A}):"general-settings"==N?(0,a.jsx)(e5,{userID:S,userRole:s,accessToken:A,modelData:b}):"model-hub"==N?(0,a.jsx)(lt.Z,{accessToken:A,publicPage:!1,premiumUser:n}):"caching"==N?(0,a.jsx)(lf,{userID:S,userRole:s,token:w,accessToken:A,premiumUser:n}):"pass-through-settings"==N?(0,a.jsx)(e7,{userID:S,userRole:s,accessToken:A,modelData:b}):(0,a.jsx)(lj,{userID:S,userRole:s,token:w,accessToken:A,keys:p,premiumUser:n})]})]})})}},48357:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(57437),n=s(2265),a=s(16463),r=s(38939),i=s(15606),o=s(75203),d=s(63789),c=s(93466),m=s(51782),u=s(174),h=s(28260),x=s(29312),p=s(99295),j=s(97673),g=s(25858),Z=s(68551),f=s(45076),_=s(28040),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,E]=(0,n.useState)(null),T=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{E(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},F=()=>{I(!1),C(!1),E(null)},M=()=>{I(!1),C(!1),E(null)},D=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>D(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:F,onCancel:M,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{T.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:F,onCancel:M,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(P.model_group,'", # 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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="'.concat(P.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # 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="http://0.0.0.0:4000",\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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="http://0.0.0.0:4000",\n model = "'.concat(P.model_group,'",\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 ')})})]})]})]})})]})}}},function(e){e.O(0,[665,569,852,748,17,939,971,23,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 2537644b3f0d..522ef2d9bd83 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 61949640cad0..4040fbcbac9e 100644
--- a/litellm/proxy/_experimental/out/index.txt
+++ b/litellm/proxy/_experimental/out/index.txt
@@ -1,7 +1,7 @@
2:I[66513,[],"ClientPageRoot"]
-3:I[79642,["665","static/chunks/3014691f-0e3faeb6a30bdef5.js","569","static/chunks/569-fb5d4ecc1efc8220.js","852","static/chunks/852-8504c1dc77126607.js","748","static/chunks/748-ca0d88d4d972a1fe.js","17","static/chunks/17-dde5d33395f2c56a.js","939","static/chunks/939-446113ab9fc7760f.js","931","static/chunks/app/page-276b2ef886aa0b4e.js"],"default",1]
+3:I[79642,["665","static/chunks/3014691f-0e3faeb6a30bdef5.js","569","static/chunks/569-fb5d4ecc1efc8220.js","852","static/chunks/852-8504c1dc77126607.js","748","static/chunks/748-ca0d88d4d972a1fe.js","17","static/chunks/17-dde5d33395f2c56a.js","939","static/chunks/939-446113ab9fc7760f.js","931","static/chunks/app/page-0ad2ec54b8904803.js"],"default",1]
4:I[39275,[],""]
5:I[61343,[],""]
-0:["8r6NWZjV65MfTM9OwdJEV",[[["",{"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/0940e922324b3d86.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:["RGOvdwmDKbOr7ddjPRjMK",[[["",{"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/0940e922324b3d86.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 52783516ef5a..5b1276d2bced 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 6c9bfcd95f14..12d914c217c2 100644
--- a/litellm/proxy/_experimental/out/model_hub.txt
+++ b/litellm/proxy/_experimental/out/model_hub.txt
@@ -2,6 +2,6 @@
3:I[99327,["569","static/chunks/569-fb5d4ecc1efc8220.js","852","static/chunks/852-8504c1dc77126607.js","939","static/chunks/939-446113ab9fc7760f.js","418","static/chunks/app/model_hub/page-544de941cb7f8d17.js"],"default",1]
4:I[39275,[],""]
5:I[61343,[],""]
-0:["8r6NWZjV65MfTM9OwdJEV",[[["",{"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/0940e922324b3d86.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:["RGOvdwmDKbOr7ddjPRjMK",[[["",{"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/0940e922324b3d86.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 cd6d89c7eee9..b9619b97b412 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 8de78a0a4767..d7ebd3e1c0c4 100644
--- a/litellm/proxy/_experimental/out/onboarding.txt
+++ b/litellm/proxy/_experimental/out/onboarding.txt
@@ -2,6 +2,6 @@
3:I[62105,["665","static/chunks/3014691f-0e3faeb6a30bdef5.js","569","static/chunks/569-fb5d4ecc1efc8220.js","748","static/chunks/748-ca0d88d4d972a1fe.js","939","static/chunks/939-446113ab9fc7760f.js","461","static/chunks/app/onboarding/page-0b0af9deafd4cedf.js"],"default",1]
4:I[39275,[],""]
5:I[61343,[],""]
-0:["8r6NWZjV65MfTM9OwdJEV",[[["",{"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/0940e922324b3d86.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:["RGOvdwmDKbOr7ddjPRjMK",[[["",{"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/0940e922324b3d86.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 a91e20a4ac1d..eb587481b371 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/8r6NWZjV65MfTM9OwdJEV/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_buildManifest.js
similarity index 100%
rename from ui/litellm-dashboard/out/_next/static/8r6NWZjV65MfTM9OwdJEV/_buildManifest.js
rename to ui/litellm-dashboard/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_buildManifest.js
diff --git a/ui/litellm-dashboard/out/_next/static/8r6NWZjV65MfTM9OwdJEV/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_ssgManifest.js
similarity index 100%
rename from ui/litellm-dashboard/out/_next/static/8r6NWZjV65MfTM9OwdJEV/_ssgManifest.js
rename to ui/litellm-dashboard/out/_next/static/RGOvdwmDKbOr7ddjPRjMK/_ssgManifest.js
diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-276b2ef886aa0b4e.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-0ad2ec54b8904803.js
similarity index 85%
rename from ui/litellm-dashboard/out/_next/static/chunks/app/page-276b2ef886aa0b4e.js
rename to ui/litellm-dashboard/out/_next/static/chunks/app/page-0ad2ec54b8904803.js
index 887cef923c68..3d012e48ee2d 100644
--- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-276b2ef886aa0b4e.js
+++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-0ad2ec54b8904803.js
@@ -1 +1 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1900:function(e,l,s){Promise.resolve().then(s.bind(s,79642))},62105:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return f}});var t=s(57437),n=s(2265),a=s(16463),r=s(15606),i=s(85272),o=s(75203),d=s(56745),c=s(46430),m=s(29312),u=s(50586),h=s(99295),x=s(23152),p=s(38939),j=s(49714),g=s(26267),Z=s(46682);function f(){let[e]=g.Z.useForm(),l=(0,a.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"),[f,_]=(0,n.useState)(null),[y,b]=(0,n.useState)(""),[v,S]=(0,n.useState)(""),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(""),[A,C]=(0,n.useState)("");return(0,n.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);C(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),S(t.user_email),w(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:",f,"token:",A,"formValues:",e),f&&A&&(e.user_email=v,k&&s&&(0,p.m_)(f,s,k,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="+A,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)(Z.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},79642:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l_}});var t,n,a=s(57437),r=s(2265),i=s(16463),o=s(87138),d=s(71774),c=s(23288),m=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:n,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",n),console.log=function(){};let m="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(m=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",m);let u=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})},{key:"2",label:(0,a.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=m},children:"Logout"})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(o.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[n?null:(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterprise license"})}),(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:u},children:(0,a.jsx)(c.Z,{children:t||s})})})]})]})},u=s(38939),h=s(56745),x=s(46430),p=s(15606),j=s(50586),g=s(58759),Z=s(58748),f=s(32850),_=s(29312),y=s(99295),b=s(45789),v=s(29525),S=s(26267),k=s(58569),w=s(45076),N=s(59733),I=s(82832),A=s(62250),C=s(46682);let{Option:P}=v.default,E=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 T=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)(null),[M,D]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[V,B]=(0,r.useState)("you"),[z,q]=(0,r.useState)(E(i)),K=()=>{m(!1),d.resetFields()},W=()=>{m(!1),O(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),D(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let H=async e=>{try{var s,t,a;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!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(k.ZP.info("Making API Call"),m(!0),"service_account"===V){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 h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),O(h.key),F(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,a.jsxs)(S.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Owned By",className:"mb-4",children:(0,a.jsxs)(N.ZP.Group,{onChange:e=>B(e.target.value),value:V,children:[(0,a.jsx)(N.ZP,{value:"you",children:"You"}),(0,a.jsx)(N.ZP,{value:"service_account",children:"Service Account"})]})}),(0,a.jsx)(S.Z.Item,{label:"you"===V?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===V?"key name":"service account ID")}],help:"you"===V?"required":"IDs can include letters, numbers, and hyphens",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(P,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,a.jsx)(P,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)(S.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,a.jsx)(v.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:z})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),T&&(0,a.jsx)(w.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.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,a.jsx)(h.Z,{numColSpan:1,children:null!=T?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:T})}),(0,a.jsx)(b.CopyToClipboard,{text:T,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(17539),R=s(88795),F=s(94157),M=s(10823),D=s(17164),L=s(12299),U=s(75203),V=s(11887),B=s(38193),z=s(76971),q=s(49368),K=s(4207),W=s(72056),H=s(5594),G=s(39858),J=s(24155),Y=s(90797);let{Option:X}=v.default;console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d,premiumUser:c}=e,[m,g]=(0,r.useState)(!1),[Z,f]=(0,r.useState)(!1),[N,I]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[T,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,en]=(0,r.useState)(!1),[ea,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),[eZ]=S.Z.useForm(),[ef,e_]=(0,r.useState)(null),[ey,eb]=(0,r.useState)(ed);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",ea),(null==ej?void 0:ej.duration)?e_((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)):e_(null),console.log("calculateNewExpiryTime:",ef)},[ea,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.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 ev=e=>{er(e),em(!0)},eS=async e=>{if(null==t||null==ea)return;let l={...ea,metadata:e,key:ea.token};try{let e=await (0,u.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===ea.token?e:l);o(l)}k.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),k.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 ek=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)},ew=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),k.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,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),es(!1),er(null)},eN=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(I(e.token),localStorage.removeItem("userData"+l),f(!0))},eI=async()=>{if(null!=N&&null!=i){try{await (0,u.I1)(t,N);let e=i.filter(e=>e.token!==N);o(e)}catch(e){console.error("Error deleting the key:",e)}f(!1),I(null)}},eA=e=>{er(e),e_(null),eZ.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)},eC=(e,l)=>{eg(s=>({...s,[e]:l}))},eP=async()=>{if(!c){k.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=ea)try{let e=await eZ.validateFields(),l=await (0,u.s0)(t,ea.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==ea?void 0:ea.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),eZ.resetFields(),k.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),k.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(B.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Key Alias"}),(0,a.jsx)(W.Z,{children:"Secret Key"}),(0,a.jsx)(W.Z,{children:"Created"}),(0,a.jsx)(W.Z,{children:"Expires"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Budget Reset"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"Rate Limits"}),(0,a.jsx)(W.Z,{children:"Rate Limits per model"})]})}),(0,a.jsx)(z.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(ey.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||ey.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(q.Z,{children:null!=e.created_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,a.jsx)(q.Z,{children:null!=e.expires?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(q.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(q.Z,{children:null!=e.budget_reset_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{size:"xs",onClick:()=>ev(e),children:"Edit Limits"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{onClick:()=>{er(e),en(!0)},icon:R.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:et,onCancel:()=>{en(!1),er(null)},footer:null,width:800,children:ea&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(ea.spend).toFixed(4)}catch(e){return ea.spend}})()})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.max_budget?(0,a.jsxs)(a.Fragment,{children:[ea.max_budget,ea.budget_duration&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"Budget will be reset at ",ea.budget_reset_at?new Date(ea.budget_reset_at).toLocaleString():"Never"]})]}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.expires?(0,a.jsx)(a.Fragment,{children:new Date(ea.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(U.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:ea.key_alias?ea.key_alias:ea.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.token}),(0,a.jsx)(y.Z,{children:"User ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.user_id}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(ea.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{en(!1),er(null)},children:"Close"})]})}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>ek(e)}),(0,a.jsx)(V.Z,{onClick:()=>eA(e),icon:M.Z,size:"sm"}),(0,a.jsx)(V.Z,{onClick:()=>eN(e),icon:D.Z,size:"sm"})]})]},e.token)})})]}),Z&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:eI,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{f(!1),I(null)},children:"Cancel"})]})]})]})})]}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let Z=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,a.jsx)(w.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,a.jsxs)(S.Z,{form:o,onFinish:ew,initialValues:Z,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(X,{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,a.jsx)(X,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(X,{value:e,children:e},e)):ei.map(e=>(0,a.jsx)(X,{value:e,children:e},e))]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"daily",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"weekly",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"monthly",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,a.jsx)(G.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(J.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max tpm_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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,a.jsx)(Y.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:ea,onSubmit:ew}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:n,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,m]=(0,r.useState)([]),[h,x]=(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,u.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));m(l)}catch(e){console.error("Error fetching model data:",e),k.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,a.jsxs)(w.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model"}),(0,a.jsx)(W.Z,{children:"TPM Limit"}),(0,a.jsx)(W.Z,{children:"RPM Limit"}),(0,a.jsx)(W.Z,{children:"Actions"})]})}),(0,a.jsxs)(z.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:l}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(v.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),x(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,a.jsx)(X,{value:e,children:e},e))})}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>x(null),children:"Cancel"})})]})]})]}),(0,a.jsx)(p.Z,{onClick:()=>{x("")},disabled:null!==h,children:"Add Limit"})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,a.jsx)(p.Z,{onClick:s,children:"Cancel"}),(0,a.jsx)(p.Z,{onClick:()=>{n({...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:ea,onSubmit:eS,accessToken:t}),(0,a.jsx)(w.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),eZ.resetFields()},footer:[(0,a.jsx)(p.Z,{onClick:()=>{eh(!1),eZ.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,a.jsx)(p.Z,{onClick:eP,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,a.jsxs)(S.Z,{form:eZ,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eC("duration",e.duration)},children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{disabled:!0})}),(0,a.jsx)(S.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,a.jsx)(A.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==ea?void 0:ea.expires)!=null?new Date(ea.expires).toLocaleString():"Never"]}),ef&&(0,a.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",ef]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,a.jsx)(w.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,a.jsx)(p.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Regenerated Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,a.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,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"Key Alias:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==ea?void 0:ea.key_alias)||"No alias set"})}),(0,a.jsx)(_.Z,{className:"mt-3",children:"New API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,a.jsx)(b.CopyToClipboard,{text:ex,onCopy:()=>k.ZP.success("API Key copied to clipboard"),children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(n));let[d,c]=(0,r.useState)(null!==n?n:0),[m,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,u.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!==n&&c(n)},[n]);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,a.jsx)("div",{className:"flex items-center",children:(0,a.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})};console.log=function(){};var ee=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,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,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.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,a.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},el=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let m={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,u.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(m);return console.log("userRole: ".concat(n)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===n?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[m]:s?[...s,m]:[m],(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(_.Z,{className:"mt-3 mb-3",children:[(0,a.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,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},es=s(62105),et=s(49714),en=s(16330);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,premiumUser:j}=e,[g,Z]=(0,r.useState)(null),f=(0,i.useSearchParams)();f.get("viewSpend"),(0,i.useRouter)();let _=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),y=f.get("invitation_id"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)(null),C={models:[],team_alias:"Default Team",team_id:null},[P,E]=(0,r.useState)(t?t[0]:C);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(_){let e=(0,et.o)(_);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&&!n&&!g){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.g)(b);A(e);let t=await (0,u.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))),Z(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),E(n[0])):E(C),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,_,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=P&&null!==P.team_id){let e=0;for(let l of n)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[P]),null!=y)return(0,a.jsx)(es.default,{});if(null==l||null==_){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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(ee,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,a.jsx)(Q,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:S,selectedTeam:P||null}),(0,a.jsx)($,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:n,setData:p,premiumUser:j,teams:t}),(0,a.jsx)(T,{userID:l,team:P||null,userRole:s,accessToken:b,data:n,setData:p},P?P.team_id:null),(0,a.jsx)(el,{teams:t,setSelectedTeam:E,userRole:s,proxySettings:I,setProxySettings:A,userInfo:g,accessToken:b})]})})})},er=s(92411),ei=s(95299),eo=s(63789),ed=s(93466),ec=s(51782),em=s(174),eu=s(28260),eh=s(55083),ex=s(38848),ep=s(16039),ej=s(91499),eg=s(68551),eZ=s(95381),ef=s(77733),e_=s(69332),ey=s(46229),eb=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(V.Z,{onClick:()=>n(!0),icon:D.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ev=s(1071),eS=s(44611),ek=s(85272),ew=s(7416),eN=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ew.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,a.jsxs)("div",{children:[(0,a.jsx)(ek.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,a.jsx)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eI=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eA=s(28040);let{Title:eC,Link:eP}=en.default;(t=n||(n={})).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 eE={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"},eT={"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={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eE[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)n[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 k.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 t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eR=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:m,premiumUser:h}=e,[g,Z]=(0,r.useState)([]),[f]=S.Z.useForm(),[b,v]=(0,r.useState)(null),[N,I]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),T=Object.values(n).filter(e=>isNaN(Number(e))),[O,D]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[ek,ew]=(0,r.useState)(null),[eR,eF]=(0,r.useState)([]),[eM,eD]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[eV,eB]=(0,r.useState)([]),[ez,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)([]),[e5,e4]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e9]=(0,r.useState)(null),[e7,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,ln]=(0,r.useState)([]),[la,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 n=null==li?void 0:li.token;void 0===n&&(n=null);let a=ld;void 0===a&&(a=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,u.o6)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,u.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,u.N8)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let m=await (0,u.fP)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);if(console.log("slowResponses:",m),e4(m),e){let n=await (0,u.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(n);let a=await (0,u.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ln(a)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{ew(e),es(!0)},lp=e=>{ew(e),ea(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,n]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]=n:t=n;let n={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",n);try{await (0,u.um)(s,n),k.ZP.success("Model updated successfully, restart server to see updates"),es(!1),ew(null)}catch(e){console.log("Error occurred")}},lg=()=>{I(new Date().toLocaleString())},lZ=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,u.K_)(s,{router_settings:{model_group_retry_policy:e6}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.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,n,a,r,d,c,h,x,p,j;let g=await (0,u.hy)(s);D(g);let Z=await (0,u.AZ)(s,o,i);console.log("Model data response:",Z.data),m(Z);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",eL);let b=await (0,u.o6)(s,o,i,y,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,u.Rg)(s,y,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(n=e8.to)||void 0===n?void 0:n.toISOString());eG(v.data),eY(v.all_api_bases);let S=await (0,u.N8)(s,o,i,y,null===(a=e8.from)||void 0===a?void 0:a.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",S),e$(S.data),e0(S.exception_types);let k=await (0,u.fP)(s,o,i,y,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),w=await (0,u.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],y);ls(w);let N=await (0,u.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],y);ln(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e4(k);let I=await (0,u.j2)(s);lu(null==I?void 0:I.end_users);let A=(await (0,u.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e9(C),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,u.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),v(e)};null==b&&l(),lg()},[s,t,i,o,b,N]),!d||!s||!t||!i||!o)return(0,a.jsx)("div",{children:"Loading..."});let lf=[],l_=[];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];(a=t)||(a=1===e.length?u(s):l)}else a="-";n&&(r=null==n?void 0:n.input_cost_per_token,i=null==n?void 0:n.output_cost_per_token,o=null==n?void 0:n.max_tokens,c=null==n?void 0:n.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=a,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,l_.push(a),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,lf.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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lS=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eE[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.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))}},lk=async()=>{try{k.ZP.info("Running health check..."),ee("");let e=await (0,u.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lw=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),h?(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsx)(J.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsxs)(J.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsxs)(J.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!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,a.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,a.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,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.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 lA=Object.keys(n).find(e=>n[e]===X);return lA&&(l=O.find(e=>e.name===eE[lA])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eo.Z,{children:"All Models"}),(0,a.jsx)(eo.Z,{children:"Add Model"}),(0,a.jsx)(eo.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eo.Z,{children:"Model Analytics"}),(0,a.jsx)(eo.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[N&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",N]}),(0,a.jsx)(V.Z,{icon:M.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(G.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,a.jsx)(J.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,a.jsxs)(H.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.litellm_model_name,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.api_base,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&e.model_info.created_by||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(L.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(L.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:R.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(eb,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.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,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),ew(null)},model:ek,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:ek&&ek.model_name,visible:et,width:800,footer:null,onCancel:()=>{ea(!1),ew(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eA.Z,{language:"json",children:ek&&JSON.stringify(ek,null,2)})]})]}),(0,a.jsxs)(em.Z,{className:"h-full",children:[(0,a.jsx)(eC,{level:2,children:"Add new model"}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(S.Z,{form:f,onFinish:()=>{f.validateFields().then(e=>{eO(e,s,f)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(G.Z,{value:X.toString(),children:T.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lS(e),$(e)},children:e},l))})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsxs)(S.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,a.jsx)(S.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,a.jsx)(j.Z,{placeholder:lI(X.toString())}):P.length>0?(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(ex.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,a.jsx)(ex.Z,{value:e,children:e},l))]}):(0,a.jsx)(j.Z,{placeholder:lI(X.toString())})}),(0,a.jsx)(S.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,a.jsx)(S.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,a.jsx)(j.Z,{placeholder:"Enter custom model name"})})}})]}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eP,{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,a.jsx)(eI,{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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(eS.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;f.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(C.ZP,{icon:(0,a.jsx)(ev.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eP,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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,a.jsx)(Y.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eg.Z,{title:"Get help on our github",children:(0,a.jsx)(en.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:lk,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,a.jsxs)(eZ.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(G.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(e_.Z,{trigger:"click",content:lw,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eo.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ez&&eK&&(0,a.jsx)(ep.Z,{title:"Model Latency",className:"h-72",data:ez,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eN,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:h})})]})]})})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Deployment"}),(0,a.jsx)(W.Z,{children:"Success Responses"}),(0,a.jsxs)(W.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(z.Z,{children:e5.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.api_base}),(0,a.jsx)(q.Z,{children:e.total_count}),(0,a.jsx)(q.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,a.jsx)(ej.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eZ.Z,{})]})]}),h?(0,a.jsx)(a.Fragment,{children:lt.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(G.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,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eT&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eT).map((e,l)=>{var s;let[t,n]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[n];return null==r&&(r=e7),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(A.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e9(l=>{var s;let t=null!==(s=null==l?void 0:l[eL])&&void 0!==s?s:{};return{...null!=l?l:{},[eL]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eF=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=en.default,o=()=>(null==n?void 0:n.has_user_setup_sso)?"".concat(t,"/ui"):"".concat(t,"/ui?invitation_id=").concat(null==n?void 0:n.id);return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsx)(_.Z,{children:(0,a.jsx)(_.Z,{children:o()})})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:o(),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eM}=v.default;var eD=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o,d]=(0,r.useState)(null),[c]=S.Z.useForm(),[m,h]=(0,r.useState)(!1),[x,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)();console.log=function(){};let[E,T]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(P){let{protocol:e,host:l}=window.location;T("".concat(e,"/").concat(l))}},[P]);let O=async e=>{try{var t;k.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),g(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:a,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),b(!0)}else(0,u.XO)(s,a).then(e=>{e.has_user_setup_sso=!1,A(e),b(!0)});k.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eM,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eM,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),x&&(0,a.jsx)(eF,{isInvitationLinkModalVisible:y,setIsInvitationLinkModalVisible:b,baseUrl:E,invitationLinkData:N})]})},eL=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eU=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)(null),[f,_]=(0,r.useState)(1),[y,b]=r.useState(null),[v,S]=(0,r.useState)(null),[w,N]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(!1),[E,T]=(0,r.useState)(null),[O,R]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{T(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,u.Eb)(l,[E]),k.ZP.success("User deleted successfully"),h){let e=h.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),k.ZP.error("Failed to delete user")}P(!1),T(null)},J=async()=>{A(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}h&&j(h.map(l=>l.user_id===e.user_id?e:l)),A(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(f));if(e){let l=JSON.parse(e);m(l),j(l.users||[])}else{let e=await (0,u.Br)(l,null,n,!0,f,25);sessionStorage.setItem("userList_".concat(f),JSON.stringify(e)),m(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)R(JSON.parse(s));else{let e=await (0,u.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),R(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,f]),h&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eD,{userID:i,accessToken:l,teams:o,possibleUIRoles:O}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(ed.Z,{children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(B.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"User ID"}),(0,a.jsx)(W.Z,{children:"User Email"}),(0,a.jsx)(W.Z,{children:"Role"}),(0,a.jsx)(W.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(W.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(W.Z,{children:"API Keys"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:h.map(e=>{var l,s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_id||"-"}),(0,a.jsx)(q.Z,{children:e.user_email||"-"}),(0,a.jsx)(q.Z,{children:(null==O?void 0:null===(l=O[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(q.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(q.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e.key_count>0?(0,a.jsxs)(L.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,a.jsx)(L.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,onClick:()=>{A(e),N(!0)},children:"View Keys"}),(0,a.jsx)(V.Z,{icon:D.Z,onClick:()=>M(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,a.jsx)(eL,{visible:w,possibleUIRoles:O,onCancel:J,user:I,onSubmit:Y}),C&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,a.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{P(!1),T(null)},children:"Cancel"})]})]})]})})]}),function(){if(!h)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),_(e)};return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",f," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.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===f,onClick:()=>l(f-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:f===e,onClick:()=>l(f+1),children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})};console.log=function(){};var eV=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,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,u.It)(t,i):await (0,u.It)(t),console.log("givenTeams: ".concat(e)),n(e)})()},[l]);let[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=en.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[N,P]=(0,r.useState)(l?l[0]:null),[E,T]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)(!1),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)({}),et=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{ee(e),$(!0)},ei=async()=>{if(null!=Q&&null!=l&&null!=t){try{await (0,u.rs)(t,Q);let e=l.filter(e=>e.team_id!==Q);n(e)}catch(e){console.error("Error deleting the team:",e)}$(!1),ee(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,u.It)(t,i):await (0,u.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),Y(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),T(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:e.role,user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,N.team_id,s);k.ZP.success("Member added"),console.log("response for team create call: ".concat(a.data));let r=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}R(!1)}}catch(e){console.error("Error creating the team:",e)}};return(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Team Name"}),(0,a.jsx)(W.Z,{children:"Team ID"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(W.Z,{children:"Info"})]})}),(0,a.jsx)(z.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,a.jsx)(eg.Z,{title:e.team_id,children:e.team_id})}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(q.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,a.jsx)(q.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].keys&&el[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].members_with_roles&&el[e.team_id].members_with_roles.length," ","Members"]})]}),(0,a.jsx)(q.Z,{children:"Admin"==o?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>et(e)}),(0,a.jsx)(V.Z,{onClick:()=>er(e.team_id),icon:D.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),X&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{$(!1),ee(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>T(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:E,width:800,footer:null,onOk:()=>{T(!1),d.resetFields()},onCancel:()=>{T(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:N?N.members_with_roles.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(q.Z,{children:e.role})]},l)):null})]})}),N&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M&&M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:N,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:["Admin"==o||N&&(e=>{for(let l=0;lR(!0),children:"+ Add member"}):null,(0,a.jsx)(w.Z,{title:"Add member",visible:O,width:800,footer:null,onOk:()=>{R(!1),c.resetFields()},onCancel:()=>{R(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)(S.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,a.jsxs)(v.default,{defaultValue:"user",children:[(0,a.jsx)(v.default.Option,{value:"admin",children:"admin"}),(0,a.jsx)(v.default.Option,{value:"user",children:"user"})]})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eB=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n,premiumUser:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:j}=en.default,[g,Z]=(0,r.useState)(""),[f,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,M]=(0,r.useState)(!1),[D,L]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,et]=(0,r.useState)(!1),[ea,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){k.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,u.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),k.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,u.eH)(t,e.ip);let l=await (0,u.PT)(t);er(l),k.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),k.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),et(!0)},eZ=async()=>{if(ei&&t)try{await (0,u.$I)(t,ei);let e=await (0,u.PT)(t);er(e.length>0?e:[ex]),k.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),k.ZP.error("Failed to delete IP address ".concat(e))}finally{et(!1),eo(null)}},ef=()=>{X(!1)},e_=["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,u.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 n=(await (0,u.Xd)(t,"proxy_admin")).users;n.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(n)),console.log("combinedList: ".concat(e)),y(e),em(await (0,u.lg)(t))}})()},[t]);let ey=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(G.Z,{value:l,children:e_.map((e,l)=>(0,a.jsx)(J.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ew=async e=>{try{if(null!=t&&null!=f){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=f.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"),f.push(l),y(f)),k.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!=f){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)});let a=f.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(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=f){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)}),console.log("response for team create call: ".concat(s));let a=f.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eA=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,u.K_)(t,l)};return console.log("admins: ".concat(null==f?void 0:f.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(m,{level:4,children:"Admin Access "}),(0,a.jsxs)(j,{children:[n&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:f?f.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(q.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,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>M(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ey,onCancel:eb,children:eS(ew,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),c.resetFields(),d.resetFields()},onCancel:()=>{O(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,a.jsx)(eF,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,a.jsx)(w.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,a.jsxs)(x.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(m,{level:4,children:" ✨ Security Settings"}),(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:()=>!0===o?L(!0):k.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(w.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{L(!1),d.resetFields()},onCancel:()=>{L(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:e=>{eI(e),eA(e),L(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(I.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(I.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:ef,onCancel:()=>{X(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{onClick:ef,children:"Done"})})]}),(0,a.jsx)(w.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,a.jsx)(p.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"IP Address"}),(0,a.jsx)(W.Z,{className:"text-right",children:"Action"})]})}),(0,a.jsx)(z.Z,{children:ea.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e}),(0,a.jsx)(q.Z,{className:"text-right",children:e!==ex&&(0,a.jsx)(p.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,a.jsx)(w.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,a.jsxs)(S.Z,{onFinish:ej,children:[(0,a.jsx)(S.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,a.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,a.jsx)(S.Z.Item,{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,a.jsx)(w.Z,{title:"Confirm Delete",visible:es,onCancel:()=>et(!1),onOk:eZ,footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>eZ(),children:"Yes"},"delete"),(0,a.jsx)(p.Z,{onClick:()=>et(!1),children:"Close"},"close")],children:(0,a.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,a.jsxs)(ek.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},ez=s(22054),eq=s(26706),eK=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.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."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{align:"center",children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(S.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eW=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eK,{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))),n(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);n(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 n={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(n)));let{slack_alerting:a,...r}=n;console.log("slack_alerting: ".concat(a,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,u.jA)(l,"alerting_args",r),"boolean"==typeof a&&(!0==a?(0,u.jA)(l,"alerting",["slack"]):(0,u.jA)(l,"alerting",[])),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},eH=s(36031);let{Title:eG,Paragraph:eJ}=en.default;console.log=function(){};var eY=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)(!1),[M,D]=(0,r.useState)([]),[L,G]=(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)?T(E.filter(l=>l!==e)):T([...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,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),D(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),T(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let en=e=>E&&E.includes(e),ea=()=>{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,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.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,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},ei=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,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(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,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eo.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eo.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(eo.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(U.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(W.Z,{children:"Callback Name"})})}),(0,a.jsx)(z.Z,{children:i.map((e,s)=>(0,a.jsxs)(H.Z,{className:"flex justify-between",children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>R(!0),children:"Add Callback"})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(_.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)}):(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eW,{accessToken:l,premiumUser:n})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(q.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.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,a.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,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ea(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:O,width:800,onCancel:()=>R(!1),footer:null,children:[(0,a.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,a.jsx)(S.Z,{form:g,onFinish:ei,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eH.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,a.jsx)(J.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,a.jsx)(eH.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(eH.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eX}=v.default;var e$=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(G.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(eh.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eQ=s(45595);async function e0(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new eQ.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});k.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let e1={ttl:3600,lowest_latency_buffer:0},e2=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var e5=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,I]=(0,r.useState)(null),[C,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,u.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,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let T=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,u.K_)(l,{router_settings:i}),o({...i}),I(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},O=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},F=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},M=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eo.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eo.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.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,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,a.jsx)(q.Z,{children:"routing_strategy"==l?(0,a.jsxs)(G.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(J.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(J.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(J.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e2,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:e1,paramExplanation:E})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>M(i),children:"Save Changes"})})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model Name"}),(0,a.jsx)(W.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(z.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:t}),(0,a.jsx)(q.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>e0(t,l),children:"Test Fallback"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(e$,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"}),(0,a.jsx)(W.Z,{children:"Status"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(q.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>O(e.field_name,l)}):null}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>F(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e4=s(16873),e8=s(56115),e3=e=>{let{value:l={},onChange:s}=e,[t,n]=(0,r.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);n(l),null==s||s(Object.fromEntries(l))},o=(e,l,a)=>{let r=[...t];r[e]=[l,a],n(r),null==s||s(Object.fromEntries(r))};return(0,a.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(c.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,a.jsx)(j.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,a.jsx)(j.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,a.jsx)(e4.Z,{onClick:()=>i(l)})]},l)}),(0,a.jsx)(C.ZP,{type:"dashed",onClick:()=>{n([...t,["",""]])},icon:(0,a.jsx)(e8.Z,{}),children:"Add Header"})]})};let{Option:e6}=v.default;var e9=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,a.jsx)(w.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),n.resetFields()},onCancel:()=>{o(!1),n.resetFields()},children:(0,a.jsxs)(S.Z,{form:n,onFinish:e=>{console.log(e);let a=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,u.Vt)(l,e),s(a)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("Pass through endpoint successfully added"),o(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(e3,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},e7=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,u.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,u.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),k.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Path"}),(0,a.jsx)(W.Z,{children:"Target"}),(0,a.jsx)(W.Z,{children:"Headers"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:i.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.path})}),(0,a.jsx)(q.Z,{children:e.target}),(0,a.jsx)(q.Z,{children:JSON.stringify(e.headers)}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,a.jsx)(e9,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},le=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},ll=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=S.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call"),t(!0);let l=await (0,u.qI)(s,e);n(e=>e?[...e,l]:[l]),k.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Budget"})})]})})},ls=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{m(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))},x=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...c];t.splice(s,1),m(t),k.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,u.O3)(l).then(e=>{m(e)})};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(le,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,a.jsx)(ll,{accessToken:l,isModalVisible:n,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:j}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Budget ID"}),(0,a.jsx)(W.Z,{children:"Max Budget"}),(0,a.jsx)(W.Z,{children:"TPM"}),(0,a.jsx)(W.Z,{children:"RPM"})]})}),(0,a.jsx)(z.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.budget_id}),(0,a.jsx)(q.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(q.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(q.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>x(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eo.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eo.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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)'})})]})]})]})]})},lt=s(48357),ln=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(_.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,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eo.Z,{children:"LlamaIndex"}),(0,a.jsx)(eo.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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 ')})})]})]})]})})})};async function la(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let n=window.location.origin,a=new eQ.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lr=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await la(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(ec.Z,{children:(0,a.jsx)(eo.Z,{children:"Chat"})}),(0,a.jsx)(eu.Z,{children:(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(B.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{})})}),(0,a.jsx)(z.Z,{children:m.map((e,l)=>(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},li=s(16384),lo=s(71646);let{Sider:ld}=li.default,lc=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lm=[{key:"1",page:"api-keys",label:"Virtual Keys"},{key:"3",page:"llm-playground",label:"Test Key"},{key:"2",page:"models",label:"Models",roles:lc},{key:"4",page:"usage",label:"Usage"},{key:"6",page:"teams",label:"Teams"},{key:"5",page:"users",label:"Internal Users",roles:lc},{key:"8",page:"settings",label:"Logging & Alerts",roles:lc},{key:"9",page:"caching",label:"Caching",roles:lc},{key:"10",page:"budgets",label:"Budgets",roles:lc},{key:"11",page:"general-settings",label:"Router Settings",roles:lc},{key:"12",page:"pass-through-settings",label:"Pass-Through",roles:lc},{key:"13",page:"admin-panel",label:"Admin Settings",roles:lc},{key:"14",page:"api_ref",label:"API Reference"},{key:"16",page:"model-hub",label:"Model Hub"}];var lu=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,n=lm.find(e=>e.page===t),r=(null==n?void 0:n.key)||"1",i=lm.filter(e=>!e.roles||e.roles.includes(s));return(0,a.jsx)(li.default,{style:{minHeight:"100vh",maxWidth:"Admin Viewer"===s?"120px":"145px"},children:(0,a.jsx)(ld,{width:"Admin Viewer"===s?120:145,children:(0,a.jsx)(lo.Z,{mode:"inline",selectedKeys:[r],style:{height:"100%",borderRight:0},children:i.map(e=>(0,a.jsx)(lo.Z.Item,{onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)},children:(0,a.jsx)(_.Z,{children:e.label})},e.key))})})})},lh=s(90402),lx=s(64476);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lp=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lj=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,M]=(0,r.useState)({}),[D,L]=(0,r.useState)([]),[V,Y]=(0,r.useState)(""),[X,$]=(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),en=new Date(d.getFullYear(),d.getMonth(),1),ea=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(en),eZ=ev(ea);function ef(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 e_=async()=>{if(l)try{let e=await (0,u.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 ey=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 n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},eb=async(e,s)=>{e&&s&&l&&(null==es||!es.DISABLE_EXPENSIVE_DB_QUERIES)&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.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(eZ));let eS=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},ek=()=>eS(()=>l?(0,u.FC)(l):Promise.reject("No access token"),m,"Error fetching overall spend"),ew=()=>eS(()=>l&&s?(0,u.OU)(l,s,eg,eZ):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await eS(async()=>(await (0,u.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 eS(async()=>(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),f,"Error fetching top models")},eA=async()=>{l&&await eS(async()=>{let e=await (0,u.mR)(l);return k(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},T,"Error fetching team spend")},eC=()=>{l&&eS(async()=>(await (0,u.X)(l)).tag_names,A,"Error fetching tag names")},eP=()=>{l&&eS(()=>{var e,s;return(0,u.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&&eS(()=>(0,u.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eT=()=>{l&&eS(()=>(0,u.wd)(l,eg,eZ),M,"Error fetching global activity")},eO=()=>{l&&eS(()=>(0,u.xA)(l,eg,eZ),L,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&n){let e=await e_();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),ek(),ew(),eN(),eI(),eT(),eO(),lp(t)&&(eA(),eC(),eP(),eE()))}})()},[l,s,t,n,eg,eZ]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,a.jsxs)(_.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,a.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,a.jsx)(p.Z,{className:"mt-4",children:(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{className:"mt-2",children:[(0,a.jsx)(eo.Z,{children:"All Up"}),lp(t)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eo.Z,{children:"Team Based Usage"}),(0,a.jsx)(eo.Z,{children:"Customer Usage"}),(0,a.jsx)(eo.Z,{children:"Tag Based Usage"})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{})})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eo.Z,{children:"Cost"}),(0,a.jsx)(eo.Z,{children:"Activity"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(Q,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ej.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ej.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,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ej.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(lx.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Provider"}),(0,a.jsx)(W.Z,{children:"Spend"})]})}),(0,a.jsx)(z.Z,{children:O.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.provider}),(0,a.jsx)(q.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(F.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(F.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:D.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ef,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:D&&D.length>0&&D.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:ef,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lh.Z,{data:E})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ej.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.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,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),ey(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.Z,{value:"all-keys",onClick:()=>{ey(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,a.jsx)(J.Z,{value:String(l),onClick:()=>{ey(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(U.Z,{className:"mt-4",children:(0,a.jsxs)(B.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Customer"}),(0,a.jsx)(W.Z,{children:"Spend"}),(0,a.jsx)(W.Z,{children:"Total Events"})]})}),(0,a.jsx)(z.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.end_user}),(0,a.jsx)(q.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(q.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ei.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(ex.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(J.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ej.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})};let lg=e=>{if(e)return e.toISOString().split("T")[0]};function lZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lf=e=>{let{accessToken:l,token:s,userRole:t,userID:n,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,m]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,Z]=(0,r.useState)([]),[f,_]=(0,r.useState)("0"),[y,b]=(0,r.useState)("0"),[v,S]=(0,r.useState)("0"),[k,w]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&k&&(async()=>{Z(await (0,u.zg)(l,lg(k.from),lg(k.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 A=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,u.zg)(l,lg(e),lg(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,n=e.reduce((e,n)=>{console.log("Processing item:",n),n.call_type||(console.log("Item has no call_type:",n),n.call_type="Unknown"),l+=(n.total_rows||0)-(n.cache_hit_true_rows||0),s+=n.cache_hit_true_rows||0,t+=n.cached_completion_tokens||0;let a=e.find(e=>e.name===n.call_type);return a?(a["LLM API requests"]+=(n.total_rows||0)-(n.cache_hit_true_rows||0),a["Cache hit"]+=n.cache_hit_true_rows||0,a["Cached Completion Tokens"]+=n.cached_completion_tokens||0,a["Generated Completion Tokens"]+=n.generated_completion_tokens||0):e.push({name:n.call_type,"LLM API requests":(n.total_rows||0)-(n.cache_hit_true_rows||0),"Cache hit":n.cache_hit_true_rows||0,"Cached Completion Tokens":n.cached_completion_tokens||0,"Generated Completion Tokens":n.generated_completion_tokens||0}),e},[]);_(lZ(s)),b(lZ(t));let a=s+l;a>0?S((s/a*100).toFixed(2)):S("0"),d(n),console.log("PROCESSED DATA IN CACHE DASHBOARD",n)},[c,p,k,g]),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(x.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:N.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(ei.Z,{enableSelect:!0,value:k,onValueChange:e=>{w(e),A(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:f})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:y})})]})]}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,a.jsx)(ej.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,a.jsx)(ej.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l_=()=>{let{Title:e,Paragraph:l}=en.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[f,_]=(0,r.useState)(!0),y=(0,i.useSearchParams)(),[b,v]=(0,r.useState)({data:[]}),S=y.get("userID"),k=y.get("invitation_id"),w=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),[N,I]=(0,r.useState)(()=>y.get("page")||"api-keys"),[A,C]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(w){let e=(0,et.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),C(e.key),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&&I("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?_("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,u.K8)(e.auth_header_name)}}},[w]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:k?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:S,userRole:s,userEmail:d,premiumUser:n,setProxySettings:Z,proxySettings:g}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lu,{setPage:e=>{let l=new URLSearchParams(y);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),I(e)},userRole:s,defaultSelectedKey:N})}),"api-keys"==N?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):"models"==N?(0,a.jsx)(eR,{userID:S,userRole:s,token:w,keys:p,accessToken:A,modelData:b,setModelData:v,premiumUser:n}):"llm-playground"==N?(0,a.jsx)(lr,{userID:S,userRole:s,token:w,accessToken:A}):"users"==N?(0,a.jsx)(eU,{userID:S,userRole:s,token:w,keys:p,teams:h,accessToken:A,setKeys:j}):"teams"==N?(0,a.jsx)(eV,{teams:h,setTeams:x,searchParams:y,accessToken:A,userID:S,userRole:s}):"admin-panel"==N?(0,a.jsx)(eB,{setTeams:x,searchParams:y,accessToken:A,showSSOBanner:f,premiumUser:n}):"api_ref"==N?(0,a.jsx)(ln,{proxySettings:g}):"settings"==N?(0,a.jsx)(eY,{userID:S,userRole:s,accessToken:A,premiumUser:n}):"budgets"==N?(0,a.jsx)(ls,{accessToken:A}):"general-settings"==N?(0,a.jsx)(e5,{userID:S,userRole:s,accessToken:A,modelData:b}):"model-hub"==N?(0,a.jsx)(lt.Z,{accessToken:A,publicPage:!1,premiumUser:n}):"caching"==N?(0,a.jsx)(lf,{userID:S,userRole:s,token:w,accessToken:A,premiumUser:n}):"pass-through-settings"==N?(0,a.jsx)(e7,{userID:S,userRole:s,accessToken:A,modelData:b}):(0,a.jsx)(lj,{userID:S,userRole:s,token:w,accessToken:A,keys:p,premiumUser:n})]})]})})}},48357:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(57437),n=s(2265),a=s(16463),r=s(38939),i=s(15606),o=s(75203),d=s(63789),c=s(93466),m=s(51782),u=s(174),h=s(28260),x=s(29312),p=s(99295),j=s(97673),g=s(25858),Z=s(68551),f=s(45076),_=s(28040),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,E]=(0,n.useState)(null),T=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{E(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},F=()=>{I(!1),C(!1),E(null)},M=()=>{I(!1),C(!1),E(null)},D=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>D(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:F,onCancel:M,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{T.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:F,onCancel:M,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(P.model_group,'", # 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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="'.concat(P.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # 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="http://0.0.0.0:4000",\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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="http://0.0.0.0:4000",\n model = "'.concat(P.model_group,'",\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 ')})})]})]})]})})]})}}},function(e){e.O(0,[665,569,852,748,17,939,971,23,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,79642))},62105:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return f}});var t=s(57437),n=s(2265),a=s(16463),r=s(15606),i=s(85272),o=s(75203),d=s(56745),c=s(46430),m=s(29312),u=s(50586),h=s(99295),x=s(23152),p=s(38939),j=s(49714),g=s(26267),Z=s(46682);function f(){let[e]=g.Z.useForm(),l=(0,a.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"),[f,_]=(0,n.useState)(null),[y,b]=(0,n.useState)(""),[v,S]=(0,n.useState)(""),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(""),[A,C]=(0,n.useState)("");return(0,n.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);C(s),console.log("decoded:",t),_(t.key),console.log("decoded user email:",t.user_email),S(t.user_email),w(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:",f,"token:",A,"formValues:",e),f&&A&&(e.user_email=v,k&&s&&(0,p.m_)(f,s,k,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="+A,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)(Z.ZP,{htmlType:"submit",children:"Sign Up"})})]})]})})}},79642:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return l_}});var t,n,a=s(57437),r=s(2265),i=s(16463),o=s(87138),d=s(71774),c=s(23288),m=e=>{let{userID:l,userRole:s,userEmail:t,premiumUser:n,setProxySettings:r,proxySettings:i}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("premiumUser:",n),console.log=function(){};let m="";console.log("PROXY_settings=",i),i&&i.PROXY_LOGOUT_URL&&void 0!==i.PROXY_LOGOUT_URL&&(m=i.PROXY_LOGOUT_URL),console.log("logoutUrl=",m);let u=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})},{key:"2",label:(0,a.jsx)("p",{onClick:()=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=m},children:"Logout"})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(o.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[n?null:(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterprise license"})}),(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:u},children:(0,a.jsx)(c.Z,{children:t||s})})})]})]})},u=s(38939),h=s(56745),x=s(46430),p=s(15606),j=s(50586),g=s(58759),Z=s(58748),f=s(32850),_=s(29312),y=s(99295),b=s(45789),v=s(29525),S=s(26267),k=s(58569),w=s(45076),N=s(59733),I=s(82832),A=s(62250),C=s(46682);let{Option:P}=v.default,E=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 T=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)(null),[M,D]=(0,r.useState)([]),[L,U]=(0,r.useState)([]),[V,B]=(0,r.useState)("you"),[z,q]=(0,r.useState)(E(i)),K=()=>{m(!1),d.resetFields()},W=()=>{m(!1),O(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),D(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let H=async e=>{try{var s,t,a;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!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));if(k.ZP.info("Making API Call"),m(!0),"service_account"===V){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 h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),O(h.key),F(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{U(s&&s.models.length>0?s.models.includes("all-proxy-models")?M:s.models:M)},[s,M]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:K,onCancel:W,children:(0,a.jsxs)(S.Z,{form:d,onFinish:H,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Owned By",className:"mb-4",children:(0,a.jsxs)(N.ZP.Group,{onChange:e=>B(e.target.value),value:V,children:[(0,a.jsx)(N.ZP,{value:"you",children:"You"}),(0,a.jsx)(N.ZP,{value:"service_account",children:"Service Account"})]})}),(0,a.jsx)(S.Z.Item,{label:"you"===V?"Key Name":"Service Account ID",name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===V?"key name":"service account ID")}],help:"you"===V?"required":"IDs can include letters, numbers, and hyphens",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(P,{value:"all-team-models",children:"All Team Models"},"all-team-models"),L.map(e=>(0,a.jsx)(P,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)(S.Z.Item,{label:"Tags",name:"tags",className:"mt-8",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,a.jsx)(v.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:z})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Key"})})]})}),T&&(0,a.jsx)(w.Z,{visible:c,onOk:K,onCancel:W,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.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,a.jsx)(h.Z,{numColSpan:1,children:null!=T?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:T})}),(0,a.jsx)(b.CopyToClipboard,{text:T,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},O=s(17539),R=s(88795),F=s(94157),M=s(10823),D=s(17164),L=s(12299),U=s(75203),V=s(11887),B=s(38193),z=s(76971),q=s(49368),K=s(4207),W=s(72056),H=s(5594),G=s(39858),J=s(24155),Y=s(90797);let{Option:X}=v.default;console.log=function(){};var $=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d,premiumUser:c}=e,[m,g]=(0,r.useState)(!1),[Z,f]=(0,r.useState)(!1),[N,I]=(0,r.useState)(null),[P,E]=(0,r.useState)(null),[T,$]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,en]=(0,r.useState)(!1),[ea,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),[eZ]=S.Z.useForm(),[ef,e_]=(0,r.useState)(null),[ey,eb]=(0,r.useState)(ed);(0,r.useEffect)(()=>{console.log("in calculateNewExpiryTime for selectedToken",ea),(null==ej?void 0:ej.duration)?e_((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)):e_(null),console.log("calculateNewExpiryTime:",ef)},[ea,null==ej?void 0:ej.duration]),(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.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 ev=e=>{er(e),em(!0)},eS=async e=>{if(null==t||null==ea)return;let l={...ea,metadata:e,key:ea.token};try{let e=await (0,u.Nc)(t,l);if(console.log("Model limits updated:",e),i){let l=i.map(l=>l.token===ea.token?e:l);o(l)}k.ZP.success("Model-specific limits updated successfully")}catch(e){console.error("Error updating model-specific limits:",e),k.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 ek=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)},ew=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),k.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,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),es(!1),er(null)},eN=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(I(e.token),localStorage.removeItem("userData"+l),f(!0))},eI=async()=>{if(null!=N&&null!=i){try{await (0,u.I1)(t,N);let e=i.filter(e=>e.token!==N);o(e)}catch(e){console.error("Error deleting the key:",e)}f(!1),I(null)}},eA=e=>{er(e),e_(null),eZ.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)},eC=(e,l)=>{eg(s=>({...s,[e]:l}))},eP=async()=>{if(!c){k.ZP.error("Regenerate API Key is an Enterprise feature. Please upgrade to use this feature.");return}if(null!=ea)try{let e=await eZ.validateFields(),l=await (0,u.s0)(t,ea.token,e);if(ep(l.key),i){let s=i.map(s=>s.token===(null==ea?void 0:ea.token)?{...s,key_name:l.key_name,...e}:s);o(s)}eh(!1),eZ.resetFields(),k.ZP.success("API Key regenerated successfully")}catch(e){console.error("Error regenerating key:",e),k.ZP.error("Failed to regenerate API Key")}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(B.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Key Alias"}),(0,a.jsx)(W.Z,{children:"Secret Key"}),(0,a.jsx)(W.Z,{children:"Created"}),(0,a.jsx)(W.Z,{children:"Expires"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Budget Reset"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"Rate Limits"}),(0,a.jsx)(W.Z,{children:"Rate Limits per model"})]})}),(0,a.jsx)(z.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(ey.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||ey.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(q.Z,{children:null!=e.created_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.created_at).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Not available"})}),(0,a.jsx)(q.Z,{children:null!=e.expires?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.expires).toLocaleDateString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(q.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(q.Z,{children:null!=e.budget_reset_at?(0,a.jsx)("div",{children:(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:new Date(e.budget_reset_at).toLocaleString()})}):(0,a.jsx)("p",{style:{fontSize:"0.70rem"},children:"Never"})}),(0,a.jsx)(q.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{size:"xs",onClick:()=>ev(e),children:"Edit Limits"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{onClick:()=>{er(e),en(!0)},icon:R.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:et,onCancel:()=>{en(!1),er(null)},footer:null,width:800,children:ea&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(ea.spend).toFixed(4)}catch(e){return ea.spend}})()})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.max_budget?(0,a.jsxs)(a.Fragment,{children:[ea.max_budget,ea.budget_duration&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"Budget will be reset at ",ea.budget_reset_at?new Date(ea.budget_reset_at).toLocaleString():"Never"]})]}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=ea.expires?(0,a.jsx)(a.Fragment,{children:new Date(ea.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(U.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:ea.key_alias?ea.key_alias:ea.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.token}),(0,a.jsx)(y.Z,{children:"User ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:ea.user_id}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(ea.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{en(!1),er(null)},children:"Close"})]})}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>ek(e)}),(0,a.jsx)(V.Z,{onClick:()=>eA(e),icon:M.Z,size:"sm"}),(0,a.jsx)(V.Z,{onClick:()=>eN(e),icon:D.Z,size:"sm"})]})]},e.token)})})]}),Z&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:eI,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{f(!1),I(null)},children:"Cancel"})]})]})]})})]}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1),g="";try{g=JSON.stringify(t.metadata,null,2)}catch(e){console.error("Error stringifying metadata:",e),g=""}let Z=t?{...t,budget_duration:t.budget_duration,metadata:g}:{metadata:g};return(0,a.jsx)(w.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,a.jsxs)(S.Z,{form:o,onFinish:ew,initialValues:Z,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(X,{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,a.jsx)(X,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(X,{value:e,children:e},e)):ei.map(e=>(0,a.jsx)(X,{value:e,children:e},e))]})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.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,a.jsxs)(v.default,{placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"daily",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"weekly",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"monthly",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",className:"mt-8",help:"the team this key belongs to",children:(0,a.jsx)(G.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(J.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"RPM Limit (requests per minute)",name:"rpm_limit",help:"rpm_limit cannot exceed team max tpm_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,a.jsx)(A.Z,{step:1,precision:1,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Metadata (ensure this is valid JSON)",name:"metadata",children:(0,a.jsx)(Y.Z,{rows:10,onChange:e=>{o.setFieldsValue({metadata:e.target.value})}})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:el,onCancel:()=>{es(!1),er(null)},token:ea,onSubmit:ew}),ea&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:n,accessToken:i}=e,[o,d]=(0,r.useState)({}),[c,m]=(0,r.useState)([]),[h,x]=(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,u.AZ)(i,"",""),l=Array.from(new Set(e.data.map(e=>e.model_name)));m(l)}catch(e){console.error("Error fetching model data:",e),k.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,a.jsxs)(w.Z,{title:"Edit Model-Specific Limits",visible:l,onCancel:s,footer:null,width:800,children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model"}),(0,a.jsx)(W.Z,{children:"TPM Limit"}),(0,a.jsx)(W.Z,{children:"RPM Limit"}),(0,a.jsx)(W.Z,{children:"Actions"})]})}),(0,a.jsxs)(z.Z,{children:[Object.entries(o).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:l}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.tpm,onChange:e=>j(l,"tpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(A.Z,{value:s.rpm,onChange:e=>j(l,"rpm",e)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>g(l),children:"Remove"})})]},l)}),null!==h&&(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(v.default,{style:{width:200},placeholder:"Select a model",onChange:e=>{o[e]||d(l=>({...l,[e]:{tpm:0,rpm:0}})),x(null)},value:h||void 0,children:c.filter(e=>!o.hasOwnProperty(e)).map(e=>(0,a.jsx)(X,{value:e,children:e},e))})}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:"-"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>x(null),children:"Cancel"})})]})]})]}),(0,a.jsx)(p.Z,{onClick:()=>{x("")},disabled:null!==h,children:"Add Limit"})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-4 mt-6",children:[(0,a.jsx)(p.Z,{onClick:s,children:"Cancel"}),(0,a.jsx)(p.Z,{onClick:()=>{n({...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:ea,onSubmit:eS,accessToken:t}),(0,a.jsx)(w.Z,{title:"Regenerate API Key",visible:eu,onCancel:()=>{eh(!1),eZ.resetFields()},footer:[(0,a.jsx)(p.Z,{onClick:()=>{eh(!1),eZ.resetFields()},className:"mr-2",children:"Cancel"},"cancel"),(0,a.jsx)(p.Z,{onClick:eP,disabled:!c,children:c?"Regenerate":"Upgrade to Regenerate"},"regenerate")],children:c?(0,a.jsxs)(S.Z,{form:eZ,layout:"vertical",onValuesChange:(e,l)=>{"duration"in e&&eC("duration",e.duration)},children:[(0,a.jsx)(S.Z.Item,{name:"key_alias",label:"Key Alias",children:(0,a.jsx)(j.Z,{disabled:!0})}),(0,a.jsx)(S.Z.Item,{name:"max_budget",label:"Max Budget (USD)",children:(0,a.jsx)(A.Z,{step:.01,precision:2,style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"tpm_limit",label:"TPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"rpm_limit",label:"RPM Limit",children:(0,a.jsx)(A.Z,{style:{width:"100%"}})}),(0,a.jsx)(S.Z.Item,{name:"duration",label:"Expire Key (eg: 30s, 30h, 30d)",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsxs)("div",{className:"mt-2 text-sm text-gray-500",children:["Current expiry: ",(null==ea?void 0:ea.expires)!=null?new Date(ea.expires).toLocaleString():"Never"]}),ef&&(0,a.jsxs)("div",{className:"mt-2 text-sm text-green-600",children:["New expiry: ",ef]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",children:"Get Free Trial"})})]})}),ex&&(0,a.jsx)(w.Z,{visible:!!ex,onCancel:()=>ep(null),footer:[(0,a.jsx)(p.Z,{onClick:()=>ep(null),children:"Close"},"close")],children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Regenerated Key"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please replace your old key with the new key generated. For security reasons, ",(0,a.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,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(_.Z,{className:"mt-3",children:"Key Alias:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:(null==ea?void 0:ea.key_alias)||"No alias set"})}),(0,a.jsx)(_.Z,{className:"mt-3",children:"New API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ex})}),(0,a.jsx)(b.CopyToClipboard,{text:ex,onCopy:()=>k.ZP.success("API Key copied to clipboard"),children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]})]})})]})};console.log=function(){};var Q=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,userMaxBudget:i,selectedTeam:o}=e;console.log("userSpend: ".concat(n));let[d,c]=(0,r.useState)(null!==n?n:0),[m,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,u.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!==n&&c(n)},[n]);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,a.jsx)("div",{className:"flex items-center",children:(0,a.jsxs)("div",{className:"flex justify-between gap-x-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",g]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Max Budget"}),(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null!==m?"$".concat(m," limit"):"No limit"})]})]})})};console.log=function(){};var ee=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,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,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.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,a.jsxs)("p",{className:"text-xs text-gray-400 dark:text-gray-400 font-semibold",children:["Team ID: ",null==t?void 0:t.team_id]})]})})},el=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n,proxySettings:i,setProxySettings:o,userInfo:d,accessToken:c}=e;console.log("userInfo: ".concat(JSON.stringify(d)));let m={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,u.g)(c))};(0,r.useEffect)(()=>{h()},[i]);let[x,p]=(0,r.useState)(m);return console.log("userRole: ".concat(n)),console.log("proxySettings: ".concat(JSON.stringify(i))),l="App User"===n?s:i&&!0===i.DEFAULT_TEAM_DISABLED?s?[...s]:[m]:s?[...s,m]:[m],(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(_.Z,{className:"mt-3 mb-3",children:[(0,a.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,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},es=s(62105),et=s(49714),en=s(16330);console.log=function(){},console.log("isLocal:",!1);var ea=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,premiumUser:j}=e,[g,Z]=(0,r.useState)(null),f=(0,i.useSearchParams)();f.get("viewSpend"),(0,i.useRouter)();let _=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),y=f.get("invitation_id"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)(null),C={models:[],team_alias:"Default Team",team_id:null},[P,E]=(0,r.useState)(t?t[0]:C);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(_){let e=(0,et.o)(_);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&&!n&&!g){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.g)(b);A(e);let t=await (0,u.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))),Z(t.user_info),console.log("userSpendData: ".concat(JSON.stringify(g))),p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),E(n[0])):E(C),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,_,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=P&&null!==P.team_id){let e=0;for(let l of n)P.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===P.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[P]),null!=y)return(0,a.jsx)(es.default,{});if(null==l||null==_){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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",P),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(ee,{userID:l,userRole:s,selectedTeam:P||null,accessToken:b}),(0,a.jsx)(Q,{userID:l,userRole:s,userMaxBudget:(null==g?void 0:g.max_budget)||null,accessToken:b,userSpend:S,selectedTeam:P||null}),(0,a.jsx)($,{userID:l,userRole:s,accessToken:b,selectedTeam:P||null,data:n,setData:p,premiumUser:j,teams:t}),(0,a.jsx)(T,{userID:l,team:P||null,userRole:s,accessToken:b,data:n,setData:p},P?P.team_id:null),(0,a.jsx)(el,{teams:t,setSelectedTeam:E,userRole:s,proxySettings:I,setProxySettings:A,userInfo:g,accessToken:b})]})})})},er=s(92411),ei=s(95299),eo=s(63789),ed=s(93466),ec=s(51782),em=s(174),eu=s(28260),eh=s(55083),ex=s(38848),ep=s(16039),ej=s(91499),eg=s(68551),eZ=s(95381),ef=s(77733),e_=s(69332),ey=s(46229),eb=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(V.Z,{onClick:()=>n(!0),icon:D.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ev=s(1071),eS=s(44611),ek=s(85272),ew=s(7416),eN=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ew.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,a.jsxs)("div",{children:[(0,a.jsx)(ek.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,a.jsx)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eI=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},eA=s(28040);let{Title:eC,Link:eP}=en.default;(t=n||(n={})).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 eE={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"},eT={"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={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l){console.log("custom_llm_provider:",s);let e=eE[s];t.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==l)continue;else if("base_model"===l)n[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 k.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 t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eR=e=>{let l,{accessToken:s,token:t,userRole:i,userID:o,modelData:d={data:[]},keys:c,setModelData:m,premiumUser:h}=e,[g,Z]=(0,r.useState)([]),[f]=S.Z.useForm(),[b,v]=(0,r.useState)(null),[N,I]=(0,r.useState)(""),[P,E]=(0,r.useState)([]),T=Object.values(n).filter(e=>isNaN(Number(e))),[O,D]=(0,r.useState)([]),[X,$]=(0,r.useState)("OpenAI"),[Q,ee]=(0,r.useState)(""),[el,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(!1),[ek,ew]=(0,r.useState)(null),[eR,eF]=(0,r.useState)([]),[eM,eD]=(0,r.useState)([]),[eL,eU]=(0,r.useState)(null),[eV,eB]=(0,r.useState)([]),[ez,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)([]),[e5,e4]=(0,r.useState)([]),[e8,e3]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e6,e9]=(0,r.useState)(null),[e7,le]=(0,r.useState)(0),[ll,ls]=(0,r.useState)({}),[lt,ln]=(0,r.useState)([]),[la,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 n=null==li?void 0:li.token;void 0===n&&(n=null);let a=ld;void 0===a&&(a=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),t.setHours(23),t.setMinutes(59),t.setSeconds(59);try{let r=await (0,u.o6)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model metrics response:",r),eq(r.data),eW(r.all_api_bases);let d=await (0,u.Rg)(s,e,l.toISOString(),t.toISOString());eG(d.data),eY(d.all_api_bases);let c=await (0,u.N8)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);console.log("Model exceptions response:",c),e$(c.data),e0(c.exception_types);let m=await (0,u.fP)(s,o,i,e,l.toISOString(),t.toISOString(),n,a);if(console.log("slowResponses:",m),e4(m),e){let n=await (0,u.n$)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ls(n);let a=await (0,u.v9)(s,null==l?void 0:l.toISOString().split("T")[0],null==t?void 0:t.toISOString().split("T")[0],e);ln(a)}}catch(e){console.error("Failed to fetch model metrics",e)}};(0,r.useEffect)(()=>{lh(eL,e8.from,e8.to)},[li,ld]);let lx=e=>{ew(e),es(!0)},lp=e=>{ew(e),ea(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==s)return;let l={},t=null;for(let[s,n]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]=n:t=n;let n={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",n);try{await (0,u.um)(s,n),k.ZP.success("Model updated successfully, restart server to see updates"),es(!1),ew(null)}catch(e){console.log("Error occurred")}},lg=()=>{I(new Date().toLocaleString())},lZ=async()=>{if(!s){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e6);try{await (0,u.K_)(s,{router_settings:{model_group_retry_policy:e6}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.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,n,a,r,d,c,h,x,p,j;let g=await (0,u.hy)(s);D(g);let Z=await (0,u.AZ)(s,o,i);console.log("Model data response:",Z.data),m(Z);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y)),console.log("selectedModelGroup:",eL);let b=await (0,u.o6)(s,o,i,y,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,u.Rg)(s,y,null===(t=e8.from)||void 0===t?void 0:t.toISOString(),null===(n=e8.to)||void 0===n?void 0:n.toISOString());eG(v.data),eY(v.all_api_bases);let S=await (0,u.N8)(s,o,i,y,null===(a=e8.from)||void 0===a?void 0:a.toISOString(),null===(r=e8.to)||void 0===r?void 0:r.toISOString(),null==li?void 0:li.token,ld);console.log("Model exceptions response:",S),e$(S.data),e0(S.exception_types);let k=await (0,u.fP)(s,o,i,y,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),w=await (0,u.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],y);ls(w);let N=await (0,u.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],y);ln(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e4(k);let I=await (0,u.j2)(s);lu(null==I?void 0:I.end_users);let A=(await (0,u.BL)(s,o,i)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e9(C),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,u.qm)(s);console.log("received model cost map data: ".concat(Object.keys(e))),v(e)};null==b&&l(),lg()},[s,t,i,o,b,N]),!d||!s||!t||!i||!o)return(0,a.jsx)("div",{children:"Loading..."});let lf=[],l_=[];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];(a=t)||(a=1===e.length?u(s):l)}else a="-";n&&(r=null==n?void 0:n.input_cost_per_token,i=null==n?void 0:n.output_cost_per_token,o=null==n?void 0:n.max_tokens,c=null==n?void 0:n.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=a,d.data[e].input_cost=r,d.data[e].output_cost=i,d.data[e].litellm_model_name=s,l_.push(a),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,lf.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}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lS=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eE[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof b&&(Object.entries(b).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.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))}},lk=async()=>{try{k.ZP.info("Running health check..."),ee("");let e=await (0,u.EY)(s);ee(e)}catch(e){console.error("Error running health check:",e),ee("Error running health check")}},lw=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),h?(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsx)(J.Z,{value:String(l),onClick:()=>{lo(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lc(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.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,a.jsxs)(J.Z,{value:String(l),disabled:!0,onClick:()=>{lo(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(G.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(J.Z,{value:"all-customers",onClick:()=>{lc(null)},children:"All Customers"},"all-customers"),null==lm?void 0:lm.map((e,l)=>(0,a.jsxs)(J.Z,{value:e,disabled:!0,onClick:()=>{lc(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lN=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!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,a.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,a.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,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.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 lA=Object.keys(n).find(e=>n[e]===X);return lA&&(l=O.find(e=>e.name===eE[lA])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eo.Z,{children:"All Models"}),(0,a.jsx)(eo.Z,{children:"Add Model"}),(0,a.jsx)(eo.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eo.Z,{children:"Model Analytics"}),(0,a.jsx)(eo.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[N&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",N]}),(0,a.jsx)(V.Z,{icon:M.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(G.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,a.jsx)(J.Z,{value:"all",children:"All Models"}),eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"LiteLLM Model"}),"Admin"===i&&(0,a.jsx)(W.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(W.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:h?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(W.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:d.data.filter(e=>"all"===eL||e.model_name===eL||null==eL||""===eL).map((e,l)=>{var t;return(0,a.jsxs)(H.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.litellm_model_name,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eg.Z,{title:e&&e.api_base,children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.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,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&((t=e.model_info.created_at)?new Date(t).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:h&&e.model_info.created_by||"-"})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(L.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(L.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:R.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(eb,{modelID:e.model_info.id,accessToken:s})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.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,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"organization",name:"organization",tooltip:"OpenAI Organization ID",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.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,a.jsx)(A.Z,{min:0,step:.01})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:el,onCancel:()=>{es(!1),ew(null)},model:ek,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:ek&&ek.model_name,visible:et,width:800,footer:null,onCancel:()=>{ea(!1),ew(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eA.Z,{language:"json",children:ek&&JSON.stringify(ek,null,2)})]})]}),(0,a.jsxs)(em.Z,{className:"h-full",children:[(0,a.jsx)(eC,{level:2,children:"Add new model"}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(S.Z,{form:f,onFinish:()=>{f.validateFields().then(e=>{eO(e,s,f)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(G.Z,{value:X.toString(),children:T.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>{lS(e),$(e)},children:e},l))})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsxs)(S.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"Actual model name used for making litellm.completion() / litellm.embedding() call.",className:"mb-0",children:[(0,a.jsx)(S.Z.Item,{name:"model",rules:[{required:!0,message:"Required"}],noStyle:!0,children:"Azure"===X||"OpenAI-Compatible Endpoints (Together AI, etc.)"===X||"Ollama"===X?(0,a.jsx)(j.Z,{placeholder:lI(X.toString())}):P.length>0?(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(ex.Z,{value:"custom",children:"Custom Model Name (Enter below)"}),P.map((e,l)=>(0,a.jsx)(ex.Z,{value:e,children:e},l))]}):(0,a.jsx)(j.Z,{placeholder:lI(X.toString())})}),(0,a.jsx)(S.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:l}=e;return(l("model")||[]).includes("custom")&&(0,a.jsx)(S.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name"}],className:"mt-2",children:(0,a.jsx)(j.Z,{placeholder:"Enter custom model name"})})}})]}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eP,{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,a.jsx)(eI,{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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==X&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(eS.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;f.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(C.ZP,{icon:(0,a.jsx)(ev.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==X&&(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsx)(_.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,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==X&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eP,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),"Amazon Bedrock"==X&&(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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,a.jsx)(Y.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ef.Z,{children:[(0,a.jsx)(eZ.Z,{span:10}),(0,a.jsx)(eZ.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eP,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eg.Z,{title:"Get help on our github",children:(0,a.jsx)(en.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:lk,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:e8,className:"mr-2",onValueChange:e=>{e3(e),lh(eL,e.from,e.to)}})]}),(0,a.jsxs)(eZ.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(G.Z,{defaultValue:eL||eR[0],value:eL||eR[0],children:eR.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>lh(e,e8.from,e8.to),children:e},l))})]}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(e_.Z,{trigger:"click",content:lw,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:ey.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>lr(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eo.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),ez&&eK&&(0,a.jsx)(ep.Z,{title:"Model Latency",className:"h-72",data:ez,showLegend:!1,index:"date",categories:eK,connectNulls:!0,customTooltip:lN})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eN,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lN,premiumUser:h})})]})]})})}),(0,a.jsx)(eZ.Z,{children:(0,a.jsx)(U.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Deployment"}),(0,a.jsx)(W.Z,{children:"Success Responses"}),(0,a.jsxs)(W.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(z.Z,{children:e5.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.api_base}),(0,a.jsx)(q.Z,{children:e.total_count}),(0,a.jsx)(q.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Exceptions for ",eL]}),(0,a.jsx)(ej.Z,{className:"h-60",data:eX,index:"model",categories:eQ,stack:!0,yAxisWidth:30})]})}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eL]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ll.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:ll.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eZ.Z,{})]})]}),h?(0,a.jsx)(a.Fragment,{children:lt.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:lt&<.length>0&<.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eZ.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(G.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,a.jsx)(J.Z,{value:e,onClick:()=>eU(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eL]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eT&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eT).map((e,l)=>{var s;let[t,n]=e,r=null==e6?void 0:null===(s=e6[eL])||void 0===s?void 0:s[n];return null==r&&(r=e7),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(A.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e9(l=>{var s;let t=null!==(s=null==l?void 0:l[eL])&&void 0!==s?s:{};return{...null!=l?l:{},[eL]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eF=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=en.default,o=()=>(null==n?void 0:n.has_user_setup_sso)?"".concat(t,"/ui"):"".concat(t,"/ui?invitation_id=").concat(null==n?void 0:n.id);return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsx)(_.Z,{children:(0,a.jsx)(_.Z,{children:o()})})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:o(),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eM}=v.default;var eD=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o,d]=(0,r.useState)(null),[c]=S.Z.useForm(),[m,h]=(0,r.useState)(!1),[x,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[N,A]=(0,r.useState)(null),P=(0,i.useRouter)();console.log=function(){};let[E,T]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(P){let{protocol:e,host:l}=window.location;T("".concat(e,"/").concat(l))}},[P]);let O=async e=>{try{var t;k.ZP.info("Making API Call"),h(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),g(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;if(null==o?void 0:o.SSO_ENABLED){let e={id:crypto.randomUUID(),user_id:a,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),b(!0)}else(0,u.XO)(s,a).then(e=>{e.has_user_setup_sso=!1,A(e),b(!0)});k.ZP.success("API user Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>h(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:m,width:800,footer:null,onOk:()=>{h(!1),c.resetFields()},onCancel:()=>{h(!1),g(null),c.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:c,onFinish:O,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eM,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eM,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(I.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create User"})})]})]}),x&&(0,a.jsx)(eF,{isInvitationLinkModalVisible:y,setIsInvitationLinkModalVisible:b,baseUrl:E,invitationLinkData:N})]})},eL=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(J.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(A.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})}):null};console.log=function(){};var eU=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)(null),[f,_]=(0,r.useState)(1),[y,b]=r.useState(null),[v,S]=(0,r.useState)(null),[w,N]=(0,r.useState)(!1),[I,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(!1),[E,T]=(0,r.useState)(null),[O,R]=(0,r.useState)({});window.addEventListener("beforeunload",function(){sessionStorage.clear()});let M=e=>{T(e),P(!0)},G=async()=>{if(E&&l)try{if(await (0,u.Eb)(l,[E]),k.ZP.success("User deleted successfully"),h){let e=h.filter(e=>e.user_id!==E);j(e)}}catch(e){console.error("Error deleting user:",e),k.ZP.error("Failed to delete user")}P(!1),T(null)},J=async()=>{A(null),N(!1)},Y=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}h&&j(h.map(l=>l.user_id===e.user_id?e:l)),A(null),N(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=sessionStorage.getItem("userList_".concat(f));if(e){let l=JSON.parse(e);m(l),j(l.users||[])}else{let e=await (0,u.Br)(l,null,n,!0,f,25);sessionStorage.setItem("userList_".concat(f),JSON.stringify(e)),m(e),j(e.users||[])}let s=sessionStorage.getItem("possibleUserRoles");if(s)R(JSON.parse(s));else{let e=await (0,u.lg)(l);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),R(e)}}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,f]),h&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eD,{userID:i,accessToken:l,teams:o,possibleUIRoles:O}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(ed.Z,{children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(B.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"User ID"}),(0,a.jsx)(W.Z,{children:"User Email"}),(0,a.jsx)(W.Z,{children:"Role"}),(0,a.jsx)(W.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(W.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(W.Z,{children:"API Keys"}),(0,a.jsx)(W.Z,{})]})}),(0,a.jsx)(z.Z,{children:h.map(e=>{var l,s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_id||"-"}),(0,a.jsx)(q.Z,{children:e.user_email||"-"}),(0,a.jsx)(q.Z,{children:(null==O?void 0:null===(l=O[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(q.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(q.Z,{children:null!==e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e.key_count>0?(0,a.jsxs)(L.Z,{size:"xs",color:"indigo",children:[e.key_count," Keys"]}):(0,a.jsx)(L.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,onClick:()=>{A(e),N(!0)},children:"View Keys"}),(0,a.jsx)(V.Z,{icon:D.Z,onClick:()=>M(e.user_id),children:"Delete"})]})]},e.user_id)})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})}),(0,a.jsx)(eL,{visible:w,possibleUIRoles:O,onCancel:J,user:I,onSubmit:Y}),C&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete User"}),(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this user?"}),(0,a.jsxs)("p",{className:"text-sm font-medium text-gray-900 mt-2",children:["User ID: ",E]})]})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:G,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{P(!1),T(null)},children:"Cancel"})]})]})]})})]}),function(){if(!h)return null;let e=(null==c?void 0:c.total_pages)||0,l=e=>{j([]),_(e)};return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",f," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.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===f,onClick:()=>l(f-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:f===e,onClick:()=>l(f+1),children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})};console.log=function(){};var eV=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,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,u.It)(t,i):await (0,u.It)(t),console.log("givenTeams: ".concat(e)),n(e)})()},[l]);let[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=en.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[N,P]=(0,r.useState)(l?l[0]:null),[E,T]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1),[M,Y]=(0,r.useState)([]),[X,$]=(0,r.useState)(!1),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)({}),et=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{ee(e),$(!0)},ei=async()=>{if(null!=Q&&null!=l&&null!=t){try{await (0,u.rs)(t,Q);let e=l.filter(e=>e.team_id!==Q);n(e)}catch(e){console.error("Error deleting the team:",e)}$(!1),ee(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,u.It)(t,i):await (0,u.It)(t);for(let l=0;l{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),Y(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),T(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:e.role,user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,N.team_id,s);k.ZP.success("Member added"),console.log("response for team create call: ".concat(a.data));let r=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}R(!1)}}catch(e){console.error("Error creating the team:",e)}};return(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Team Name"}),(0,a.jsx)(W.Z,{children:"Team ID"}),(0,a.jsx)(W.Z,{children:"Spend (USD)"}),(0,a.jsx)(W.Z,{children:"Budget (USD)"}),(0,a.jsx)(W.Z,{children:"Models"}),(0,a.jsx)(W.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(W.Z,{children:"Info"})]})}),(0,a.jsx)(z.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.75em"},children:(0,a.jsx)(eg.Z,{title:e.team_id,children:e.team_id})}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(q.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,a.jsx)(q.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(L.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(q.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].keys&&el[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[el&&e.team_id&&el[e.team_id]&&el[e.team_id].members_with_roles&&el[e.team_id].members_with_roles.length," ","Members"]})]}),(0,a.jsx)(q.Z,{children:"Admin"==o?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>et(e)}),(0,a.jsx)(V.Z,{onClick:()=>er(e.team_id),icon:D.Z,size:"sm"})]}):null})]},e.team_id)):null})]}),X&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.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,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,a.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,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{$(!1),ee(null)},children:"Cancel"})]})]})]})})]})]}),"Admin"==o?(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>T(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:E,width:800,footer:null,onOk:()=>{T(!1),d.resetFields()},onCancel:()=>{T(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}):null,(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(G.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(J.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:N?N.members_with_roles.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(q.Z,{children:e.role})]},l)):null})]})}),N&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),M&&M.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(A.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:N,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:["Admin"==o||N&&(e=>{for(let l=0;lR(!0),children:"+ Add member"}):null,(0,a.jsx)(w.Z,{title:"Add member",visible:O,width:800,footer:null,onOk:()=>{R(!1),c.resetFields()},onCancel:()=>{R(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{role:"user"},children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(I.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)(S.Z.Item,{label:"Member Role",name:"role",className:"mb-4",children:(0,a.jsxs)(v.default,{defaultValue:"user",children:[(0,a.jsx)(v.default.Option,{value:"admin",children:"admin"}),(0,a.jsx)(v.default.Option,{value:"user",children:"user"})]})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eB=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n,premiumUser:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:j}=en.default,[g,Z]=(0,r.useState)(""),[f,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[N,A]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,M]=(0,r.useState)(!1),[D,L]=(0,r.useState)(!1),[Y,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(!1),[es,et]=(0,r.useState)(!1),[ea,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){k.ZP.error("This feature is only available for premium users. Please upgrade your account.");return}if(t){let e=await (0,u.PT)(t);er(e&&e.length>0?e:[ex])}else er([ex])}catch(e){console.error("Error fetching allowed IPs:",e),k.ZP.error("Failed to fetch allowed IPs ".concat(e)),er([ex])}finally{!0===o&&Q(!0)}},ej=async e=>{try{if(t){await (0,u.eH)(t,e.ip);let l=await (0,u.PT)(t);er(l),k.ZP.success("IP address added successfully")}}catch(e){console.error("Error adding IP:",e),k.ZP.error("Failed to add IP address ".concat(e))}finally{el(!1)}},eg=async e=>{eo(e),et(!0)},eZ=async()=>{if(ei&&t)try{await (0,u.$I)(t,ei);let e=await (0,u.PT)(t);er(e.length>0?e:[ex]),k.ZP.success("IP address deleted successfully")}catch(e){console.error("Error deleting IP:",e),k.ZP.error("Failed to delete IP address ".concat(e))}finally{et(!1),eo(null)}},ef=()=>{X(!1)},e_=["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,u.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 n=(await (0,u.Xd)(t,"proxy_admin")).users;n.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(n)),console.log("combinedList: ".concat(e)),y(e),em(await (0,u.lg)(t))}})()},[t]);let ey=()=>{M(!1),c.resetFields(),d.resetFields()},eb=()=>{M(!1),c.resetFields(),d.resetFields()},ev=e=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(I.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add member"})})]}),eS=(e,l,s)=>(0,a.jsxs)(S.Z,{form:d,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(G.Z,{value:l,children:e_.map((e,l)=>(0,a.jsx)(J.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(I.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update role"})})]}),ew=async e=>{try{if(null!=t&&null!=f){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=f.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"),f.push(l),y(f)),k.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!=f){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)});let a=f.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(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),E(!1)}}catch(e){console.error("Error creating the key:",e)}},eI=async e=>{try{if(null!=t&&null!=f){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{v(e),A(!0)}),console.log("response for team create call: ".concat(s));let a=f.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),f.push(s),y(f)),d.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eA=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,u.K_)(t,l)};return console.log("admins: ".concat(null==f?void 0:f.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(m,{level:4,children:"Admin Access "}),(0,a.jsxs)(j,{children:[n&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc."," ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(U.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Member Name"}),(0,a.jsx)(W.Z,{children:"Role"})]})}),(0,a.jsx)(z.Z,{children:f?f.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(q.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,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>M(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ey,onCancel:eb,children:eS(ew,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),c.resetFields(),d.resetFields()},onCancel:()=>{O(!1),A(!1),c.resetFields(),d.resetFields()},children:ev(eI)}),(0,a.jsx)(eF,{isInvitationLinkModalVisible:N,setIsInvitationLinkModalVisible:A,baseUrl:eu,invitationLinkData:b}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>E(!0),children:"+ Add viewer"}),(0,a.jsx)(w.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,a.jsxs)(x.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(m,{level:4,children:" ✨ Security Settings"}),(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:()=>!0===o?L(!0):k.ZP.error("Only premium users can add SSO"),children:"Add SSO"})}),(0,a.jsx)("div",{children:(0,a.jsx)(p.Z,{onClick:ep,children:"Allowed IPs"})})]})]}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(w.Z,{title:"Add SSO",visible:D,width:800,footer:null,onOk:()=>{L(!1),d.resetFields()},onCancel:()=>{L(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:e=>{eI(e),eA(e),L(!1),X(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(I.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(I.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(I.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:ef,onCancel:()=>{X(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{onClick:ef,children:"Done"})})]}),(0,a.jsx)(w.Z,{title:"Manage Allowed IP Addresses",width:800,visible:$,onCancel:()=>Q(!1),footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>el(!0),children:"Add IP Address"},"add"),(0,a.jsx)(p.Z,{onClick:()=>Q(!1),children:"Close"},"close")],children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"IP Address"}),(0,a.jsx)(W.Z,{className:"text-right",children:"Action"})]})}),(0,a.jsx)(z.Z,{children:ea.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e}),(0,a.jsx)(q.Z,{className:"text-right",children:e!==ex&&(0,a.jsx)(p.Z,{onClick:()=>eg(e),color:"red",size:"xs",children:"Delete"})})]},l))})]})}),(0,a.jsx)(w.Z,{title:"Add Allowed IP Address",visible:ee,onCancel:()=>el(!1),footer:null,children:(0,a.jsxs)(S.Z,{onFinish:ej,children:[(0,a.jsx)(S.Z.Item,{name:"ip",rules:[{required:!0,message:"Please enter an IP address"}],children:(0,a.jsx)(I.Z,{placeholder:"Enter IP address"})}),(0,a.jsx)(S.Z.Item,{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add IP Address"})})]})}),(0,a.jsx)(w.Z,{title:"Confirm Delete",visible:es,onCancel:()=>et(!1),onOk:eZ,footer:[(0,a.jsx)(p.Z,{className:"mx-1",onClick:()=>eZ(),children:"Yes"},"delete"),(0,a.jsx)(p.Z,{onClick:()=>et(!1),children:"Close"},"close")],children:(0,a.jsxs)("p",{children:["Are you sure you want to delete the IP address: ",ei,"?"]})})]}),(0,a.jsxs)(ek.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access"," ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},ez=s(22054),eq=s(26706),eK=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.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."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{align:"center",children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(S.Z.Item,{name:e.field_name,className:"mb-0",valuePropName:"Boolean"===e.field_type?"checked":"value",children:(0,a.jsx)(q.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):"Boolean"===e.field_type?(0,a.jsx)(ez.Z,{checked:e.field_value,onChange:l=>{s(e.field_name,l),i.setFieldsValue({[e.field_name]:l})}}):(0,a.jsx)(I.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eW=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eK,{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))),n(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);n(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 n={...e,...s};console.log("mergedFormValues: ".concat(JSON.stringify(n)));let{slack_alerting:a,...r}=n;console.log("slack_alerting: ".concat(a,", alertingArgs: ").concat(JSON.stringify(r)));try{(0,u.jA)(l,"alerting_args",r),"boolean"==typeof a&&(!0==a?(0,u.jA)(l,"alerting",["slack"]):(0,u.jA)(l,"alerting",[])),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},eH=s(36031);let{Title:eG,Paragraph:eJ}=en.default;console.log=function(){};var eY=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({}),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)(!1),[M,D]=(0,r.useState)([]),[L,G]=(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)?T(E.filter(l=>l!==e)):T([...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,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),D(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),T(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let en=e=>E&&E.includes(e),ea=()=>{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,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.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,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},ei=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,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(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,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eo.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eo.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(eo.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(U.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(W.Z,{children:"Callback Name"})})}),(0,a.jsx)(z.Z,{children:i.map((e,s)=>(0,a.jsxs)(H.Z,{className:"flex justify-between",children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(q.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>R(!0),children:"Add Callback"})]}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(_.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{}),(0,a.jsx)(W.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(et).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)}):(0,a.jsx)(p.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(ez.Z,{id:"switch",name:"switch",checked:en(s),onChange:()=>es(s)})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:A&&A[s]?A[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(et).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:E}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(eW,{accessToken:l,premiumUser:n})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(eG,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(q.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.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,a.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,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ea(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:O,width:800,onCancel:()=>R(!1),footer:null,children:[(0,a.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,a.jsx)(S.Z,{form:g,onFinish:ei,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eH.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=M[e];l&&(console.log(l.ui_callback_name),eh(l))},children:M&&Object.values(M).map(e=>(0,a.jsx)(J.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),Y&&Y.map(e=>(0,a.jsx)(eH.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:er,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(eH.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eX}=v.default;var e$=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(G.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(J.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(eh.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eQ=s(45595);async function e0(e,l){console.log=function(){},console.log("isLocal:",!1);let s=window.location.origin,t=new eQ.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});k.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let e1={ttl:3600,lowest_latency_buffer:0},e2=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var e5=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,I]=(0,r.useState)(null),[C,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,u.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,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let T=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,u.K_)(l,{router_settings:i}),o({...i}),I(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},O=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},R=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},F=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},M=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ec.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eo.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eo.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eo.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"})]})}),(0,a.jsx)(z.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,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:E[l]})]}),(0,a.jsx)(q.Z,{children:"routing_strategy"==l?(0,a.jsxs)(G.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(J.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(J.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(J.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e2,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:e1,paramExplanation:E})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>M(i),children:"Save Changes"})})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Model Name"}),(0,a.jsx)(W.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(z.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:t}),(0,a.jsx)(q.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>e0(t,l),children:"Test Fallback"})}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(e$,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(em.Z,{children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Setting"}),(0,a.jsx)(W.Z,{children:"Value"}),(0,a.jsx)(W.Z,{children:"Status"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:m.filter(e=>"TypedDictionary"!==e.field_type).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(_.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(q.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>O(e.field_name,l)}):null}),(0,a.jsx)(q.Z,{children:!0==e.stored_in_db?(0,a.jsx)(L.Z,{icon:eq.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(L.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>R(e.field_name,l),children:"Update"}),(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>F(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e4=s(16873),e8=s(56115),e3=e=>{let{value:l={},onChange:s}=e,[t,n]=(0,r.useState)(Object.entries(l)),i=e=>{let l=t.filter((l,s)=>s!==e);n(l),null==s||s(Object.fromEntries(l))},o=(e,l,a)=>{let r=[...t];r[e]=[l,a],n(r),null==s||s(Object.fromEntries(r))};return(0,a.jsxs)("div",{children:[t.map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(c.Z,{style:{display:"flex",marginBottom:8},align:"start",children:[(0,a.jsx)(j.Z,{placeholder:"Header Name",value:s,onChange:e=>o(l,e.target.value,t)}),(0,a.jsx)(j.Z,{placeholder:"Header Value",value:t,onChange:e=>o(l,s,e.target.value)}),(0,a.jsx)(e4.Z,{onClick:()=>i(l)})]},l)}),(0,a.jsx)(C.ZP,{type:"dashed",onClick:()=>{n([...t,["",""]])},icon:(0,a.jsx)(e8.Z,{}),children:"Add Header"})]})};let{Option:e6}=v.default;var e9=e=>{let{accessToken:l,setPassThroughItems:s,passThroughItems:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Add Pass-Through Endpoint"}),(0,a.jsx)(w.Z,{title:"Add Pass-Through Endpoint",visible:i,width:800,footer:null,onOk:()=>{o(!1),n.resetFields()},onCancel:()=>{o(!1),n.resetFields()},children:(0,a.jsxs)(S.Z,{form:n,onFinish:e=>{console.log(e);let a=[...t,{headers:e.headers,path:e.path,target:e.target}];try{(0,u.Vt)(l,e),s(a)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("Pass through endpoint successfully added"),o(!1),n.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Path",name:"path",rules:[{required:!0,message:"The route to be added to the LiteLLM Proxy Server."}],help:"required",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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,a.jsx)(e3,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Add Pass-Through Endpoint"})})]})})]})},e7=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&(0,u.mp)(l).then(e=>{o(e.endpoints)})},[l,s,t]);let d=(e,s)=>{if(l)try{(0,u.EG)(l,e);let s=i.filter(l=>l.path!==e);o(s),k.ZP.success("Endpoint deleted successfully.")}catch(e){}};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(ed.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Path"}),(0,a.jsx)(W.Z,{children:"Target"}),(0,a.jsx)(W.Z,{children:"Headers"}),(0,a.jsx)(W.Z,{children:"Action"})]})}),(0,a.jsx)(z.Z,{children:i.map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:(0,a.jsx)(_.Z,{children:e.path})}),(0,a.jsx)(q.Z,{children:e.target}),(0,a.jsx)(q.Z,{children:JSON.stringify(e.headers)}),(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{icon:D.Z,color:"red",onClick:()=>d(e.path,l),children:"Reset"})})]},l))})]}),(0,a.jsx)(e9,{accessToken:l,setPassThroughItems:o,passThroughItems:i})]})})}):null},le=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},ll=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n,existingBudget:i,handleUpdateCall:o}=e;console.log("existingBudget",i);let[d]=S.Z.useForm();(0,r.useEffect)(()=>{d.setFieldsValue(i)},[i,d]);let c=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call"),t(!0);let l=await (0,u.qI)(s,e);n(e=>e?[...e,l]:[l]),k.ZP.success("Budget Updated"),d.resetFields(),o()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Edit Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),d.resetFields()},onCancel:()=>{t(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:i,children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(A.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(A.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"7d",children:"weekly"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(C.ZP,{htmlType:"submit",children:"Edit Budget"})})]})})},ls=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[c,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{m(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))},x=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...c];t.splice(s,1),m(t),k.ZP.success("Budget Deleted.")},j=async()=>{null!=l&&(0,u.O3)(l).then(e=>{m(e)})};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(le,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:m}),o&&(0,a.jsx)(ll,{accessToken:l,isModalVisible:n,setIsModalVisible:i,setBudgetList:m,existingBudget:o,handleUpdateCall:j}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Budget ID"}),(0,a.jsx)(W.Z,{children:"Max Budget"}),(0,a.jsx)(W.Z,{children:"TPM"}),(0,a.jsx)(W.Z,{children:"RPM"})]})}),(0,a.jsx)(z.Z,{children:c.slice().sort((e,l)=>new Date(l.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,l)=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.budget_id}),(0,a.jsx)(q.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(q.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(q.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(V.Z,{icon:F.Z,size:"sm",onClick:()=>h(e.budget_id,l)}),(0,a.jsx)(V.Z,{icon:D.Z,size:"sm",onClick:()=>x(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eo.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eo.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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)'})})]})]})]})]})},lt=s(48357),ln=e=>{let{proxySettings:l}=e,s="";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(_.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,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{children:[(0,a.jsx)(eo.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eo.Z,{children:"LlamaIndex"}),(0,a.jsx)(eo.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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,a.jsx)(em.Z,{children:(0,a.jsx)(eA.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 ')})})]})]})]})})})};async function la(e,l,s,t){console.log=function(){},console.log("isLocal:",!1);let n=window.location.origin,a=new eQ.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lr=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await la(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=en.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(U.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(ec.Z,{children:(0,a.jsx)(eo.Z,{children:"Chat"})}),(0,a.jsx)(eu.Z,{children:(0,a.jsxs)(em.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(B.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{})})}),(0,a.jsx)(z.Z,{children:m.map((e,l)=>(0,a.jsx)(H.Z,{children:(0,a.jsx)(q.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},li=s(16384),lo=s(71646);let{Sider:ld}=li.default,lc=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],lm=[{key:"1",page:"api-keys",label:"Virtual Keys"},{key:"3",page:"llm-playground",label:"Test Key"},{key:"2",page:"models",label:"Models",roles:lc},{key:"4",page:"usage",label:"Usage"},{key:"6",page:"teams",label:"Teams"},{key:"5",page:"users",label:"Internal Users",roles:lc},{key:"8",page:"settings",label:"Logging & Alerts",roles:lc},{key:"9",page:"caching",label:"Caching",roles:lc},{key:"10",page:"budgets",label:"Budgets",roles:lc},{key:"11",page:"general-settings",label:"Router Settings",roles:lc},{key:"12",page:"pass-through-settings",label:"Pass-Through",roles:lc},{key:"13",page:"admin-panel",label:"Admin Settings",roles:lc},{key:"14",page:"api_ref",label:"API Reference"},{key:"16",page:"model-hub",label:"Model Hub"}];var lu=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e,n=lm.find(e=>e.page===t),r=(null==n?void 0:n.key)||"1",i=lm.filter(e=>!e.roles||e.roles.includes(s));return(0,a.jsx)(li.default,{style:{minHeight:"100vh",maxWidth:"Admin Viewer"===s?"120px":"145px"},children:(0,a.jsx)(ld,{width:"Admin Viewer"===s?120:145,children:(0,a.jsx)(lo.Z,{mode:"inline",selectedKeys:[r],style:{height:"100%",borderRight:0},children:i.map(e=>(0,a.jsx)(lo.Z.Item,{onClick:()=>{let s=new URLSearchParams(window.location.search);s.set("page",e.page),window.history.pushState(null,"","?".concat(s.toString())),l(e.page)},children:(0,a.jsx)(_.Z,{children:e.label})},e.key))})})})},lh=s(90402),lx=s(64476);console.log("process.env.NODE_ENV","production"),console.log=function(){};let lp=e=>null!==e&&("Admin"===e||"Admin Viewer"===e);var lj=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[E,T]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,M]=(0,r.useState)({}),[D,L]=(0,r.useState)([]),[V,Y]=(0,r.useState)(""),[X,$]=(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),en=new Date(d.getFullYear(),d.getMonth(),1),ea=new Date(d.getFullYear(),d.getMonth()+1,0),eg=ev(en),eZ=ev(ea);function ef(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 e_=async()=>{if(l)try{let e=await (0,u.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 ey=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 n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},eb=async(e,s)=>{if(!e||!s||!l)return;let t=await e_();null!=t&&t.DISABLE_EXPENSIVE_DB_QUERIES||(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.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(eZ));let eS=async(e,l,s)=>{try{let s=await e();l(s)}catch(e){console.error(s,e)}},ek=()=>eS(()=>l?(0,u.FC)(l):Promise.reject("No access token"),m,"Error fetching overall spend"),ew=()=>eS(()=>l&&s?(0,u.OU)(l,s,eg,eZ):Promise.reject("No access token or token"),R,"Error fetching provider spend"),eN=async()=>{l&&await eS(async()=>(await (0,u.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 eS(async()=>(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend})),f,"Error fetching top models")},eA=async()=>{l&&await eS(async()=>{let e=await (0,u.mR)(l);return k(e.daily_spend),P(e.teams),e.total_spend_per_team.map(e=>({name:e.team_id||"",value:(e.total_spend||0).toFixed(2)}))},T,"Error fetching team spend")},eC=()=>{l&&eS(async()=>(await (0,u.X)(l)).tag_names,A,"Error fetching tag names")},eP=()=>{l&&eS(()=>{var e,s;return(0,u.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&&eS(()=>(0,u.b1)(l,null,void 0,void 0),v,"Error fetching top end users")},eT=()=>{l&&eS(()=>(0,u.wd)(l,eg,eZ),M,"Error fetching global activity")},eO=()=>{l&&eS(()=>(0,u.xA)(l,eg,eZ),L,"Error fetching global activity per model")};return((0,r.useEffect)(()=>{(async()=>{if(l&&s&&t&&n){let e=await e_();e&&(et(e),null!=e&&e.DISABLE_EXPENSIVE_DB_QUERIES)||(console.log("fetching data - valiue of proxySettings",es),ek(),ew(),eN(),eI(),eT(),eO(),lp(t)&&(eA(),eC(),eP(),eE()))}})()},[l,s,t,n,eg,eZ]),null==es?void 0:es.DISABLE_EXPENSIVE_DB_QUERIES)?(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Database Query Limit Reached"}),(0,a.jsxs)(_.Z,{className:"mt-4",children:["SpendLogs in DB has ",es.NUM_SPEND_LOGS_ROWS," rows.",(0,a.jsx)("br",{}),"Please follow our guide to view usage when SpendLogs has more than 1M rows."]}),(0,a.jsx)(p.Z,{className:"mt-4",children:(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/spending_monitoring",target:"_blank",children:"View Usage Guide"})})]})}):(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{className:"mt-2",children:[(0,a.jsx)(eo.Z,{children:"All Up"}),lp(t)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eo.Z,{children:"Team Based Usage"}),(0,a.jsx)(eo.Z,{children:"Customer Usage"}),(0,a.jsx)(eo.Z,{children:"Tag Based Usage"})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{})})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsxs)(ec.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eo.Z,{children:"Cost"}),(0,a.jsx)(eo.Z,{children:"Activity"})]}),(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(Q,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null,userMaxBudget:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ej.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ej.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,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ej.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(lx.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(B.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Provider"}),(0,a.jsx)(W.Z,{children:"Spend"})]})}),(0,a.jsx)(z.Z,{children:O.map(e=>(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.provider}),(0,a.jsx)(q.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(F.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(F.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:F.daily_data,valueFormatter:ef,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:D.map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:ef,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:D&&D.length>0&&D.slice(0,1).map((e,l)=>(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(p.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",ef(e.sum_api_requests)]}),(0,a.jsx)(ep.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:ef,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(er.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",ef(e.sum_total_tokens)]}),(0,a.jsx)(ej.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:ef,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(em.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(U.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lh.Z,{data:E})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ej.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(em.Z,{children:[(0,a.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,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(ei.Z,{enableSelect:!0,value:ee,onValueChange:e=>{el(e),ey(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(G.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(J.Z,{value:"all-keys",onClick:()=>{ey(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,a.jsx)(J.Z,{value:String(l),onClick:()=>{ey(ee.from,ee.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(U.Z,{className:"mt-4",children:(0,a.jsxs)(B.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(W.Z,{children:"Customer"}),(0,a.jsx)(W.Z,{children:"Spend"}),(0,a.jsx)(W.Z,{children:"Total Events"})]})}),(0,a.jsx)(z.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(H.Z,{children:[(0,a.jsx)(q.Z,{children:e.end_user}),(0,a.jsx)(q.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(q.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(em.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ei.Z,{className:"mb-4",enableSelect:!0,value:ee,onValueChange:e=>{el(e),eb(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(ex.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(eh.Z,{value:X,onValueChange:e=>$(e),children:[(0,a.jsx)(ex.Z,{value:"all-tags",onClick:()=>$(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(J.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ej.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})};let lg=e=>{if(e)return e.toISOString().split("T")[0]};function lZ(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}var lf=e=>{let{accessToken:l,token:s,userRole:t,userID:n,premiumUser:i}=e,[o,d]=(0,r.useState)([]),[c,m]=(0,r.useState)([]),[p,j]=(0,r.useState)([]),[g,Z]=(0,r.useState)([]),[f,_]=(0,r.useState)("0"),[y,b]=(0,r.useState)("0"),[v,S]=(0,r.useState)("0"),[k,w]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date});(0,r.useEffect)(()=>{l&&k&&(async()=>{Z(await (0,u.zg)(l,lg(k.from),lg(k.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 A=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),Z(await (0,u.zg)(l,lg(e),lg(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,n=e.reduce((e,n)=>{console.log("Processing item:",n),n.call_type||(console.log("Item has no call_type:",n),n.call_type="Unknown"),l+=(n.total_rows||0)-(n.cache_hit_true_rows||0),s+=n.cache_hit_true_rows||0,t+=n.cached_completion_tokens||0;let a=e.find(e=>e.name===n.call_type);return a?(a["LLM API requests"]+=(n.total_rows||0)-(n.cache_hit_true_rows||0),a["Cache hit"]+=n.cache_hit_true_rows||0,a["Cached Completion Tokens"]+=n.cached_completion_tokens||0,a["Generated Completion Tokens"]+=n.generated_completion_tokens||0):e.push({name:n.call_type,"LLM API requests":(n.total_rows||0)-(n.cache_hit_true_rows||0),"Cache hit":n.cache_hit_true_rows||0,"Cached Completion Tokens":n.cached_completion_tokens||0,"Generated Completion Tokens":n.generated_completion_tokens||0}),e},[]);_(lZ(s)),b(lZ(t));let a=s+l;a>0?S((s/a*100).toFixed(2)):S("0"),d(n),console.log("PROCESSED DATA IN CACHE DASHBOARD",n)},[c,p,k,g]),(0,a.jsxs)(U.Z,{children:[(0,a.jsxs)(x.Z,{numItems:3,className:"gap-4 mt-4",children:[(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select API Keys",value:c,onValueChange:m,children:N.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(eh.Z,{placeholder:"Select Models",value:p,onValueChange:j,children:I.map(e=>(0,a.jsx)(ex.Z,{value:e,children:e},e))})}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(ei.Z,{enableSelect:!0,value:k,onValueChange:e=>{w(e),A(e.from,e.to)},selectPlaceholder:"Select date range"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-4",children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hit Ratio"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsxs)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[v,"%"]})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cache Hits"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:f})})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Cached Tokens"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-metric font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:y})})]})]}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cache Hits vs API Requests"}),(0,a.jsx)(ej.Z,{title:"Cache Hits vs API Requests",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["LLM API requests","Cache hit"],colors:["sky","teal"],yAxisWidth:48}),(0,a.jsx)(er.Z,{className:"mt-4",children:"Cached Completion Tokens vs Generated Completion Tokens"}),(0,a.jsx)(ej.Z,{className:"mt-6",data:o,stack:!0,index:"name",valueFormatter:lZ,categories:["Generated Completion Tokens","Cached Completion Tokens"],colors:["sky","teal"],yAxisWidth:48})]})},l_=()=>{let{Title:e,Paragraph:l}=en.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[h,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(null),[g,Z]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[f,_]=(0,r.useState)(!0),y=(0,i.useSearchParams)(),[b,v]=(0,r.useState)({data:[]}),S=y.get("userID"),k=y.get("invitation_id"),w=function(e){console.log("COOKIES",document.cookie);let l=document.cookie.split("; ").find(l=>l.startsWith(e+"="));return l?l.split("=")[1]:null}("token"),[N,I]=(0,r.useState)(()=>y.get("page")||"api-keys"),[A,C]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(w){let e=(0,et.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),C(e.key),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&&I("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?_("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,u.K8)(e.auth_header_name)}}},[w]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:k?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:S,userRole:s,userEmail:d,premiumUser:n,setProxySettings:Z,proxySettings:g}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lu,{setPage:e=>{let l=new URLSearchParams(y);l.set("page",e),window.history.pushState(null,"","?".concat(l.toString())),I(e)},userRole:s,defaultSelectedKey:N})}),"api-keys"==N?(0,a.jsx)(ea,{userID:S,userRole:s,premiumUser:n,teams:h,keys:p,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:x,setKeys:j}):"models"==N?(0,a.jsx)(eR,{userID:S,userRole:s,token:w,keys:p,accessToken:A,modelData:b,setModelData:v,premiumUser:n}):"llm-playground"==N?(0,a.jsx)(lr,{userID:S,userRole:s,token:w,accessToken:A}):"users"==N?(0,a.jsx)(eU,{userID:S,userRole:s,token:w,keys:p,teams:h,accessToken:A,setKeys:j}):"teams"==N?(0,a.jsx)(eV,{teams:h,setTeams:x,searchParams:y,accessToken:A,userID:S,userRole:s}):"admin-panel"==N?(0,a.jsx)(eB,{setTeams:x,searchParams:y,accessToken:A,showSSOBanner:f,premiumUser:n}):"api_ref"==N?(0,a.jsx)(ln,{proxySettings:g}):"settings"==N?(0,a.jsx)(eY,{userID:S,userRole:s,accessToken:A,premiumUser:n}):"budgets"==N?(0,a.jsx)(ls,{accessToken:A}):"general-settings"==N?(0,a.jsx)(e5,{userID:S,userRole:s,accessToken:A,modelData:b}):"model-hub"==N?(0,a.jsx)(lt.Z,{accessToken:A,publicPage:!1,premiumUser:n}):"caching"==N?(0,a.jsx)(lf,{userID:S,userRole:s,token:w,accessToken:A,premiumUser:n}):"pass-through-settings"==N?(0,a.jsx)(e7,{userID:S,userRole:s,accessToken:A,modelData:b}):(0,a.jsx)(lj,{userID:S,userRole:s,token:w,accessToken:A,keys:p,premiumUser:n})]})]})})}},48357:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(57437),n=s(2265),a=s(16463),r=s(38939),i=s(15606),o=s(75203),d=s(63789),c=s(93466),m=s(51782),u=s(174),h=s(28260),x=s(29312),p=s(99295),j=s(97673),g=s(25858),Z=s(68551),f=s(45076),_=s(28040),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,E]=(0,n.useState)(null),T=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{E(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},F=()=>{I(!1),C(!1),E(null)},M=()=>{I(!1),C(!1),E(null)},D=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>D(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:F,onCancel:M,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{T.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:F,onCancel:M,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(P.model_group,'", # 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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="'.concat(P.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # 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="http://0.0.0.0:4000",\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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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="http://0.0.0.0:4000",\n model = "'.concat(P.model_group,'",\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 ')})})]})]})]})})]})}}},function(e){e.O(0,[665,569,852,748,17,939,971,23,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 2537644b3f0d..522ef2d9bd83 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 61949640cad0..4040fbcbac9e 100644
--- a/ui/litellm-dashboard/out/index.txt
+++ b/ui/litellm-dashboard/out/index.txt
@@ -1,7 +1,7 @@
2:I[66513,[],"ClientPageRoot"]
-3:I[79642,["665","static/chunks/3014691f-0e3faeb6a30bdef5.js","569","static/chunks/569-fb5d4ecc1efc8220.js","852","static/chunks/852-8504c1dc77126607.js","748","static/chunks/748-ca0d88d4d972a1fe.js","17","static/chunks/17-dde5d33395f2c56a.js","939","static/chunks/939-446113ab9fc7760f.js","931","static/chunks/app/page-276b2ef886aa0b4e.js"],"default",1]
+3:I[79642,["665","static/chunks/3014691f-0e3faeb6a30bdef5.js","569","static/chunks/569-fb5d4ecc1efc8220.js","852","static/chunks/852-8504c1dc77126607.js","748","static/chunks/748-ca0d88d4d972a1fe.js","17","static/chunks/17-dde5d33395f2c56a.js","939","static/chunks/939-446113ab9fc7760f.js","931","static/chunks/app/page-0ad2ec54b8904803.js"],"default",1]
4:I[39275,[],""]
5:I[61343,[],""]
-0:["8r6NWZjV65MfTM9OwdJEV",[[["",{"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/0940e922324b3d86.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:["RGOvdwmDKbOr7ddjPRjMK",[[["",{"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/0940e922324b3d86.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 52783516ef5a..5b1276d2bced 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 6c9bfcd95f14..12d914c217c2 100644
--- a/ui/litellm-dashboard/out/model_hub.txt
+++ b/ui/litellm-dashboard/out/model_hub.txt
@@ -2,6 +2,6 @@
3:I[99327,["569","static/chunks/569-fb5d4ecc1efc8220.js","852","static/chunks/852-8504c1dc77126607.js","939","static/chunks/939-446113ab9fc7760f.js","418","static/chunks/app/model_hub/page-544de941cb7f8d17.js"],"default",1]
4:I[39275,[],""]
5:I[61343,[],""]
-0:["8r6NWZjV65MfTM9OwdJEV",[[["",{"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/0940e922324b3d86.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:["RGOvdwmDKbOr7ddjPRjMK",[[["",{"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/0940e922324b3d86.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 cd6d89c7eee9..b9619b97b412 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 8de78a0a4767..d7ebd3e1c0c4 100644
--- a/ui/litellm-dashboard/out/onboarding.txt
+++ b/ui/litellm-dashboard/out/onboarding.txt
@@ -2,6 +2,6 @@
3:I[62105,["665","static/chunks/3014691f-0e3faeb6a30bdef5.js","569","static/chunks/569-fb5d4ecc1efc8220.js","748","static/chunks/748-ca0d88d4d972a1fe.js","939","static/chunks/939-446113ab9fc7760f.js","461","static/chunks/app/onboarding/page-0b0af9deafd4cedf.js"],"default",1]
4:I[39275,[],""]
5:I[61343,[],""]
-0:["8r6NWZjV65MfTM9OwdJEV",[[["",{"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/0940e922324b3d86.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:["RGOvdwmDKbOr7ddjPRjMK",[[["",{"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/0940e922324b3d86.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