diff --git a/litellm/proxy/_experimental/out/404/index.html b/litellm/proxy/_experimental/out/404.html
similarity index 98%
rename from litellm/proxy/_experimental/out/404/index.html
rename to litellm/proxy/_experimental/out/404.html
index daae71ba3..2c4f52e83 100644
--- a/litellm/proxy/_experimental/out/404/index.html
+++ b/litellm/proxy/_experimental/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/litellm/proxy/_experimental/out/_next/static/XsAEnZvT8GWmMEp4_0in-/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_buildManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/XsAEnZvT8GWmMEp4_0in-/_buildManifest.js
rename to litellm/proxy/_experimental/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_buildManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/XsAEnZvT8GWmMEp4_0in-/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_ssgManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/XsAEnZvT8GWmMEp4_0in-/_ssgManifest.js
rename to litellm/proxy/_experimental/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_ssgManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-0f6ae871c63eb14b.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-0f6ae871c63eb14b.js
deleted file mode 100644
index 5e1fb3b33..000000000
--- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-0f6ae871c63eb14b.js
+++ /dev/null
@@ -1 +0,0 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,s){Promise.resolve().then(s.bind(s,62631))},62631:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return e9}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let i=[{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(r)]})]})}];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?(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 enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:i},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(81583),k=s(80588),w=s(99129),N=s(44839),A=s(88707),I=s(1861);let{Option:C}=v.default;var E=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),[E,P]=(0,r.useState)(null),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)([]),[M,L]=(0,r.useState)([]),U=()=>{m(!1),d.resetFields()},D=()=>{m(!1),P(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),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let K=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"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),P(h.key),O(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)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(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:U,onCancel:D,children:(0,a.jsxs)(S.Z,{form:d,onFinish:K,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",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)(N.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)(C,{value:"all-team-models",children:"All Team Models"},"all-team-models"),M.map(e=>(0,a.jsx)(C,{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:"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)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Key"})})]})}),E&&(0,a.jsx)(w.Z,{visible:c,onOk:U,onCancel:D,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!=E?(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:E})}),(0,a.jsx)(b.CopyToClipboard,{text:E,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"})})]})})]})},P=s(9454),T=s(98941),O=s(33393),R=s(5),F=s(13810),M=s(61244),L=s(10827),U=s(3851),D=s(2044),K=s(64167),B=s(74480),q=s(7178),z=s(95093),V=s(27166);let{Option:G}=v.default;var W=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,C]=(0,r.useState)(null),[E,W]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,$]=(0,r.useState)(!1),[X,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(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),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,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"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Key Alias"}),(0,a.jsx)(B.Z,{children:"Secret Key"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(U.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(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.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)(q.Z,{children:[(0,a.jsx)(D.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)(D.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(D.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(R.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(D.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.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{onClick:()=>{Q(e),$(!0)},icon:P.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{$(!1),Q(null)},footer:null,width:800,children:X&&(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)(F.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(X.spend).toFixed(4)}catch(e){return X.spend}})()})})]}),(0,a.jsxs)(F.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!=X.max_budget?(0,a.jsx)(a.Fragment,{children:X.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(F.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!=X.expires?(0,a.jsx)(a.Fragment,{children:new Date(X.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)(F.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:X.key_alias?X.key_alias:X.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:X.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(X.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{$(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(M.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),X&&(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);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:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.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)(G,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(G,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(G,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(G,{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,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(z.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(V.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:X,onSubmit:er})]})},H=s(76032),Y=s(35152),J=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(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),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("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:["$",j]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)(_.Z,{children:"Team Models"})}),(0,a.jsx)(Z.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(H.Z,{children:p.map(e=>(0,a.jsx)(Y.Z,{children:(0,a.jsx)(_.Z,{children:e})},e))})})]})})]})},$=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.jsx)("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})})})},X=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.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."})]})]})},Q=s(37963),ee=s(97482);console.log("isLocal:",!1);var el=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p}=e,[j,g]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let f=Z.get("token"),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)([]),w={models:[],team_alias:"Default Team",team_id:null},[N,A]=(0,r.useState)(t?t[0]:w);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(f){let e=(0,Q.o)(f);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(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";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&&_&&s&&!n&&!j){let e=sessionStorage.getItem("userModels"+l);e?k(JSON.parse(e)):(async()=>{try{let e=await (0,u.Br)(_,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await (0,u.Qy)(_);g(e),console.log("globalSpend:",e)}else g(e.user_info);p(e.keys),m(e.teams);let t=[...e.teams];t.length>0?(console.log("response['teams']: ".concat(t)),A(t[0])):A(w),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let n=(await (0,u.So)(_,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),k(n),console.log("userModels:",S),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,f,_,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=N&&null!==N.team_id){let e=0;for(let l of n)N.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===N.team_id&&(e+=l.spend);v(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;v(e)}},[N]),null==l||null==f){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==_)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=ee.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",N),(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)($,{userID:l,userRole:s,selectedTeam:N||null,accessToken:_}),(0,a.jsx)(J,{userID:l,userRole:s,accessToken:_,userSpend:b,selectedTeam:N||null}),(0,a.jsx)(W,{userID:l,userRole:s,accessToken:_,selectedTeam:N||null,data:n,setData:p,teams:t}),(0,a.jsx)(E,{userID:l,team:N||null,userRole:s,accessToken:_,data:n,setData:p},N?N.team_id:null),(0,a.jsx)(X,{teams:t,setSelectedTeam:A,userRole:s})]})})})},es=s(35087),et=s(92836),en=s(26734),ea=s(41608),er=s(32126),ei=s(23682),eo=s(47047),ed=s(76628),ec=s(25707),em=s(44041),eu=s(1460),eh=s(28683),ex=s(38302),ep=s(78578),ej=s(63954),eg=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)(M.Z,{onClick:()=>n(!0),icon:O.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})]})})]})})]})},eZ=s(97766),ef=s(46495),e_=s(18190),ey=s(91118),eb=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ey.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)(e_.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"})})]})},ev=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))})},eS=s(67951);let{Title:ek,Link:ew}=ee.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks";let eN={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eI=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)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=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 eC=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},setModelData:g,premiumUser:Z}=e,[f,b]=(0,r.useState)([]),[v]=S.Z.useForm(),[N,C]=(0,r.useState)(null),[E,O]=(0,r.useState)(""),[G,W]=(0,r.useState)([]),H=Object.values(n).filter(e=>isNaN(Number(e))),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)("OpenAI"),[Q,el]=(0,r.useState)(""),[e_,ey]=(0,r.useState)(!1),[eC,eE]=(0,r.useState)(!1),[eP,eT]=(0,r.useState)(null),[eO,eR]=(0,r.useState)([]),[eF,eM]=(0,r.useState)(null),[eL,eU]=(0,r.useState)([]),[eD,eK]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[ez,eV]=(0,r.useState)([]),[eG,eW]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,e$]=(0,r.useState)([]),[eX,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e5,e8]=(0,r.useState)(null),[e3,e6]=(0,r.useState)(0),e7=e=>{eT(e),ey(!0)},e9=e=>{eT(e),eE(!0)},le=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),ey(!1),eT(null)}catch(e){console.log("Error occurred")}},ll=()=>{O(new Date().toLocaleString())},ls=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e5);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e5}}),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(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i;let d=await (0,u.hy)(o);J(d);let h=await (0,u.AZ)(o,m,c);console.log("Model data response:",h.data),g(h);let x=new Set;for(let e=0;e0&&(j=p[p.length-1],console.log("_initial_model_group:",j),eM(j)),console.log("selectedModelGroup:",eF);let Z=await (0,u.o6)(o,m,c,j,null===(e=e2.from)||void 0===e?void 0:e.toISOString(),null===(l=e2.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",Z),eK(Z.data),eq(Z.all_api_bases);let f=await (0,u.Rg)(o,j,null===(s=e2.from)||void 0===s?void 0:s.toISOString(),null===(t=e2.to)||void 0===t?void 0:t.toISOString());eV(f.data),eW(f.all_api_bases);let _=await (0,u.N8)(o,m,c,j,null===(n=e2.from)||void 0===n?void 0:n.toISOString(),null===(a=e2.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",_),eY(_.data),e$(_.exception_types);let y=await (0,u.fP)(o,m,c,j,null===(r=e2.from)||void 0===r?void 0:r.toISOString(),null===(i=e2.to)||void 0===i?void 0:i.toISOString());console.log("slowResponses:",y),e1(y);let b=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",b);let v=b.model_group_retry_policy,S=b.num_retries;console.log("model_group_retry_policy:",v),console.log("default_retries:",S),e8(v),e6(S)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),C(e)};null==N&&l(),ll()},[o,d,c,m,N,E]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lt=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(N)),null!=N&&"object"==typeof N&&e in N)?N[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lt.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=ee.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 ln=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eN[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof N&&Object.entries(N).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)}),W(s),console.log("providerModels: ".concat(G))}},la=async()=>{try{k.ZP.info("Running health check..."),el("");let e=await (0,u.EY)(o);el(e)}catch(e){console.error("Error running health check:",e),el("Error running health check")}},lr=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),o&&m&&c&&l&&s){console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),eM(e);try{let t=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model metrics response:",t),eK(t.data),eq(t.all_api_bases);let n=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eV(n.data),eW(n.all_api_bases);let a=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model exceptions response:",a),eY(a.data),e$(a.exception_types);let r=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString());console.log("slowResponses:",r),e1(r)}catch(e){console.error("Failed to fetch model metrics",e)}}},li=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)})]})};console.log("selectedProvider: ".concat($)),console.log("providerModels.length: ".concat(G.length));let lo=Object.keys(n).find(e=>n[e]===$);return lo&&(i=Y.find(e=>e.name===eN[lo])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(et.Z,{children:"All Models"}),(0,a.jsx)(et.Z,{children:"Add Model"}),(0,a.jsx)(et.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(et.Z,{children:"Model Analytics"}),(0,a.jsx)(et.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[E&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",E]}),(0,a.jsx)(M.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ll})]})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],onValueChange:e=>eM("all"===e?"all":e),value:eF||eO[0],children:[(0,a.jsx)(V.Z,{value:"all",children:"All Models"}),eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))]})]}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(B.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)(B.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)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(B.Z,{})]})}),(0,a.jsx)(U.Z,{children:h.data.filter(e=>"all"===eF||e.model_name===eF||null==eF||""===eF).map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.model_name||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"10px"},title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},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)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&e.model_info.created_by||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:P.Z,size:"sm",onClick:()=>e9(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>e7(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eg,{modelID:e.model_info.id,accessToken:o})})]})})]},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:le,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:"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_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(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)(I.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:e_,onCancel:()=>{ey(!1),eT(null)},model:eP,onSubmit:le}),(0,a.jsxs)(w.Z,{title:eP&&eP.model_name,visible:eC,width:800,footer:null,onCancel:()=>{eE(!1),eT(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eS.Z,{language:"json",children:eP&&JSON.stringify(eP,null,2)})]})]}),(0,a.jsxs)(er.Z,{className:"h-full",children:[(0,a.jsx)(ek,{level:2,children:"Add new model"}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(S.Z,{form:v,onFinish:()=>{v.validateFields().then(e=>{eI(e,o,v)}).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)(z.Z,{value:$.toString(),children:H.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>{ln(e),X(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,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=$.toString())?"gemini-pro":"Anthropic"==t?"claude-3-opus":"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===$?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(eo.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(ed.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(ew,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(ew,{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!==i&&i.fields.length>0&&(0,a.jsx)(ev,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=$&&"Vertex AI (Anthropic, Gemini, etc.)"!=$&&void 0===i&&(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"==$&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(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.)"==$&&(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.)"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ef.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;v.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)(I.ZP,{icon:(0,a.jsx)(eZ.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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"==$||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==$)&&(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"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==$&&(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)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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)(ew,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==$&&(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"==$&&(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"==$&&(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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(ew,{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)(I.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eu.Z,{title:"Get help on our github",children:(0,a.jsx)(ee.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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:la,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(es.Z,{enableSelect:!0,value:e2,onValueChange:e=>{e4(e),lr(eF,e.from,e.to)}})]}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2",defaultValue:eF||eO[0],value:eF||eO[0],children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>lr(e,e2.from,e2.to),children:e},l))})]})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(et.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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"}),eD&&eB&&(0,a.jsx)(ec.Z,{title:"Model Latency",className:"h-72",data:eD,showLegend:!1,index:"date",categories:eB,connectNulls:!0,customTooltip:li})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(eb,{modelMetrics:ez,modelMetricsCategories:eG,customTooltip:li,premiumUser:Z})})]})]})})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Deployment"}),(0,a.jsx)(B.Z,{children:"Success Responses"}),(0,a.jsxs)(B.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(U.Z,{children:e0.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.api_base}),(0,a.jsx)(D.Z,{children:e.total_count}),(0,a.jsx)(D.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(F.Z,{className:"mt-4",children:[(0,a.jsx)(y.Z,{children:"Exceptions per Model"}),(0,a.jsx)(em.Z,{className:"h-72",data:eH,index:"model",categories:eJ,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],value:eF||eO[0],onValueChange:e=>eM(e),children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eF]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e5?void 0:null===(s=e5[eF])||void 0===s?void 0:s[n];return null==r&&(r=e3),(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=>{e8(l=>{var s;let t=null!==(s=null==l?void 0:l[eF])&&void 0!==s?s:{};return{...null!=l?l:{},[eF]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:ls,children:"Save"})]})]})]})})};let{Option:eE}=v.default;var eP=e=>{let{userID:l,accessToken:s,teams:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[m,h]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{o(!1),n.resetFields()},g=()=>{o(!1),c(null),n.resetFields()},Z=async e=>{try{k.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let t=await (0,u.Ov)(s,null,e);console.log("user create Response:",t),c(t.key),k.ZP.success("API user Created"),n.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:()=>o(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:i,width:800,footer:null,onOk:x,onCancel:g,children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(_.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(S.Z,{form:n,onFinish:Z,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:"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)(eE,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eE,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create User"})})]})]}),d&&(0,a.jsxs)(w.Z,{title:"User Created Successfully",visible:i,onOk:x,onCancel:g,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},eT=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[y,b]=(0,r.useState)(null);return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(eP,{userID:i,accessToken:l,teams:o}),(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(_.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(en.Z,{children:(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"User ID"}),(0,a.jsx)(B.Z,{children:"User Email"}),(0,a.jsx)(B.Z,{children:"User Models"}),(0,a.jsx)(B.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(B.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(B.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(U.Z,{children:c.map(e=>{var l;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_id}),(0,a.jsx)(D.Z,{children:e.user_email}),(0,a.jsx)(D.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(D.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(R.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(er.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"})]})})]})})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+1," 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:0===j,onClick:()=>g(j-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",onClick:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eO=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=ee.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[C,E]=(0,r.useState)(l?l[0]:null),[P,G]=(0,r.useState)(!1),[W,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)(!1),[Q,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{E(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),E(null)},er=async e=>{el(e),X(!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)}X(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{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),J(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"),G(!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:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,C.team_id,s);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),E(a.data)}H(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Team Name"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(B.Z,{children:"Info"})]})}),(0,a.jsx)(U.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.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)(D.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)(D.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(M.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),$&&(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:()=>{X(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>G(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:P,width:800,footer:null,onOk:()=>{G(!1),d.resetFields()},onCancel:()=>{G(!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"),Y.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,{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)(I.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.Z,{value:String(l),onClick:()=>{E(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:C?C.members_with_roles.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.role})]},l)):null})]})}),C&&(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"),Y&&Y.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,{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)(I.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),E(null)},team:C,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:W,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eR=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[i]=S.Z.useForm(),[o]=S.Z.useForm(),{Title:d,Paragraph:c}=ee.default,[m,j]=(0,r.useState)(""),[g,Z]=(0,r.useState)(null),[f,y]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[A,C]=(0,r.useState)(!1),[E,P]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let G=()=>{R(!1)},W=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),Z(e)}})()},[t]);let H=()=>{C(!1),o.resetFields()},Y=()=>{C(!1),o.resetFields()},J=e=>(0,a.jsxs)(S.Z,{form:i,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]}),$=(e,l,s)=>(0,a.jsxs)(S.Z,{form:i,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)(z.Z,{value:l,children:W.map((e,l)=>(0,a.jsx)(V.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)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update role"})})]}),X=async e=>{try{if(null!=t&&null!=g){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=g.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"),g.push(l),Z(g)),k.ZP.success("Refresh tab to see updated user role"),C(!1)}}catch(e){console.error("Error creating the key:",e)}},Q=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),y(!1)}}catch(e){console.error("Error creating the key:",e)}},el=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await (0,u.pf)(t,e,"proxy_admin");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),v(!1)}}catch(e){console.error("Error creating the key:",e)}},es=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==g?void 0:g.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(d,{level:4,children:"Admin Access "}),(0,a.jsxs)(c,{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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:g?g.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.user_role}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>C(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:A,width:800,footer:null,onOk:H,onCancel:Y,children:$(X,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:()=>v(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:b,width:800,footer:null,onOk:()=>{v(!1),o.resetFields()},onCancel:()=>{v(!1),o.resetFields()},children:J(el)}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>y(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:f,width:800,footer:null,onOk:()=>{y(!1),o.resetFields()},onCancel:()=>{y(!1),o.resetFields()},children:J(Q)})]})})]}),(0,a.jsxs)(x.Z,{children:[(0,a.jsx)(d,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(p.Z,{onClick:()=>P(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:E,width:800,footer:null,onOk:()=>{P(!1),i.resetFields()},onCancel:()=>{P(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{el(e),es(e),P(!1),R(!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)(N.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)(N.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)(N.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)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:O,width:800,footer:null,onOk:G,onCancel:()=>{R(!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)(I.ZP,{onClick:G,children:"Done"})})]})]}),(0,a.jsxs)(e_.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})," "]})]})]})]})},eF=s(42556),eM=s(90252),eL=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:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(D.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",children:(0,a.jsx)(D.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"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eM.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eU=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eL,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}: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);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})};let eD=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var eK=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)(eD),[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,A]=(0,r.useState)(""),[C,E]=(0,r.useState)({}),[P,T]=(0,r.useState)([]),O=e=>{P.includes(e)?T(P.filter(l=>l!==e)):T([...P,e])},M={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);let l=eD;o(l=l.map(l=>{let s=e.callbacks.find(e=>e.name===l.name);return s?{...l,variables:{...l.variables,...s.variables}}:l}));let s=e.alerts;if(console.log("alerts_data",s),s&&s.length>0){let e=s[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),T(e.active_alerts),A(l),E(e.alerts_to_webhook)}c(s)})},[l,s,t]);let z=e=>P&&P.includes(e),V=e=>{if(!l)return;let s=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[s,t]=e;return[s,(null===(l=document.querySelector('input[name="'.concat(s,'"]')))||void 0===l?void 0:l.value)||t]}));console.log("updatedVariables",s),console.log("updateAlertTypes",y);let t={environment_variables:s,litellm_settings:{success_callback:[e.name]}};try{(0,u.K_)(l,t)}catch(e){k.ZP.error("Failed to update callback: "+e,20)}k.ZP.success("Callback updated successfully")},G=()=>{l&&g.validateFields().then(e=>{let s;if(console.log("Form values:",e),"langfuse"===e.callback){s={environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),s={general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}},(0,u.K_)(l,s),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),s={environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};o(i?[...i,t]:[t])}else s={error:"Invalid callback value"};h(!1),g.resetFields(),f(null)})};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(e_.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(et.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(et.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Callback"}),(0,a.jsx)(B.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(U.Z,{children:i.filter(e=>"slack"!==e.name).map((e,s)=>{var t;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:(0,a.jsx)(R.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(t=e.variables)&&void 0!==t?t:{}).filter(l=>{let[s,t]=l;return s.toLowerCase().includes(e.name)}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password"})]},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>V(e),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"mx-2",children:"Test Callback"})]})]},s)})})]})})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(M).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eF.Z,{id:"switch",name:"switch",checked:z(s),onChange:()=>O(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)(eF.Z,{id:"switch",name:"switch",checked:z(s),onChange:()=>O(s)})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(M).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:P}};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)(er.Z,{children:(0,a.jsx)(eU,{accessToken:l,premiumUser:n})})]})]})]}),(0,a.jsx)(w.Z,{title:"Add Callback",visible:m,onOk:G,width:800,onCancel:()=>{h(!1),g.resetFields(),f(null)},footer:null,children:(0,a.jsxs)(S.Z,{form:g,layout:"vertical",onFinish:G,children:[(0,a.jsx)(S.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(v.default,{onChange:e=>{f(e)},children:[(0,a.jsx)(v.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(v.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===Z&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(j.Z,{type:"password"})}),(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(j.Z,{type:"password"})})]}),"openmeter"==Z&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(j.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eB}=v.default;var eq=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)(z.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(V.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)(eo.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ed.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},ez=s(12968);async function eV(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new ez.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 eG={ttl:3600,lowest_latency_buffer:0},eW=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)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.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 eH=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,E]=(0,r.useState)(null),P={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(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)}}},G=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},W=(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){}},H=(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){}},Y=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)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(et.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(et.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.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)(F.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.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)(q.Z,{children:[(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,a.jsx)(D.Z,{children:"routing_strategy"==l?(0,a.jsxs)(z.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(V.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(V.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(V.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)(eW,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eG,paramExplanation:P})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Model Name"}),(0,a.jsx)(B.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(U.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:t}),(0,a.jsx)(D.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eV(t,l),children:"Test Fallback"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(eq,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"}),(0,a.jsx)(B.Z,{children:"Status"}),(0,a.jsx)(B.Z,{children:"Action"})]})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>G(e.field_name,l)}):null}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eM.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>W(e.field_name,l),children:"Update"}),(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},eY=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:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},eJ=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.ZP.success("Budget Deleted.")};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)(eY,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Budget ID"}),(0,a.jsx)(B.Z,{children:"Max Budget"}),(0,a.jsx)(B.Z,{children:"TPM"}),(0,a.jsx)(B.Z,{children:"RPM"})]})}),(0,a.jsx)(U.Z,{children:n.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.budget_id}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(D.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(D.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>o(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(et.Z,{children:"Test it (Curl)"}),(0,a.jsx)(et.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{}=e;return(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(et.Z,{children:"LlamaIndex"}),(0,a.jsx)(et.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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="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)(er.Z,{children:(0,a.jsx)(eS.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="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,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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 = "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 eQ(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new ez.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 e0=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}));console.log(l),b(l),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 eQ(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}=ee.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)(F.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(et.Z,{children:"Chat"})}),(0,a.jsx)(ei.Z,{children:(0,a.jsxs)(er.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)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.Z,{})})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.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),placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e1=s(33509),e2=s(95781);let{Sider:e4}=e1.default;var e5=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e1.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e4,{width:120,children:(0,a.jsxs)(e2.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e2.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(e1.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e4,{width:145,children:(0,a.jsxs)(e2.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e2.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Rate Limits"})},"9"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e2.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},e8=s(67989),e3=s(49167),e6=s(52703),e7=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)([]),[A,I]=(0,r.useState)([]),[C,E]=(0,r.useState)([]),[P,T]=(0,r.useState)([]),[O,R]=(0,r.useState)({}),[M,G]=(0,r.useState)([]),[W,H]=(0,r.useState)(""),[Y,$]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),X=new Date(d.getFullYear(),d.getMonth(),1),Q=new Date(d.getFullYear(),d.getMonth()+1,0),ee=eu(X),el=eu(Q);console.log("keys in usage",i),console.log("premium user in usage",o);let eo=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)},ed=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function eu(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)}return console.log("Start date is ".concat(ee)),console.log("End date is ".concat(el)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ee,el);console.log("provider_spend",n),T(n);let r=(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(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),I(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),E(d);let c=await (0,u.J$)(l,null===(e=Y.from)||void 0===e?void 0:e.toISOString(),null===(a=Y.to)||void 0===a?void 0:a.toISOString());N(c.spend_per_tag);let h=await (0,u.b1)(l,null,void 0,void 0);v(h),console.log("spend/user result",h);let x=await (0,u.wd)(l,ee,el);R(x);let p=await (0,u.xA)(l,ee,el);console.log("global activity per model",p),G(p)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ee,el).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ee,el]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(J,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{className:"mt-2",children:[(0,a.jsx)(et.Z,{children:"All Up"}),(0,a.jsx)(et.Z,{children:"Team Based Usage"}),(0,a.jsx)(et.Z,{children:"End User Usage"}),(0,a.jsx)(et.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(et.Z,{children:"Cost"}),(0,a.jsx)(et.Z,{children:"Activity"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(em.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)(F.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)(e6.Z,{className:"mt-4 h-40",variant:"pie",data:P,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Provider"}),(0,a.jsx)(B.Z,{children:"Spend"})]})}),(0,a.jsx)(U.Z,{children:P.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.provider}),(0,a.jsx)(D.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)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(F.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)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",O.sum_api_requests]}),(0,a.jsx)(ec.Z,{className:"h-40",data:O.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",O.sum_total_tokens]}),(0,a.jsx)(em.Z,{className:"h-40",data:O.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:M.map((e,l)=>(0,a.jsxs)(F.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)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:M&&M.length>0&&M.slice(0,1).map((e,l)=>(0,a.jsxs)(F.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)(F.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)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(er.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)(F.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(e8.Z,{data:C})]}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(em.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:A,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users 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)(es.Z,{enableSelect:!0,value:Y,onValueChange:e=>{$(e),eo(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(z.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(V.Z,{value:"all-keys",onClick:()=>{eo(Y.from,Y.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)(V.Z,{value:String(l),onClick:()=>{eo(Y.from,Y.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(F.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"End User"}),(0,a.jsx)(B.Z,{children:"Spend"}),(0,a.jsx)(B.Z,{children:"Total Events"})]})}),(0,a.jsx)(U.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.end_user}),(0,a.jsx)(D.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(D.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsx)(es.Z,{className:"mb-4",enableSelect:!0,value:Y,onValueChange:e=>{$(e),ed(e.from,e.to)}}),(0,a.jsxs)(F.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/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(em.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})})]})]})]})},e9=()=>{let{Title:e,Paragraph:l}=ee.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(!0),Z=(0,i.useSearchParams)(),[f,_]=(0,r.useState)({data:[]}),y=Z.get("userID"),b=Z.get("token"),[v,S]=(0,r.useState)("api-keys"),[k,w]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(b){let e=(0,Q.o)(b);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(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"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&S("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?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[b]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:y,userRole:s,userEmail:d,showSSOBanner:j,premiumUser:n}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e5,{setPage:S,userRole:s,defaultSelectedKey:null})}),"api-keys"==v?(0,a.jsx)(el,{userID:y,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p}):"models"==v?(0,a.jsx)(eC,{userID:y,userRole:s,token:b,accessToken:k,modelData:f,setModelData:_,premiumUser:n}):"llm-playground"==v?(0,a.jsx)(e0,{userID:y,userRole:s,token:b,accessToken:k}):"users"==v?(0,a.jsx)(eT,{userID:y,userRole:s,token:b,keys:x,teams:u,accessToken:k,setKeys:p}):"teams"==v?(0,a.jsx)(eO,{teams:u,setTeams:h,searchParams:Z,accessToken:k,userID:y,userRole:s}):"admin-panel"==v?(0,a.jsx)(eR,{setTeams:h,searchParams:Z,accessToken:k,showSSOBanner:j}):"api_ref"==v?(0,a.jsx)(eX,{}):"settings"==v?(0,a.jsx)(eK,{userID:y,userRole:s,accessToken:k,premiumUser:n}):"budgets"==v?(0,a.jsx)(eJ,{accessToken:k}):"general-settings"==v?(0,a.jsx)(eH,{userID:y,userRole:s,accessToken:k,modelData:f}):"model-hub"==v?(0,a.jsx)(e$.Z,{accessToken:k,publicPage:!1,premiumUser:n}):(0,a.jsx)(e7,{userID:y,userRole:s,token:b,accessToken:k,keys:x,premiumUser:n})]})]})})}}},function(e){e.O(0,[936,359,440,134,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-1fb033a77b428a50.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-1fb033a77b428a50.js
new file mode 100644
index 000000000..82b275b53
--- /dev/null
+++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-1fb033a77b428a50.js
@@ -0,0 +1 @@
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,s){Promise.resolve().then(s.bind(s,5347))},5347:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return le}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let i=[{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(r)]})]})},{key:"2",label:(0,a.jsx)(o.default,{href:"/",children:(0,a.jsx)("p",{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?(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 enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:i},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(81583),k=s(80588),w=s(99129),N=s(44839),A=s(88707),I=s(1861);let{Option:E}=v.default;var C=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),[C,P]=(0,r.useState)(null),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)([]),[M,L]=(0,r.useState)([]),U=()=>{m(!1),d.resetFields()},D=()=>{m(!1),P(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),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let K=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"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),P(h.key),O(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)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(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:U,onCancel:D,children:(0,a.jsxs)(S.Z,{form:d,onFinish:K,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",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)(N.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)(E,{value:"all-team-models",children:"All Team Models"},"all-team-models"),M.map(e=>(0,a.jsx)(E,{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:"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)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Key"})})]})}),C&&(0,a.jsx)(w.Z,{visible:c,onOk:U,onCancel:D,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!=C?(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:C})}),(0,a.jsx)(b.CopyToClipboard,{text:C,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"})})]})})]})},P=s(9454),T=s(98941),O=s(33393),R=s(5),F=s(13810),M=s(61244),L=s(10827),U=s(3851),D=s(2044),K=s(64167),B=s(74480),q=s(7178),z=s(95093),V=s(27166);let{Option:G}=v.default;var W=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,E]=(0,r.useState)(null),[C,W]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,$]=(0,r.useState)(!1),[X,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(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),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,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"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Key Alias"}),(0,a.jsx)(B.Z,{children:"Secret Key"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(U.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(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.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)(q.Z,{children:[(0,a.jsx)(D.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)(D.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(D.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(R.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(D.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.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{onClick:()=>{Q(e),$(!0)},icon:P.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{$(!1),Q(null)},footer:null,width:800,children:X&&(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)(F.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(X.spend).toFixed(4)}catch(e){return X.spend}})()})})]}),(0,a.jsxs)(F.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!=X.max_budget?(0,a.jsx)(a.Fragment,{children:X.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(F.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!=X.expires?(0,a.jsx)(a.Fragment,{children:new Date(X.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)(F.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:X.key_alias?X.key_alias:X.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:X.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(X.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{$(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(M.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),X&&(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);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:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.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)(G,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(G,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(G,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(G,{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,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(z.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(V.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:X,onSubmit:er})]})},H=s(76032),Y=s(35152),J=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(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),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("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:["$",j]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)(_.Z,{children:"Team Models"})}),(0,a.jsx)(Z.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(H.Z,{children:p.map(e=>(0,a.jsx)(Y.Z,{children:(0,a.jsx)(_.Z,{children:e})},e))})})]})})]})},$=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.jsx)("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})})})},X=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.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."})]})]})},Q=s(37963),ee=s(97482);console.log("isLocal:",!1);var el=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p}=e,[j,g]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let f=Z.get("token"),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)([]),w={models:[],team_alias:"Default Team",team_id:null},[N,A]=(0,r.useState)(t?t[0]:w);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(f){let e=(0,Q.o)(f);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(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";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&&_&&s&&!n&&!j){let e=sessionStorage.getItem("userModels"+l);e?k(JSON.parse(e)):(async()=>{try{let e=await (0,u.Br)(_,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await (0,u.Qy)(_);g(e),console.log("globalSpend:",e)}else g(e.user_info);p(e.keys),m(e.teams);let t=[...e.teams];t.length>0?(console.log("response['teams']: ".concat(t)),A(t[0])):A(w),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let n=(await (0,u.So)(_,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),k(n),console.log("userModels:",S),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,f,_,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=N&&null!==N.team_id){let e=0;for(let l of n)N.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===N.team_id&&(e+=l.spend);v(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;v(e)}},[N]),null==l||null==f){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==_)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=ee.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",N),(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)($,{userID:l,userRole:s,selectedTeam:N||null,accessToken:_}),(0,a.jsx)(J,{userID:l,userRole:s,accessToken:_,userSpend:b,selectedTeam:N||null}),(0,a.jsx)(W,{userID:l,userRole:s,accessToken:_,selectedTeam:N||null,data:n,setData:p,teams:t}),(0,a.jsx)(C,{userID:l,team:N||null,userRole:s,accessToken:_,data:n,setData:p},N?N.team_id:null),(0,a.jsx)(X,{teams:t,setSelectedTeam:A,userRole:s})]})})})},es=s(35087),et=s(92836),en=s(26734),ea=s(41608),er=s(32126),ei=s(23682),eo=s(47047),ed=s(76628),ec=s(25707),em=s(44041),eu=s(1460),eh=s(28683),ex=s(38302),ep=s(78578),ej=s(63954),eg=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)(M.Z,{onClick:()=>n(!0),icon:O.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})]})})]})})]})},eZ=s(97766),ef=s(46495),e_=s(18190),ey=s(91118),eb=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ey.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)(e_.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"})})]})},ev=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))})},eS=s(67951);let{Title:ek,Link:ew}=ee.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks";let eN={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eI=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)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=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 eE=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},setModelData:g,premiumUser:Z}=e,[f,b]=(0,r.useState)([]),[v]=S.Z.useForm(),[N,E]=(0,r.useState)(null),[C,O]=(0,r.useState)(""),[G,W]=(0,r.useState)([]),H=Object.values(n).filter(e=>isNaN(Number(e))),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)("OpenAI"),[Q,el]=(0,r.useState)(""),[e_,ey]=(0,r.useState)(!1),[eE,eC]=(0,r.useState)(!1),[eP,eT]=(0,r.useState)(null),[eO,eR]=(0,r.useState)([]),[eF,eM]=(0,r.useState)(null),[eL,eU]=(0,r.useState)([]),[eD,eK]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[ez,eV]=(0,r.useState)([]),[eG,eW]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,e$]=(0,r.useState)([]),[eX,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e5,e8]=(0,r.useState)(null),[e3,e6]=(0,r.useState)(0),e7=e=>{eT(e),ey(!0)},e9=e=>{eT(e),eC(!0)},le=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),ey(!1),eT(null)}catch(e){console.log("Error occurred")}},ll=()=>{O(new Date().toLocaleString())},ls=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e5);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e5}}),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(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i;let d=await (0,u.hy)(o);J(d);let h=await (0,u.AZ)(o,m,c);console.log("Model data response:",h.data),g(h);let x=new Set;for(let e=0;e0&&(j=p[p.length-1],console.log("_initial_model_group:",j),eM(j)),console.log("selectedModelGroup:",eF);let Z=await (0,u.o6)(o,m,c,j,null===(e=e2.from)||void 0===e?void 0:e.toISOString(),null===(l=e2.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",Z),eK(Z.data),eq(Z.all_api_bases);let f=await (0,u.Rg)(o,j,null===(s=e2.from)||void 0===s?void 0:s.toISOString(),null===(t=e2.to)||void 0===t?void 0:t.toISOString());eV(f.data),eW(f.all_api_bases);let _=await (0,u.N8)(o,m,c,j,null===(n=e2.from)||void 0===n?void 0:n.toISOString(),null===(a=e2.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",_),eY(_.data),e$(_.exception_types);let y=await (0,u.fP)(o,m,c,j,null===(r=e2.from)||void 0===r?void 0:r.toISOString(),null===(i=e2.to)||void 0===i?void 0:i.toISOString());console.log("slowResponses:",y),e1(y);let b=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",b);let v=b.model_group_retry_policy,S=b.num_retries;console.log("model_group_retry_policy:",v),console.log("default_retries:",S),e8(v),e6(S)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),E(e)};null==N&&l(),ll()},[o,d,c,m,N,C]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lt=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(N)),null!=N&&"object"==typeof N&&e in N)?N[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lt.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=ee.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 ln=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eN[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof N&&Object.entries(N).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)}),W(s),console.log("providerModels: ".concat(G))}},la=async()=>{try{k.ZP.info("Running health check..."),el("");let e=await (0,u.EY)(o);el(e)}catch(e){console.error("Error running health check:",e),el("Error running health check")}},lr=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),o&&m&&c&&l&&s){console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),eM(e);try{let t=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model metrics response:",t),eK(t.data),eq(t.all_api_bases);let n=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eV(n.data),eW(n.all_api_bases);let a=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model exceptions response:",a),eY(a.data),e$(a.exception_types);let r=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString());console.log("slowResponses:",r),e1(r)}catch(e){console.error("Failed to fetch model metrics",e)}}},li=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)})]})};console.log("selectedProvider: ".concat($)),console.log("providerModels.length: ".concat(G.length));let lo=Object.keys(n).find(e=>n[e]===$);return lo&&(i=Y.find(e=>e.name===eN[lo])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(et.Z,{children:"All Models"}),(0,a.jsx)(et.Z,{children:"Add Model"}),(0,a.jsx)(et.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(et.Z,{children:"Model Analytics"}),(0,a.jsx)(et.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[C&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",C]}),(0,a.jsx)(M.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ll})]})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],onValueChange:e=>eM("all"===e?"all":e),value:eF||eO[0],children:[(0,a.jsx)(V.Z,{value:"all",children:"All Models"}),eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))]})]}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(B.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)(B.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)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(B.Z,{})]})}),(0,a.jsx)(U.Z,{children:h.data.filter(e=>"all"===eF||e.model_name===eF||null==eF||""===eF).map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.model_name||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"10px"},title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},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)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&e.model_info.created_by||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:P.Z,size:"sm",onClick:()=>e9(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>e7(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eg,{modelID:e.model_info.id,accessToken:o})})]})})]},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:le,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:"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_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(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)(I.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:e_,onCancel:()=>{ey(!1),eT(null)},model:eP,onSubmit:le}),(0,a.jsxs)(w.Z,{title:eP&&eP.model_name,visible:eE,width:800,footer:null,onCancel:()=>{eC(!1),eT(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eS.Z,{language:"json",children:eP&&JSON.stringify(eP,null,2)})]})]}),(0,a.jsxs)(er.Z,{className:"h-full",children:[(0,a.jsx)(ek,{level:2,children:"Add new model"}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(S.Z,{form:v,onFinish:()=>{v.validateFields().then(e=>{eI(e,o,v)}).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)(z.Z,{value:$.toString(),children:H.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>{ln(e),X(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,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=$.toString())?"gemini-pro":"Anthropic"==t?"claude-3-opus":"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===$?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(eo.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(ed.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(ew,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(ew,{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!==i&&i.fields.length>0&&(0,a.jsx)(ev,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=$&&"Vertex AI (Anthropic, Gemini, etc.)"!=$&&(void 0===i||0==i.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"==$&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(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.)"==$&&(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.)"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ef.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;v.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)(I.ZP,{icon:(0,a.jsx)(eZ.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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"==$||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==$)&&(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"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==$&&(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)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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)(ew,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==$&&(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"==$&&(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"==$&&(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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(ew,{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)(I.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eu.Z,{title:"Get help on our github",children:(0,a.jsx)(ee.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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:la,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(es.Z,{enableSelect:!0,value:e2,onValueChange:e=>{e4(e),lr(eF,e.from,e.to)}})]}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2",defaultValue:eF||eO[0],value:eF||eO[0],children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>lr(e,e2.from,e2.to),children:e},l))})]})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(et.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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"}),eD&&eB&&(0,a.jsx)(ec.Z,{title:"Model Latency",className:"h-72",data:eD,showLegend:!1,index:"date",categories:eB,connectNulls:!0,customTooltip:li})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(eb,{modelMetrics:ez,modelMetricsCategories:eG,customTooltip:li,premiumUser:Z})})]})]})})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Deployment"}),(0,a.jsx)(B.Z,{children:"Success Responses"}),(0,a.jsxs)(B.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(U.Z,{children:e0.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.api_base}),(0,a.jsx)(D.Z,{children:e.total_count}),(0,a.jsx)(D.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(F.Z,{className:"mt-4",children:[(0,a.jsx)(y.Z,{children:"Exceptions per Model"}),(0,a.jsx)(em.Z,{className:"h-72",data:eH,index:"model",categories:eJ,stack:!0,yAxisWidth:30})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],value:eF||eO[0],onValueChange:e=>eM(e),children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eF]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e5?void 0:null===(s=e5[eF])||void 0===s?void 0:s[n];return null==r&&(r=e3),(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=>{e8(l=>{var s;let t=null!==(s=null==l?void 0:l[eF])&&void 0!==s?s:{};return{...null!=l?l:{},[eF]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:ls,children:"Save"})]})]})]})})};let{Option:eC}=v.default;var eP=e=>{let{userID:l,accessToken:s,teams:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[m,h]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{o(!1),n.resetFields()},g=()=>{o(!1),c(null),n.resetFields()},Z=async e=>{try{k.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let t=await (0,u.Ov)(s,null,e);console.log("user create Response:",t),c(t.key),k.ZP.success("API user Created"),n.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:()=>o(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:i,width:800,footer:null,onOk:x,onCancel:g,children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(_.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(S.Z,{form:n,onFinish:Z,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:"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)(eC,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eC,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create User"})})]})]}),d&&(0,a.jsxs)(w.Z,{title:"User Created Successfully",visible:i,onOk:x,onCancel:g,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},eT=e=>{let{visible:l,onCancel:s,user:t,onSubmit:n}=e,[i,o]=(0,r.useState)(t),[d]=S.Z.useForm();(0,r.useEffect)(()=>{d.resetFields()},[t]);let c=async()=>{d.resetFields(),s()},m=async e=>{d.resetFields(),n(e),s()};return t?(0,a.jsx)(w.Z,{visible:l,onCancel:c,footer:null,title:"Edit User "+t.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:d,onFinish:m,initialValues:t,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.jsxs)(v.default,{children:[(0,a.jsx)(v.default.Option,{value:"proxy_admin",children:"Proxy Admin (Can create, edit, delete keys, teams)"}),(0,a.jsx)(v.default.Option,{value:"proxy_admin_viewer",children:"Proxy Viewer (Can just view spend, cannot created keys, teams)"})]})}),(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)(I.ZP,{htmlType:"submit",children:"Save"})})]})})}):null},eO=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[y,b]=(0,r.useState)(null),[v,S]=(0,r.useState)(!1),[k,w]=(0,r.useState)(null),N=async()=>{w(null),S(!1)},A=async e=>{console.log("inside handleEditSubmit:",e),l&&s&&n&&i&&((0,u.pf)(l,e,n),c&&m(c.map(l=>l.user_id===e.user_id?e:l)),w(null),S(!1))};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(eP,{userID:i,accessToken:l,teams:o}),(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(_.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(en.Z,{children:(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"User ID"}),(0,a.jsx)(B.Z,{children:"User Email"}),(0,a.jsx)(B.Z,{children:"User Models"}),(0,a.jsx)(B.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(B.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(B.Z,{children:"API Keys"}),(0,a.jsx)(B.Z,{})]})}),(0,a.jsx)(U.Z,{children:c.map(e=>{var l;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_id}),(0,a.jsx)(D.Z,{children:e.user_email}),(0,a.jsx)(D.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(D.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsxs)(R.Z,{size:"xs",color:"indigo",children:[e.key_aliases.filter(e=>null!==e).length,"\xa0Keys"]}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:P.Z,onClick:()=>{f(e.user_id),b(e)},children:"View Keys"}),(0,a.jsx)(M.Z,{icon:T.Z,onClick:()=>{w(e),S(!0)},children:"View Keys"}),(0,a.jsx)(M.Z,{icon:O.Z,onClick:()=>{f(e.user_id),b(e)},children:"View Keys"})]})]},e.user_id)})})]})}),(0,a.jsx)(er.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)(eT,{visible:v,onCancel:N,user:k,onSubmit:A})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+1," 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:0===j,onClick:()=>g(j-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",onClick:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eR=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=ee.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[E,C]=(0,r.useState)(l?l[0]:null),[P,G]=(0,r.useState)(!1),[W,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)(!1),[Q,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{C(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),C(null)},er=async e=>{el(e),X(!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)}X(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{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),J(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"),G(!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:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,E.team_id,s);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),C(a.data)}H(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Team Name"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(B.Z,{children:"Info"})]})}),(0,a.jsx)(U.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.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)(D.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)(D.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(M.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),$&&(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:()=>{X(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>G(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:P,width:800,footer:null,onOk:()=>{G(!1),d.resetFields()},onCancel:()=>{G(!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"),Y.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,{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)(I.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.Z,{value:String(l),onClick:()=>{C(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:E?E.members_with_roles.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.role})]},l)):null})]})}),E&&(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"),Y&&Y.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,{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)(I.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),C(null)},team:E,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:W,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eF=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[i]=S.Z.useForm(),[o]=S.Z.useForm(),{Title:d,Paragraph:c}=ee.default,[m,j]=(0,r.useState)(""),[g,Z]=(0,r.useState)(null),[f,y]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[A,E]=(0,r.useState)(!1),[C,P]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let G=()=>{R(!1)},W=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),Z(e)}})()},[t]);let H=()=>{E(!1),o.resetFields()},Y=()=>{E(!1),o.resetFields()},J=e=>(0,a.jsxs)(S.Z,{form:i,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]}),$=(e,l,s)=>(0,a.jsxs)(S.Z,{form:i,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)(z.Z,{value:l,children:W.map((e,l)=>(0,a.jsx)(V.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)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update role"})})]}),X=async e=>{try{if(null!=t&&null!=g){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=g.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"),g.push(l),Z(g)),k.ZP.success("Refresh tab to see updated user role"),E(!1)}}catch(e){console.error("Error creating the key:",e)}},Q=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),y(!1)}}catch(e){console.error("Error creating the key:",e)}},el=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await (0,u.pf)(t,e,"proxy_admin");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),v(!1)}}catch(e){console.error("Error creating the key:",e)}},es=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==g?void 0:g.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(d,{level:4,children:"Admin Access "}),(0,a.jsxs)(c,{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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:g?g.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.user_role}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>E(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:A,width:800,footer:null,onOk:H,onCancel:Y,children:$(X,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:()=>v(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:b,width:800,footer:null,onOk:()=>{v(!1),o.resetFields()},onCancel:()=>{v(!1),o.resetFields()},children:J(el)}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>y(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:f,width:800,footer:null,onOk:()=>{y(!1),o.resetFields()},onCancel:()=>{y(!1),o.resetFields()},children:J(Q)})]})})]}),(0,a.jsxs)(x.Z,{children:[(0,a.jsx)(d,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(p.Z,{onClick:()=>P(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:C,width:800,footer:null,onOk:()=>{P(!1),i.resetFields()},onCancel:()=>{P(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{el(e),es(e),P(!1),R(!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)(N.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)(N.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)(N.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)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:O,width:800,footer:null,onOk:G,onCancel:()=>{R(!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)(I.ZP,{onClick:G,children:"Done"})})]})]}),(0,a.jsxs)(e_.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})," "]})]})]})]})},eM=s(42556),eL=s(90252),eU=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:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(D.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",children:(0,a.jsx)(D.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"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eL.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eD=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eU,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}: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);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})};let eK=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var eB=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)(eK),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[b,N]=(0,r.useState)([]),[A,E]=(0,r.useState)(""),[C,P]=(0,r.useState)({}),[T,O]=(0,r.useState)([]),M=e=>{T.includes(e)?O(T.filter(l=>l!==e)):O([...T,e])},z={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);let l=eK;o(l=l.map(l=>{let s=e.callbacks.find(e=>e.name===l.name);return s?{...l,variables:{...l.variables,...s.variables}}:l}));let s=e.alerts;if(console.log("alerts_data",s),s&&s.length>0){let e=s[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),O(e.active_alerts),E(l),P(e.alerts_to_webhook)}c(s)})},[l,s,t]);let V=e=>T&&T.includes(e),G=()=>{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")},W=e=>{if(!l)return;let s=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[s,t]=e;return[s,(null===(l=document.querySelector('input[name="'.concat(s,'"]')))||void 0===l?void 0:l.value)||t]}));console.log("updatedVariables",s),console.log("updateAlertTypes",b);let t={environment_variables:s,litellm_settings:{success_callback:[e.name]}};try{(0,u.K_)(l,t)}catch(e){k.ZP.error("Failed to update callback: "+e,20)}k.ZP.success("Callback updated successfully")},H=()=>{l&&g.validateFields().then(e=>{let s;if(console.log("Form values:",e),"langfuse"===e.callback){s={environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),s={general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}},(0,u.K_)(l,s),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),s={environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};o(i?[...i,t]:[t])}else s={error:"Invalid callback value"};h(!1),g.resetFields(),f(null)})};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(e_.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(et.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(et.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(et.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Callback"}),(0,a.jsx)(B.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(U.Z,{children:i.filter(e=>"slack"!==e.name).map((e,s)=>{var t;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:(0,a.jsx)(R.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(t=e.variables)&&void 0!==t?t:{}).filter(l=>{let[s,t]=l;return s.toLowerCase().includes(e.name)}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password"})]},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>W(e),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"mx-2",children:"Test Callback"})]})]},s)})})]})})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(z).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eM.Z,{id:"switch",name:"switch",checked:V(s),onChange:()=>M(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)(eM.Z,{id:"switch",name:"switch",checked:V(s),onChange:()=>M(s)})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:A})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(z).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:T}};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)(er.Z,{children:(0,a.jsx)(eD,{accessToken:l,premiumUser:n})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{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)(D.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:()=>G(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})]}),(0,a.jsx)(w.Z,{title:"Add Callback",visible:m,onOk:H,width:800,onCancel:()=>{h(!1),g.resetFields(),f(null)},footer:null,children:(0,a.jsxs)(S.Z,{form:g,layout:"vertical",onFinish:H,children:[(0,a.jsx)(S.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(v.default,{onChange:e=>{f(e)},children:[(0,a.jsx)(v.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(v.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===Z&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(j.Z,{type:"password"})}),(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(j.Z,{type:"password"})})]}),"openmeter"==Z&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(j.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eq}=v.default;var ez=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)(z.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(V.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)(eo.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ed.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eV=s(12968);async function eG(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new eV.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 eW={ttl:3600,lowest_latency_buffer:0},eH=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)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.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 eY=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),[E,C]=(0,r.useState)(null),P={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(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)}}},G=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},W=(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){}},H=(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){}},Y=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)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(et.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(et.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.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)(F.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.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)(q.Z,{children:[(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,a.jsx)(D.Z,{children:"routing_strategy"==l?(0,a.jsxs)(z.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(V.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(V.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(V.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)(eH,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eW,paramExplanation:P})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Model Name"}),(0,a.jsx)(B.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(U.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:t}),(0,a.jsx)(D.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eG(t,l),children:"Test Fallback"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(ez,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"}),(0,a.jsx)(B.Z,{children:"Status"}),(0,a.jsx)(B.Z,{children:"Action"})]})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>G(e.field_name,l)}):null}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eL.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>W(e.field_name,l),children:"Update"}),(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},eJ=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:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},e$=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.ZP.success("Budget Deleted.")};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)(eJ,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Budget ID"}),(0,a.jsx)(B.Z,{children:"Max Budget"}),(0,a.jsx)(B.Z,{children:"TPM"}),(0,a.jsx)(B.Z,{children:"RPM"})]})}),(0,a.jsx)(U.Z,{children:n.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.budget_id}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(D.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(D.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>o(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(et.Z,{children:"Test it (Curl)"}),(0,a.jsx)(et.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{}=e;return(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(et.Z,{children:"LlamaIndex"}),(0,a.jsx)(et.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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="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)(er.Z,{children:(0,a.jsx)(eS.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="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,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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 = "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 e0(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new eV.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 e1=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}));console.log(l),b(l),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 e0(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}=ee.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)(F.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(et.Z,{children:"Chat"})}),(0,a.jsx)(ei.Z,{children:(0,a.jsxs)(er.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)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.Z,{})})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.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),placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e2=s(33509),e4=s(95781);let{Sider:e5}=e2.default;var e8=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e2.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e5,{width:120,children:(0,a.jsxs)(e4.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e4.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(e2.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e5,{width:145,children:(0,a.jsxs)(e4.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e4.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Internal Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Budgets"})},"9"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e4.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},e3=s(67989),e6=s(49167),e7=s(52703),e9=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)([]),[A,I]=(0,r.useState)([]),[E,C]=(0,r.useState)([]),[P,T]=(0,r.useState)([]),[O,R]=(0,r.useState)({}),[M,G]=(0,r.useState)([]),[W,H]=(0,r.useState)(""),[Y,$]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),X=new Date(d.getFullYear(),d.getMonth(),1),Q=new Date(d.getFullYear(),d.getMonth()+1,0),ee=eh(X),el=eh(Q);function eo(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 ed=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)},eu=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function eh(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)}return console.log("Start date is ".concat(ee)),console.log("End date is ".concat(el)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ee,el);console.log("provider_spend",n),T(n);let r=(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(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),I(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),C(d);let c=await (0,u.J$)(l,null===(e=Y.from)||void 0===e?void 0:e.toISOString(),null===(a=Y.to)||void 0===a?void 0:a.toISOString());N(c.spend_per_tag);let h=await (0,u.b1)(l,null,void 0,void 0);v(h),console.log("spend/user result",h);let x=await (0,u.wd)(l,ee,el);R(x);let p=await (0,u.xA)(l,ee,el);console.log("global activity per model",p),G(p)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ee,el).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ee,el]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(J,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{className:"mt-2",children:[(0,a.jsx)(et.Z,{children:"All Up"}),(0,a.jsx)(et.Z,{children:"Team Based Usage"}),(0,a.jsx)(et.Z,{children:"End User Usage"}),(0,a.jsx)(et.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(et.Z,{children:"Cost"}),(0,a.jsx)(et.Z,{children:"Activity"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(em.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)(F.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)(e7.Z,{className:"mt-4 h-40",variant:"pie",data:P,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Provider"}),(0,a.jsx)(B.Z,{children:"Spend"})]})}),(0,a.jsx)(U.Z,{children:P.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.provider}),(0,a.jsx)(D.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)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(F.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)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eo(O.sum_api_requests)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:O.daily_data,valueFormatter:eo,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eo(O.sum_total_tokens)]}),(0,a.jsx)(em.Z,{className:"h-40",data:O.daily_data,valueFormatter:eo,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:M.map((e,l)=>(0,a.jsxs)(F.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)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eo(e.sum_api_requests)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eo,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eo(e.sum_total_tokens)]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eo,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:M&&M.length>0&&M.slice(0,1).map((e,l)=>(0,a.jsxs)(F.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)(F.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)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eo(e.sum_api_requests)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eo,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eo(e.sum_total_tokens)]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eo,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(er.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)(F.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(e3.Z,{data:E})]}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(em.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:A,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users 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)(es.Z,{enableSelect:!0,value:Y,onValueChange:e=>{$(e),ed(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(z.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(V.Z,{value:"all-keys",onClick:()=>{ed(Y.from,Y.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)(V.Z,{value:String(l),onClick:()=>{ed(Y.from,Y.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(F.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"End User"}),(0,a.jsx)(B.Z,{children:"Spend"}),(0,a.jsx)(B.Z,{children:"Total Events"})]})}),(0,a.jsx)(U.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.end_user}),(0,a.jsx)(D.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(D.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsx)(es.Z,{className:"mb-4",enableSelect:!0,value:Y,onValueChange:e=>{$(e),eu(e.from,e.to)}}),(0,a.jsxs)(F.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/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(em.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})})]})]})]})},le=()=>{let{Title:e,Paragraph:l}=ee.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(!0),Z=(0,i.useSearchParams)(),[f,_]=(0,r.useState)({data:[]}),y=Z.get("userID"),b=Z.get("token"),[v,S]=(0,r.useState)("api-keys"),[k,w]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(b){let e=(0,Q.o)(b);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(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"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&S("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?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[b]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:y,userRole:s,userEmail:d,showSSOBanner:j,premiumUser:n}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e8,{setPage:S,userRole:s,defaultSelectedKey:null})}),"api-keys"==v?(0,a.jsx)(el,{userID:y,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p}):"models"==v?(0,a.jsx)(eE,{userID:y,userRole:s,token:b,accessToken:k,modelData:f,setModelData:_,premiumUser:n}):"llm-playground"==v?(0,a.jsx)(e1,{userID:y,userRole:s,token:b,accessToken:k}):"users"==v?(0,a.jsx)(eO,{userID:y,userRole:s,token:b,keys:x,teams:u,accessToken:k,setKeys:p}):"teams"==v?(0,a.jsx)(eR,{teams:u,setTeams:h,searchParams:Z,accessToken:k,userID:y,userRole:s}):"admin-panel"==v?(0,a.jsx)(eF,{setTeams:h,searchParams:Z,accessToken:k,showSSOBanner:j}):"api_ref"==v?(0,a.jsx)(eQ,{}):"settings"==v?(0,a.jsx)(eB,{userID:y,userRole:s,accessToken:k,premiumUser:n}):"budgets"==v?(0,a.jsx)(e$,{accessToken:k}):"general-settings"==v?(0,a.jsx)(eY,{userID:y,userRole:s,accessToken:k,modelData:f}):"model-hub"==v?(0,a.jsx)(eX.Z,{accessToken:k,publicPage:!1,premiumUser:n}):(0,a.jsx)(e9,{userID:y,userRole:s,token:b,accessToken:k,keys:x,premiumUser:n})]})]})})}}},function(e){e.O(0,[936,359,440,134,971,69,744],function(){return e(e.s=20661)}),_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 b12c05bc4..28d620ebf 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 99372005b..15941a134 100644
--- a/litellm/proxy/_experimental/out/index.txt
+++ b/litellm/proxy/_experimental/out/index.txt
@@ -1,7 +1,7 @@
2:I[77831,[],""]
-3:I[62631,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","359","static/chunks/359-f105a7fb61fe8110.js","440","static/chunks/440-b9a05f116e1a696d.js","134","static/chunks/134-af41d2d267857018.js","931","static/chunks/app/page-0f6ae871c63eb14b.js"],""]
+3:I[5347,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","359","static/chunks/359-f105a7fb61fe8110.js","440","static/chunks/440-b9a05f116e1a696d.js","134","static/chunks/134-af41d2d267857018.js","931","static/chunks/app/page-1fb033a77b428a50.js"],""]
4:I[5613,[],""]
5:I[31778,[],""]
-0:["XsAEnZvT8GWmMEp4_0in-",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
+0:["QpcxqKJjVnif9CYPhpWjb",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
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/index.html b/litellm/proxy/_experimental/out/model_hub.html
similarity index 98%
rename from litellm/proxy/_experimental/out/model_hub/index.html
rename to litellm/proxy/_experimental/out/model_hub.html
index 02ef53bef..75b1c508b 100644
--- a/litellm/proxy/_experimental/out/model_hub/index.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 dd60dcaf6..3769dfc87 100644
--- a/litellm/proxy/_experimental/out/model_hub.txt
+++ b/litellm/proxy/_experimental/out/model_hub.txt
@@ -2,6 +2,6 @@
3:I[87494,["359","static/chunks/359-f105a7fb61fe8110.js","134","static/chunks/134-af41d2d267857018.js","418","static/chunks/app/model_hub/page-aa3c10cf9bb31255.js"],""]
4:I[5613,[],""]
5:I[31778,[],""]
-0:["XsAEnZvT8GWmMEp4_0in-",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
+0:["QpcxqKJjVnif9CYPhpWjb",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
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 daae71ba3..2c4f52e83 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/XsAEnZvT8GWmMEp4_0in-/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_buildManifest.js
similarity index 100%
rename from ui/litellm-dashboard/out/_next/static/XsAEnZvT8GWmMEp4_0in-/_buildManifest.js
rename to ui/litellm-dashboard/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_buildManifest.js
diff --git a/ui/litellm-dashboard/out/_next/static/XsAEnZvT8GWmMEp4_0in-/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_ssgManifest.js
similarity index 100%
rename from ui/litellm-dashboard/out/_next/static/XsAEnZvT8GWmMEp4_0in-/_ssgManifest.js
rename to ui/litellm-dashboard/out/_next/static/QpcxqKJjVnif9CYPhpWjb/_ssgManifest.js
diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-0f6ae871c63eb14b.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-0f6ae871c63eb14b.js
deleted file mode 100644
index 5e1fb3b33..000000000
--- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-0f6ae871c63eb14b.js
+++ /dev/null
@@ -1 +0,0 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,s){Promise.resolve().then(s.bind(s,62631))},62631:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return e9}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let i=[{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(r)]})]})}];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?(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 enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:i},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(81583),k=s(80588),w=s(99129),N=s(44839),A=s(88707),I=s(1861);let{Option:C}=v.default;var E=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),[E,P]=(0,r.useState)(null),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)([]),[M,L]=(0,r.useState)([]),U=()=>{m(!1),d.resetFields()},D=()=>{m(!1),P(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),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let K=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"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),P(h.key),O(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)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(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:U,onCancel:D,children:(0,a.jsxs)(S.Z,{form:d,onFinish:K,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",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)(N.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)(C,{value:"all-team-models",children:"All Team Models"},"all-team-models"),M.map(e=>(0,a.jsx)(C,{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:"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)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Key"})})]})}),E&&(0,a.jsx)(w.Z,{visible:c,onOk:U,onCancel:D,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!=E?(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:E})}),(0,a.jsx)(b.CopyToClipboard,{text:E,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"})})]})})]})},P=s(9454),T=s(98941),O=s(33393),R=s(5),F=s(13810),M=s(61244),L=s(10827),U=s(3851),D=s(2044),K=s(64167),B=s(74480),q=s(7178),z=s(95093),V=s(27166);let{Option:G}=v.default;var W=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,C]=(0,r.useState)(null),[E,W]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,$]=(0,r.useState)(!1),[X,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(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),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,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"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Key Alias"}),(0,a.jsx)(B.Z,{children:"Secret Key"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(U.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(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.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)(q.Z,{children:[(0,a.jsx)(D.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)(D.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(D.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(R.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(D.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.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{onClick:()=>{Q(e),$(!0)},icon:P.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{$(!1),Q(null)},footer:null,width:800,children:X&&(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)(F.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(X.spend).toFixed(4)}catch(e){return X.spend}})()})})]}),(0,a.jsxs)(F.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!=X.max_budget?(0,a.jsx)(a.Fragment,{children:X.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(F.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!=X.expires?(0,a.jsx)(a.Fragment,{children:new Date(X.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)(F.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:X.key_alias?X.key_alias:X.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:X.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(X.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{$(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(M.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),X&&(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);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:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.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)(G,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(G,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(G,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(G,{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,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(z.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(V.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:X,onSubmit:er})]})},H=s(76032),Y=s(35152),J=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(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),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("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:["$",j]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)(_.Z,{children:"Team Models"})}),(0,a.jsx)(Z.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(H.Z,{children:p.map(e=>(0,a.jsx)(Y.Z,{children:(0,a.jsx)(_.Z,{children:e})},e))})})]})})]})},$=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.jsx)("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})})})},X=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.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."})]})]})},Q=s(37963),ee=s(97482);console.log("isLocal:",!1);var el=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p}=e,[j,g]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let f=Z.get("token"),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)([]),w={models:[],team_alias:"Default Team",team_id:null},[N,A]=(0,r.useState)(t?t[0]:w);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(f){let e=(0,Q.o)(f);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(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";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&&_&&s&&!n&&!j){let e=sessionStorage.getItem("userModels"+l);e?k(JSON.parse(e)):(async()=>{try{let e=await (0,u.Br)(_,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await (0,u.Qy)(_);g(e),console.log("globalSpend:",e)}else g(e.user_info);p(e.keys),m(e.teams);let t=[...e.teams];t.length>0?(console.log("response['teams']: ".concat(t)),A(t[0])):A(w),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let n=(await (0,u.So)(_,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),k(n),console.log("userModels:",S),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,f,_,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=N&&null!==N.team_id){let e=0;for(let l of n)N.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===N.team_id&&(e+=l.spend);v(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;v(e)}},[N]),null==l||null==f){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==_)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=ee.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",N),(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)($,{userID:l,userRole:s,selectedTeam:N||null,accessToken:_}),(0,a.jsx)(J,{userID:l,userRole:s,accessToken:_,userSpend:b,selectedTeam:N||null}),(0,a.jsx)(W,{userID:l,userRole:s,accessToken:_,selectedTeam:N||null,data:n,setData:p,teams:t}),(0,a.jsx)(E,{userID:l,team:N||null,userRole:s,accessToken:_,data:n,setData:p},N?N.team_id:null),(0,a.jsx)(X,{teams:t,setSelectedTeam:A,userRole:s})]})})})},es=s(35087),et=s(92836),en=s(26734),ea=s(41608),er=s(32126),ei=s(23682),eo=s(47047),ed=s(76628),ec=s(25707),em=s(44041),eu=s(1460),eh=s(28683),ex=s(38302),ep=s(78578),ej=s(63954),eg=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)(M.Z,{onClick:()=>n(!0),icon:O.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})]})})]})})]})},eZ=s(97766),ef=s(46495),e_=s(18190),ey=s(91118),eb=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ey.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)(e_.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"})})]})},ev=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))})},eS=s(67951);let{Title:ek,Link:ew}=ee.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks";let eN={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eI=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)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=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 eC=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},setModelData:g,premiumUser:Z}=e,[f,b]=(0,r.useState)([]),[v]=S.Z.useForm(),[N,C]=(0,r.useState)(null),[E,O]=(0,r.useState)(""),[G,W]=(0,r.useState)([]),H=Object.values(n).filter(e=>isNaN(Number(e))),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)("OpenAI"),[Q,el]=(0,r.useState)(""),[e_,ey]=(0,r.useState)(!1),[eC,eE]=(0,r.useState)(!1),[eP,eT]=(0,r.useState)(null),[eO,eR]=(0,r.useState)([]),[eF,eM]=(0,r.useState)(null),[eL,eU]=(0,r.useState)([]),[eD,eK]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[ez,eV]=(0,r.useState)([]),[eG,eW]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,e$]=(0,r.useState)([]),[eX,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e5,e8]=(0,r.useState)(null),[e3,e6]=(0,r.useState)(0),e7=e=>{eT(e),ey(!0)},e9=e=>{eT(e),eE(!0)},le=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),ey(!1),eT(null)}catch(e){console.log("Error occurred")}},ll=()=>{O(new Date().toLocaleString())},ls=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e5);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e5}}),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(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i;let d=await (0,u.hy)(o);J(d);let h=await (0,u.AZ)(o,m,c);console.log("Model data response:",h.data),g(h);let x=new Set;for(let e=0;e0&&(j=p[p.length-1],console.log("_initial_model_group:",j),eM(j)),console.log("selectedModelGroup:",eF);let Z=await (0,u.o6)(o,m,c,j,null===(e=e2.from)||void 0===e?void 0:e.toISOString(),null===(l=e2.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",Z),eK(Z.data),eq(Z.all_api_bases);let f=await (0,u.Rg)(o,j,null===(s=e2.from)||void 0===s?void 0:s.toISOString(),null===(t=e2.to)||void 0===t?void 0:t.toISOString());eV(f.data),eW(f.all_api_bases);let _=await (0,u.N8)(o,m,c,j,null===(n=e2.from)||void 0===n?void 0:n.toISOString(),null===(a=e2.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",_),eY(_.data),e$(_.exception_types);let y=await (0,u.fP)(o,m,c,j,null===(r=e2.from)||void 0===r?void 0:r.toISOString(),null===(i=e2.to)||void 0===i?void 0:i.toISOString());console.log("slowResponses:",y),e1(y);let b=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",b);let v=b.model_group_retry_policy,S=b.num_retries;console.log("model_group_retry_policy:",v),console.log("default_retries:",S),e8(v),e6(S)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),C(e)};null==N&&l(),ll()},[o,d,c,m,N,E]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lt=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(N)),null!=N&&"object"==typeof N&&e in N)?N[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lt.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=ee.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 ln=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eN[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof N&&Object.entries(N).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)}),W(s),console.log("providerModels: ".concat(G))}},la=async()=>{try{k.ZP.info("Running health check..."),el("");let e=await (0,u.EY)(o);el(e)}catch(e){console.error("Error running health check:",e),el("Error running health check")}},lr=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),o&&m&&c&&l&&s){console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),eM(e);try{let t=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model metrics response:",t),eK(t.data),eq(t.all_api_bases);let n=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eV(n.data),eW(n.all_api_bases);let a=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model exceptions response:",a),eY(a.data),e$(a.exception_types);let r=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString());console.log("slowResponses:",r),e1(r)}catch(e){console.error("Failed to fetch model metrics",e)}}},li=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)})]})};console.log("selectedProvider: ".concat($)),console.log("providerModels.length: ".concat(G.length));let lo=Object.keys(n).find(e=>n[e]===$);return lo&&(i=Y.find(e=>e.name===eN[lo])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(et.Z,{children:"All Models"}),(0,a.jsx)(et.Z,{children:"Add Model"}),(0,a.jsx)(et.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(et.Z,{children:"Model Analytics"}),(0,a.jsx)(et.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[E&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",E]}),(0,a.jsx)(M.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ll})]})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],onValueChange:e=>eM("all"===e?"all":e),value:eF||eO[0],children:[(0,a.jsx)(V.Z,{value:"all",children:"All Models"}),eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))]})]}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(B.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)(B.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)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(B.Z,{})]})}),(0,a.jsx)(U.Z,{children:h.data.filter(e=>"all"===eF||e.model_name===eF||null==eF||""===eF).map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.model_name||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"10px"},title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},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)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&e.model_info.created_by||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:P.Z,size:"sm",onClick:()=>e9(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>e7(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eg,{modelID:e.model_info.id,accessToken:o})})]})})]},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:le,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:"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_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(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)(I.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:e_,onCancel:()=>{ey(!1),eT(null)},model:eP,onSubmit:le}),(0,a.jsxs)(w.Z,{title:eP&&eP.model_name,visible:eC,width:800,footer:null,onCancel:()=>{eE(!1),eT(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eS.Z,{language:"json",children:eP&&JSON.stringify(eP,null,2)})]})]}),(0,a.jsxs)(er.Z,{className:"h-full",children:[(0,a.jsx)(ek,{level:2,children:"Add new model"}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(S.Z,{form:v,onFinish:()=>{v.validateFields().then(e=>{eI(e,o,v)}).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)(z.Z,{value:$.toString(),children:H.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>{ln(e),X(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,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=$.toString())?"gemini-pro":"Anthropic"==t?"claude-3-opus":"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===$?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(eo.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(ed.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(ew,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(ew,{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!==i&&i.fields.length>0&&(0,a.jsx)(ev,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=$&&"Vertex AI (Anthropic, Gemini, etc.)"!=$&&void 0===i&&(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"==$&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(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.)"==$&&(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.)"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ef.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;v.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)(I.ZP,{icon:(0,a.jsx)(eZ.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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"==$||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==$)&&(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"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==$&&(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)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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)(ew,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==$&&(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"==$&&(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"==$&&(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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(ew,{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)(I.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eu.Z,{title:"Get help on our github",children:(0,a.jsx)(ee.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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:la,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(es.Z,{enableSelect:!0,value:e2,onValueChange:e=>{e4(e),lr(eF,e.from,e.to)}})]}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2",defaultValue:eF||eO[0],value:eF||eO[0],children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>lr(e,e2.from,e2.to),children:e},l))})]})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(et.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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"}),eD&&eB&&(0,a.jsx)(ec.Z,{title:"Model Latency",className:"h-72",data:eD,showLegend:!1,index:"date",categories:eB,connectNulls:!0,customTooltip:li})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(eb,{modelMetrics:ez,modelMetricsCategories:eG,customTooltip:li,premiumUser:Z})})]})]})})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Deployment"}),(0,a.jsx)(B.Z,{children:"Success Responses"}),(0,a.jsxs)(B.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(U.Z,{children:e0.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.api_base}),(0,a.jsx)(D.Z,{children:e.total_count}),(0,a.jsx)(D.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(F.Z,{className:"mt-4",children:[(0,a.jsx)(y.Z,{children:"Exceptions per Model"}),(0,a.jsx)(em.Z,{className:"h-72",data:eH,index:"model",categories:eJ,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],value:eF||eO[0],onValueChange:e=>eM(e),children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eF]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e5?void 0:null===(s=e5[eF])||void 0===s?void 0:s[n];return null==r&&(r=e3),(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=>{e8(l=>{var s;let t=null!==(s=null==l?void 0:l[eF])&&void 0!==s?s:{};return{...null!=l?l:{},[eF]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:ls,children:"Save"})]})]})]})})};let{Option:eE}=v.default;var eP=e=>{let{userID:l,accessToken:s,teams:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[m,h]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{o(!1),n.resetFields()},g=()=>{o(!1),c(null),n.resetFields()},Z=async e=>{try{k.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let t=await (0,u.Ov)(s,null,e);console.log("user create Response:",t),c(t.key),k.ZP.success("API user Created"),n.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:()=>o(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:i,width:800,footer:null,onOk:x,onCancel:g,children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(_.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(S.Z,{form:n,onFinish:Z,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:"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)(eE,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eE,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create User"})})]})]}),d&&(0,a.jsxs)(w.Z,{title:"User Created Successfully",visible:i,onOk:x,onCancel:g,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},eT=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[y,b]=(0,r.useState)(null);return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(eP,{userID:i,accessToken:l,teams:o}),(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(_.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(en.Z,{children:(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"User ID"}),(0,a.jsx)(B.Z,{children:"User Email"}),(0,a.jsx)(B.Z,{children:"User Models"}),(0,a.jsx)(B.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(B.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(B.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(U.Z,{children:c.map(e=>{var l;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_id}),(0,a.jsx)(D.Z,{children:e.user_email}),(0,a.jsx)(D.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(D.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(R.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(er.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"})]})})]})})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+1," 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:0===j,onClick:()=>g(j-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",onClick:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eO=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=ee.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[C,E]=(0,r.useState)(l?l[0]:null),[P,G]=(0,r.useState)(!1),[W,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)(!1),[Q,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{E(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),E(null)},er=async e=>{el(e),X(!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)}X(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{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),J(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"),G(!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:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,C.team_id,s);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),E(a.data)}H(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Team Name"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(B.Z,{children:"Info"})]})}),(0,a.jsx)(U.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.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)(D.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)(D.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(M.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),$&&(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:()=>{X(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>G(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:P,width:800,footer:null,onOk:()=>{G(!1),d.resetFields()},onCancel:()=>{G(!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"),Y.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,{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)(I.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.Z,{value:String(l),onClick:()=>{E(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:C?C.members_with_roles.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.role})]},l)):null})]})}),C&&(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"),Y&&Y.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,{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)(I.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),E(null)},team:C,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:W,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eR=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[i]=S.Z.useForm(),[o]=S.Z.useForm(),{Title:d,Paragraph:c}=ee.default,[m,j]=(0,r.useState)(""),[g,Z]=(0,r.useState)(null),[f,y]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[A,C]=(0,r.useState)(!1),[E,P]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let G=()=>{R(!1)},W=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),Z(e)}})()},[t]);let H=()=>{C(!1),o.resetFields()},Y=()=>{C(!1),o.resetFields()},J=e=>(0,a.jsxs)(S.Z,{form:i,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]}),$=(e,l,s)=>(0,a.jsxs)(S.Z,{form:i,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)(z.Z,{value:l,children:W.map((e,l)=>(0,a.jsx)(V.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)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update role"})})]}),X=async e=>{try{if(null!=t&&null!=g){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=g.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"),g.push(l),Z(g)),k.ZP.success("Refresh tab to see updated user role"),C(!1)}}catch(e){console.error("Error creating the key:",e)}},Q=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),y(!1)}}catch(e){console.error("Error creating the key:",e)}},el=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await (0,u.pf)(t,e,"proxy_admin");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),v(!1)}}catch(e){console.error("Error creating the key:",e)}},es=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==g?void 0:g.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(d,{level:4,children:"Admin Access "}),(0,a.jsxs)(c,{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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:g?g.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.user_role}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>C(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:A,width:800,footer:null,onOk:H,onCancel:Y,children:$(X,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:()=>v(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:b,width:800,footer:null,onOk:()=>{v(!1),o.resetFields()},onCancel:()=>{v(!1),o.resetFields()},children:J(el)}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>y(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:f,width:800,footer:null,onOk:()=>{y(!1),o.resetFields()},onCancel:()=>{y(!1),o.resetFields()},children:J(Q)})]})})]}),(0,a.jsxs)(x.Z,{children:[(0,a.jsx)(d,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(p.Z,{onClick:()=>P(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:E,width:800,footer:null,onOk:()=>{P(!1),i.resetFields()},onCancel:()=>{P(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{el(e),es(e),P(!1),R(!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)(N.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)(N.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)(N.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)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:O,width:800,footer:null,onOk:G,onCancel:()=>{R(!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)(I.ZP,{onClick:G,children:"Done"})})]})]}),(0,a.jsxs)(e_.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})," "]})]})]})]})},eF=s(42556),eM=s(90252),eL=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:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(D.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",children:(0,a.jsx)(D.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"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eM.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eU=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eL,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}: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);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})};let eD=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var eK=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)(eD),[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,A]=(0,r.useState)(""),[C,E]=(0,r.useState)({}),[P,T]=(0,r.useState)([]),O=e=>{P.includes(e)?T(P.filter(l=>l!==e)):T([...P,e])},M={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);let l=eD;o(l=l.map(l=>{let s=e.callbacks.find(e=>e.name===l.name);return s?{...l,variables:{...l.variables,...s.variables}}:l}));let s=e.alerts;if(console.log("alerts_data",s),s&&s.length>0){let e=s[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),T(e.active_alerts),A(l),E(e.alerts_to_webhook)}c(s)})},[l,s,t]);let z=e=>P&&P.includes(e),V=e=>{if(!l)return;let s=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[s,t]=e;return[s,(null===(l=document.querySelector('input[name="'.concat(s,'"]')))||void 0===l?void 0:l.value)||t]}));console.log("updatedVariables",s),console.log("updateAlertTypes",y);let t={environment_variables:s,litellm_settings:{success_callback:[e.name]}};try{(0,u.K_)(l,t)}catch(e){k.ZP.error("Failed to update callback: "+e,20)}k.ZP.success("Callback updated successfully")},G=()=>{l&&g.validateFields().then(e=>{let s;if(console.log("Form values:",e),"langfuse"===e.callback){s={environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),s={general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}},(0,u.K_)(l,s),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),s={environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};o(i?[...i,t]:[t])}else s={error:"Invalid callback value"};h(!1),g.resetFields(),f(null)})};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(e_.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(et.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(et.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Callback"}),(0,a.jsx)(B.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(U.Z,{children:i.filter(e=>"slack"!==e.name).map((e,s)=>{var t;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:(0,a.jsx)(R.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(t=e.variables)&&void 0!==t?t:{}).filter(l=>{let[s,t]=l;return s.toLowerCase().includes(e.name)}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password"})]},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>V(e),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"mx-2",children:"Test Callback"})]})]},s)})})]})})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(M).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eF.Z,{id:"switch",name:"switch",checked:z(s),onChange:()=>O(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)(eF.Z,{id:"switch",name:"switch",checked:z(s),onChange:()=>O(s)})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(M).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:P}};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)(er.Z,{children:(0,a.jsx)(eU,{accessToken:l,premiumUser:n})})]})]})]}),(0,a.jsx)(w.Z,{title:"Add Callback",visible:m,onOk:G,width:800,onCancel:()=>{h(!1),g.resetFields(),f(null)},footer:null,children:(0,a.jsxs)(S.Z,{form:g,layout:"vertical",onFinish:G,children:[(0,a.jsx)(S.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(v.default,{onChange:e=>{f(e)},children:[(0,a.jsx)(v.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(v.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===Z&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(j.Z,{type:"password"})}),(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(j.Z,{type:"password"})})]}),"openmeter"==Z&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(j.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eB}=v.default;var eq=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)(z.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(V.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)(eo.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ed.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},ez=s(12968);async function eV(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new ez.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 eG={ttl:3600,lowest_latency_buffer:0},eW=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)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.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 eH=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,E]=(0,r.useState)(null),P={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(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)}}},G=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},W=(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){}},H=(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){}},Y=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)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(et.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(et.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.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)(F.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.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)(q.Z,{children:[(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,a.jsx)(D.Z,{children:"routing_strategy"==l?(0,a.jsxs)(z.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(V.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(V.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(V.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)(eW,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eG,paramExplanation:P})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Model Name"}),(0,a.jsx)(B.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(U.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:t}),(0,a.jsx)(D.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eV(t,l),children:"Test Fallback"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(eq,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"}),(0,a.jsx)(B.Z,{children:"Status"}),(0,a.jsx)(B.Z,{children:"Action"})]})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>G(e.field_name,l)}):null}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eM.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>W(e.field_name,l),children:"Update"}),(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},eY=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:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},eJ=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.ZP.success("Budget Deleted.")};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)(eY,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Budget ID"}),(0,a.jsx)(B.Z,{children:"Max Budget"}),(0,a.jsx)(B.Z,{children:"TPM"}),(0,a.jsx)(B.Z,{children:"RPM"})]})}),(0,a.jsx)(U.Z,{children:n.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.budget_id}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(D.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(D.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>o(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(et.Z,{children:"Test it (Curl)"}),(0,a.jsx)(et.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{}=e;return(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(et.Z,{children:"LlamaIndex"}),(0,a.jsx)(et.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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="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)(er.Z,{children:(0,a.jsx)(eS.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="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,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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 = "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 eQ(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new ez.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 e0=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}));console.log(l),b(l),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 eQ(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}=ee.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)(F.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(et.Z,{children:"Chat"})}),(0,a.jsx)(ei.Z,{children:(0,a.jsxs)(er.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)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.Z,{})})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.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),placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e1=s(33509),e2=s(95781);let{Sider:e4}=e1.default;var e5=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e1.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e4,{width:120,children:(0,a.jsxs)(e2.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e2.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(e1.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e4,{width:145,children:(0,a.jsxs)(e2.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e2.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Rate Limits"})},"9"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e2.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e2.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e2.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},e8=s(67989),e3=s(49167),e6=s(52703),e7=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)([]),[A,I]=(0,r.useState)([]),[C,E]=(0,r.useState)([]),[P,T]=(0,r.useState)([]),[O,R]=(0,r.useState)({}),[M,G]=(0,r.useState)([]),[W,H]=(0,r.useState)(""),[Y,$]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),X=new Date(d.getFullYear(),d.getMonth(),1),Q=new Date(d.getFullYear(),d.getMonth()+1,0),ee=eu(X),el=eu(Q);console.log("keys in usage",i),console.log("premium user in usage",o);let eo=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)},ed=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function eu(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)}return console.log("Start date is ".concat(ee)),console.log("End date is ".concat(el)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ee,el);console.log("provider_spend",n),T(n);let r=(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(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),I(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),E(d);let c=await (0,u.J$)(l,null===(e=Y.from)||void 0===e?void 0:e.toISOString(),null===(a=Y.to)||void 0===a?void 0:a.toISOString());N(c.spend_per_tag);let h=await (0,u.b1)(l,null,void 0,void 0);v(h),console.log("spend/user result",h);let x=await (0,u.wd)(l,ee,el);R(x);let p=await (0,u.xA)(l,ee,el);console.log("global activity per model",p),G(p)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ee,el).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ee,el]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(J,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{className:"mt-2",children:[(0,a.jsx)(et.Z,{children:"All Up"}),(0,a.jsx)(et.Z,{children:"Team Based Usage"}),(0,a.jsx)(et.Z,{children:"End User Usage"}),(0,a.jsx)(et.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(et.Z,{children:"Cost"}),(0,a.jsx)(et.Z,{children:"Activity"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(em.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)(F.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)(e6.Z,{className:"mt-4 h-40",variant:"pie",data:P,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Provider"}),(0,a.jsx)(B.Z,{children:"Spend"})]})}),(0,a.jsx)(U.Z,{children:P.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.provider}),(0,a.jsx)(D.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)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(F.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)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",O.sum_api_requests]}),(0,a.jsx)(ec.Z,{className:"h-40",data:O.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",O.sum_total_tokens]}),(0,a.jsx)(em.Z,{className:"h-40",data:O.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:M.map((e,l)=>(0,a.jsxs)(F.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)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:M&&M.length>0&&M.slice(0,1).map((e,l)=>(0,a.jsxs)(F.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)(F.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)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e3.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(er.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)(F.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(e8.Z,{data:C})]}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(em.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:A,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users 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)(es.Z,{enableSelect:!0,value:Y,onValueChange:e=>{$(e),eo(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(z.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(V.Z,{value:"all-keys",onClick:()=>{eo(Y.from,Y.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)(V.Z,{value:String(l),onClick:()=>{eo(Y.from,Y.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(F.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"End User"}),(0,a.jsx)(B.Z,{children:"Spend"}),(0,a.jsx)(B.Z,{children:"Total Events"})]})}),(0,a.jsx)(U.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.end_user}),(0,a.jsx)(D.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(D.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsx)(es.Z,{className:"mb-4",enableSelect:!0,value:Y,onValueChange:e=>{$(e),ed(e.from,e.to)}}),(0,a.jsxs)(F.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/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(em.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})})]})]})]})},e9=()=>{let{Title:e,Paragraph:l}=ee.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(!0),Z=(0,i.useSearchParams)(),[f,_]=(0,r.useState)({data:[]}),y=Z.get("userID"),b=Z.get("token"),[v,S]=(0,r.useState)("api-keys"),[k,w]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(b){let e=(0,Q.o)(b);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(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"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&S("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?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[b]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:y,userRole:s,userEmail:d,showSSOBanner:j,premiumUser:n}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e5,{setPage:S,userRole:s,defaultSelectedKey:null})}),"api-keys"==v?(0,a.jsx)(el,{userID:y,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p}):"models"==v?(0,a.jsx)(eC,{userID:y,userRole:s,token:b,accessToken:k,modelData:f,setModelData:_,premiumUser:n}):"llm-playground"==v?(0,a.jsx)(e0,{userID:y,userRole:s,token:b,accessToken:k}):"users"==v?(0,a.jsx)(eT,{userID:y,userRole:s,token:b,keys:x,teams:u,accessToken:k,setKeys:p}):"teams"==v?(0,a.jsx)(eO,{teams:u,setTeams:h,searchParams:Z,accessToken:k,userID:y,userRole:s}):"admin-panel"==v?(0,a.jsx)(eR,{setTeams:h,searchParams:Z,accessToken:k,showSSOBanner:j}):"api_ref"==v?(0,a.jsx)(eX,{}):"settings"==v?(0,a.jsx)(eK,{userID:y,userRole:s,accessToken:k,premiumUser:n}):"budgets"==v?(0,a.jsx)(eJ,{accessToken:k}):"general-settings"==v?(0,a.jsx)(eH,{userID:y,userRole:s,accessToken:k,modelData:f}):"model-hub"==v?(0,a.jsx)(e$.Z,{accessToken:k,publicPage:!1,premiumUser:n}):(0,a.jsx)(e7,{userID:y,userRole:s,token:b,accessToken:k,keys:x,premiumUser:n})]})]})})}}},function(e){e.O(0,[936,359,440,134,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-1fb033a77b428a50.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-1fb033a77b428a50.js
new file mode 100644
index 000000000..82b275b53
--- /dev/null
+++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-1fb033a77b428a50.js
@@ -0,0 +1 @@
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,s){Promise.resolve().then(s.bind(s,5347))},5347:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return le}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let i=[{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(r)]})]})},{key:"2",label:(0,a.jsx)(o.default,{href:"/",children:(0,a.jsx)("p",{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?(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 enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:i},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(81583),k=s(80588),w=s(99129),N=s(44839),A=s(88707),I=s(1861);let{Option:E}=v.default;var C=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),[C,P]=(0,r.useState)(null),[T,O]=(0,r.useState)(null),[R,F]=(0,r.useState)([]),[M,L]=(0,r.useState)([]),U=()=>{m(!1),d.resetFields()},D=()=>{m(!1),P(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),F(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let K=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"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),P(h.key),O(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)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(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:U,onCancel:D,children:(0,a.jsxs)(S.Z,{form:d,onFinish:K,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",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)(N.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)(E,{value:"all-team-models",children:"All Team Models"},"all-team-models"),M.map(e=>(0,a.jsx)(E,{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:"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)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Key"})})]})}),C&&(0,a.jsx)(w.Z,{visible:c,onOk:U,onCancel:D,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!=C?(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:C})}),(0,a.jsx)(b.CopyToClipboard,{text:C,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"})})]})})]})},P=s(9454),T=s(98941),O=s(33393),R=s(5),F=s(13810),M=s(61244),L=s(10827),U=s(3851),D=s(2044),K=s(64167),B=s(74480),q=s(7178),z=s(95093),V=s(27166);let{Option:G}=v.default;var W=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,E]=(0,r.useState)(null),[C,W]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,$]=(0,r.useState)(!1),[X,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(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),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,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"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Key Alias"}),(0,a.jsx)(B.Z,{children:"Secret Key"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(U.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(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.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)(q.Z,{children:[(0,a.jsx)(D.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)(D.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(D.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(R.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.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)(D.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.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{onClick:()=>{Q(e),$(!0)},icon:P.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{$(!1),Q(null)},footer:null,width:800,children:X&&(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)(F.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(X.spend).toFixed(4)}catch(e){return X.spend}})()})})]}),(0,a.jsxs)(F.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!=X.max_budget?(0,a.jsx)(a.Fragment,{children:X.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(F.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!=X.expires?(0,a.jsx)(a.Fragment,{children:new Date(X.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)(F.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:X.key_alias?X.key_alias:X.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:X.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(X.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{$(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(M.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),X&&(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);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:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.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)(G,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(G,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(G,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(G,{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,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(z.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(V.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:X,onSubmit:er})]})},H=s(76032),Y=s(35152),J=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(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),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("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:["$",j]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)(_.Z,{children:"Team Models"})}),(0,a.jsx)(Z.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(H.Z,{children:p.map(e=>(0,a.jsx)(Y.Z,{children:(0,a.jsx)(_.Z,{children:e})},e))})})]})})]})},$=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.jsx)("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})})})},X=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.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."})]})]})},Q=s(37963),ee=s(97482);console.log("isLocal:",!1);var el=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p}=e,[j,g]=(0,r.useState)(null),Z=(0,i.useSearchParams)();Z.get("viewSpend"),(0,i.useRouter)();let f=Z.get("token"),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)([]),w={models:[],team_alias:"Default Team",team_id:null},[N,A]=(0,r.useState)(t?t[0]:w);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(f){let e=(0,Q.o)(f);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(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";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&&_&&s&&!n&&!j){let e=sessionStorage.getItem("userModels"+l);e?k(JSON.parse(e)):(async()=>{try{let e=await (0,u.Br)(_,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await (0,u.Qy)(_);g(e),console.log("globalSpend:",e)}else g(e.user_info);p(e.keys),m(e.teams);let t=[...e.teams];t.length>0?(console.log("response['teams']: ".concat(t)),A(t[0])):A(w),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let n=(await (0,u.So)(_,l,s)).data.map(e=>e.id);console.log("available_model_names:",n),k(n),console.log("userModels:",S),sessionStorage.setItem("userModels"+l,JSON.stringify(n))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,f,_,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=N&&null!==N.team_id){let e=0;for(let l of n)N.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===N.team_id&&(e+=l.spend);v(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;v(e)}},[N]),null==l||null==f){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==_)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=ee.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",N),(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)($,{userID:l,userRole:s,selectedTeam:N||null,accessToken:_}),(0,a.jsx)(J,{userID:l,userRole:s,accessToken:_,userSpend:b,selectedTeam:N||null}),(0,a.jsx)(W,{userID:l,userRole:s,accessToken:_,selectedTeam:N||null,data:n,setData:p,teams:t}),(0,a.jsx)(C,{userID:l,team:N||null,userRole:s,accessToken:_,data:n,setData:p},N?N.team_id:null),(0,a.jsx)(X,{teams:t,setSelectedTeam:A,userRole:s})]})})})},es=s(35087),et=s(92836),en=s(26734),ea=s(41608),er=s(32126),ei=s(23682),eo=s(47047),ed=s(76628),ec=s(25707),em=s(44041),eu=s(1460),eh=s(28683),ex=s(38302),ep=s(78578),ej=s(63954),eg=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)(M.Z,{onClick:()=>n(!0),icon:O.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})]})})]})})]})},eZ=s(97766),ef=s(46495),e_=s(18190),ey=s(91118),eb=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(ey.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)(e_.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"})})]})},ev=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))})},eS=s(67951);let{Title:ek,Link:ew}=ee.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks";let eN={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eI=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)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=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 eE=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},setModelData:g,premiumUser:Z}=e,[f,b]=(0,r.useState)([]),[v]=S.Z.useForm(),[N,E]=(0,r.useState)(null),[C,O]=(0,r.useState)(""),[G,W]=(0,r.useState)([]),H=Object.values(n).filter(e=>isNaN(Number(e))),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)("OpenAI"),[Q,el]=(0,r.useState)(""),[e_,ey]=(0,r.useState)(!1),[eE,eC]=(0,r.useState)(!1),[eP,eT]=(0,r.useState)(null),[eO,eR]=(0,r.useState)([]),[eF,eM]=(0,r.useState)(null),[eL,eU]=(0,r.useState)([]),[eD,eK]=(0,r.useState)([]),[eB,eq]=(0,r.useState)([]),[ez,eV]=(0,r.useState)([]),[eG,eW]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,e$]=(0,r.useState)([]),[eX,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e5,e8]=(0,r.useState)(null),[e3,e6]=(0,r.useState)(0),e7=e=>{eT(e),ey(!0)},e9=e=>{eT(e),eC(!0)},le=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),ey(!1),eT(null)}catch(e){console.log("Error occurred")}},ll=()=>{O(new Date().toLocaleString())},ls=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e5);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e5}}),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(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i;let d=await (0,u.hy)(o);J(d);let h=await (0,u.AZ)(o,m,c);console.log("Model data response:",h.data),g(h);let x=new Set;for(let e=0;e0&&(j=p[p.length-1],console.log("_initial_model_group:",j),eM(j)),console.log("selectedModelGroup:",eF);let Z=await (0,u.o6)(o,m,c,j,null===(e=e2.from)||void 0===e?void 0:e.toISOString(),null===(l=e2.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",Z),eK(Z.data),eq(Z.all_api_bases);let f=await (0,u.Rg)(o,j,null===(s=e2.from)||void 0===s?void 0:s.toISOString(),null===(t=e2.to)||void 0===t?void 0:t.toISOString());eV(f.data),eW(f.all_api_bases);let _=await (0,u.N8)(o,m,c,j,null===(n=e2.from)||void 0===n?void 0:n.toISOString(),null===(a=e2.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",_),eY(_.data),e$(_.exception_types);let y=await (0,u.fP)(o,m,c,j,null===(r=e2.from)||void 0===r?void 0:r.toISOString(),null===(i=e2.to)||void 0===i?void 0:i.toISOString());console.log("slowResponses:",y),e1(y);let b=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",b);let v=b.model_group_retry_policy,S=b.num_retries;console.log("model_group_retry_policy:",v),console.log("default_retries:",S),e8(v),e6(S)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),E(e)};null==N&&l(),ll()},[o,d,c,m,N,C]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lt=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(N)),null!=N&&"object"==typeof N&&e in N)?N[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lt.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=ee.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 ln=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eN[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof N&&Object.entries(N).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)}),W(s),console.log("providerModels: ".concat(G))}},la=async()=>{try{k.ZP.info("Running health check..."),el("");let e=await (0,u.EY)(o);el(e)}catch(e){console.error("Error running health check:",e),el("Error running health check")}},lr=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),o&&m&&c&&l&&s){console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),eM(e);try{let t=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model metrics response:",t),eK(t.data),eq(t.all_api_bases);let n=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eV(n.data),eW(n.all_api_bases);let a=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString());console.log("Model exceptions response:",a),eY(a.data),e$(a.exception_types);let r=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString());console.log("slowResponses:",r),e1(r)}catch(e){console.error("Failed to fetch model metrics",e)}}},li=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)})]})};console.log("selectedProvider: ".concat($)),console.log("providerModels.length: ".concat(G.length));let lo=Object.keys(n).find(e=>n[e]===$);return lo&&(i=Y.find(e=>e.name===eN[lo])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(et.Z,{children:"All Models"}),(0,a.jsx)(et.Z,{children:"Add Model"}),(0,a.jsx)(et.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(et.Z,{children:"Model Analytics"}),(0,a.jsx)(et.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[C&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",C]}),(0,a.jsx)(M.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:ll})]})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],onValueChange:e=>eM("all"===e?"all":e),value:eF||eO[0],children:[(0,a.jsx)(V.Z,{value:"all",children:"All Models"}),eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))]})]}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(B.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(B.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)(B.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)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:Z?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(B.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(B.Z,{})]})}),(0,a.jsx)(U.Z,{children:h.data.filter(e=>"all"===eF||e.model_name===eF||null==eF||""===eF).map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.model_name||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"10px"},title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(D.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{style:{fontSize:"10px"},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)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:Z&&e.model_info.created_by||"-"})}),(0,a.jsx)(D.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsx)(D.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:P.Z,size:"sm",onClick:()=>e9(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>e7(e)})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eg,{modelID:e.model_info.id,accessToken:o})})]})})]},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:le,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:"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_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(A.Z,{min:0,step:1e-4})}),(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)(I.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:e_,onCancel:()=>{ey(!1),eT(null)},model:eP,onSubmit:le}),(0,a.jsxs)(w.Z,{title:eP&&eP.model_name,visible:eE,width:800,footer:null,onCancel:()=>{eC(!1),eT(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(eS.Z,{language:"json",children:eP&&JSON.stringify(eP,null,2)})]})]}),(0,a.jsxs)(er.Z,{className:"h-full",children:[(0,a.jsx)(ek,{level:2,children:"Add new model"}),(0,a.jsx)(F.Z,{children:(0,a.jsxs)(S.Z,{form:v,onFinish:()=>{v.validateFields().then(e=>{eI(e,o,v)}).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)(z.Z,{value:$.toString(),children:H.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>{ln(e),X(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,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=$.toString())?"gemini-pro":"Anthropic"==t?"claude-3-opus":"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===$?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(eo.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(ed.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(ew,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(ew,{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!==i&&i.fields.length>0&&(0,a.jsx)(ev,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=$&&"Vertex AI (Anthropic, Gemini, etc.)"!=$&&(void 0===i||0==i.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"==$&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(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.)"==$&&(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.)"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ef.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;v.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)(I.ZP,{icon:(0,a.jsx)(eZ.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==$&&(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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"==$||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==$)&&(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"==$&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==$&&(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)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.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)(ew,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==$&&(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"==$&&(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"==$&&(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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(ex.Z,{children:[(0,a.jsx)(eh.Z,{span:10}),(0,a.jsx)(eh.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(ew,{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)(I.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(eu.Z,{title:"Get help on our github",children:(0,a.jsx)(ee.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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:la,children:"Run `/health`"}),Q&&(0,a.jsx)("pre",{children:JSON.stringify(Q,null,2)})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(es.Z,{enableSelect:!0,value:e2,onValueChange:e=>{e4(e),lr(eF,e.from,e.to)}})]}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2",defaultValue:eF||eO[0],value:eF||eO[0],children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>lr(e,e2.from,e2.to),children:e},l))})]})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(et.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsxs)(er.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"}),eD&&eB&&(0,a.jsx)(ec.Z,{title:"Model Latency",className:"h-72",data:eD,showLegend:!1,index:"date",categories:eB,connectNulls:!0,customTooltip:li})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(eb,{modelMetrics:ez,modelMetricsCategories:eG,customTooltip:li,premiumUser:Z})})]})]})})}),(0,a.jsx)(eh.Z,{children:(0,a.jsx)(F.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Deployment"}),(0,a.jsx)(B.Z,{children:"Success Responses"}),(0,a.jsxs)(B.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(U.Z,{children:e0.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.api_base}),(0,a.jsx)(D.Z,{children:e.total_count}),(0,a.jsx)(D.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(F.Z,{className:"mt-4",children:[(0,a.jsx)(y.Z,{children:"Exceptions per Model"}),(0,a.jsx)(em.Z,{className:"h-72",data:eH,index:"model",categories:eJ,stack:!0,yAxisWidth:30})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(z.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eF||eO[0],value:eF||eO[0],onValueChange:e=>eM(e),children:eO.map((e,l)=>(0,a.jsx)(V.Z,{value:e,onClick:()=>eM(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eF]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e5?void 0:null===(s=e5[eF])||void 0===s?void 0:s[n];return null==r&&(r=e3),(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=>{e8(l=>{var s;let t=null!==(s=null==l?void 0:l[eF])&&void 0!==s?s:{};return{...null!=l?l:{},[eF]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:ls,children:"Save"})]})]})]})})};let{Option:eC}=v.default;var eP=e=>{let{userID:l,accessToken:s,teams:t}=e,[n]=S.Z.useForm(),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[m,h]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{o(!1),n.resetFields()},g=()=>{o(!1),c(null),n.resetFields()},Z=async e=>{try{k.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let t=await (0,u.Ov)(s,null,e);console.log("user create Response:",t),c(t.key),k.ZP.success("API user Created"),n.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:()=>o(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:i,width:800,footer:null,onOk:x,onCancel:g,children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(_.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(S.Z,{form:n,onFinish:Z,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:"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)(eC,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eC,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create User"})})]})]}),d&&(0,a.jsxs)(w.Z,{title:"User Created Successfully",visible:i,onOk:x,onCancel:g,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},eT=e=>{let{visible:l,onCancel:s,user:t,onSubmit:n}=e,[i,o]=(0,r.useState)(t),[d]=S.Z.useForm();(0,r.useEffect)(()=>{d.resetFields()},[t]);let c=async()=>{d.resetFields(),s()},m=async e=>{d.resetFields(),n(e),s()};return t?(0,a.jsx)(w.Z,{visible:l,onCancel:c,footer:null,title:"Edit User "+t.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:d,onFinish:m,initialValues:t,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.jsxs)(v.default,{children:[(0,a.jsx)(v.default.Option,{value:"proxy_admin",children:"Proxy Admin (Can create, edit, delete keys, teams)"}),(0,a.jsx)(v.default.Option,{value:"proxy_admin_viewer",children:"Proxy Viewer (Can just view spend, cannot created keys, teams)"})]})}),(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)(I.ZP,{htmlType:"submit",children:"Save"})})]})})}):null},eO=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[y,b]=(0,r.useState)(null),[v,S]=(0,r.useState)(!1),[k,w]=(0,r.useState)(null),N=async()=>{w(null),S(!1)},A=async e=>{console.log("inside handleEditSubmit:",e),l&&s&&n&&i&&((0,u.pf)(l,e,n),c&&m(c.map(l=>l.user_id===e.user_id?e:l)),w(null),S(!1))};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(eP,{userID:i,accessToken:l,teams:o}),(0,a.jsxs)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(_.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(en.Z,{children:(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"User ID"}),(0,a.jsx)(B.Z,{children:"User Email"}),(0,a.jsx)(B.Z,{children:"User Models"}),(0,a.jsx)(B.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(B.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(B.Z,{children:"API Keys"}),(0,a.jsx)(B.Z,{})]})}),(0,a.jsx)(U.Z,{children:c.map(e=>{var l;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_id}),(0,a.jsx)(D.Z,{children:e.user_email}),(0,a.jsx)(D.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(D.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsxs)(R.Z,{size:"xs",color:"indigo",children:[e.key_aliases.filter(e=>null!==e).length,"\xa0Keys"]}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:P.Z,onClick:()=>{f(e.user_id),b(e)},children:"View Keys"}),(0,a.jsx)(M.Z,{icon:T.Z,onClick:()=>{w(e),S(!0)},children:"View Keys"}),(0,a.jsx)(M.Z,{icon:O.Z,onClick:()=>{f(e.user_id),b(e)},children:"View Keys"})]})]},e.user_id)})})]})}),(0,a.jsx)(er.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)(eT,{visible:v,onCancel:N,user:k,onSubmit:A})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+1," 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:0===j,onClick:()=>g(j-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",onClick:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eR=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=ee.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[E,C]=(0,r.useState)(l?l[0]:null),[P,G]=(0,r.useState)(!1),[W,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[$,X]=(0,r.useState)(!1),[Q,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{C(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),C(null)},er=async e=>{el(e),X(!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)}X(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{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),J(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"),G(!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:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,E.team_id,s);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),C(a.data)}H(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Team Name"}),(0,a.jsx)(B.Z,{children:"Spend (USD)"}),(0,a.jsx)(B.Z,{children:"Budget (USD)"}),(0,a.jsx)(B.Z,{children:"Models"}),(0,a.jsx)(B.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(B.Z,{children:"Info"})]})}),(0,a.jsx)(U.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(D.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(D.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)(R.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.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)(D.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)(D.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(M.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),$&&(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:()=>{X(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>G(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:P,width:800,footer:null,onOk:()=>{G(!1),d.resetFields()},onCancel:()=>{G(!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"),Y.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,{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)(I.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(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)(z.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(V.Z,{value:String(l),onClick:()=>{C(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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:E?E.members_with_roles.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.role})]},l)):null})]})}),E&&(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"),Y&&Y.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,{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)(I.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),C(null)},team:E,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:W,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eF=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[i]=S.Z.useForm(),[o]=S.Z.useForm(),{Title:d,Paragraph:c}=ee.default,[m,j]=(0,r.useState)(""),[g,Z]=(0,r.useState)(null),[f,y]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[A,E]=(0,r.useState)(!1),[C,P]=(0,r.useState)(!1),[O,R]=(0,r.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let G=()=>{R(!1)},W=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),Z(e)}})()},[t]);let H=()=>{E(!1),o.resetFields()},Y=()=>{E(!1),o.resetFields()},J=e=>(0,a.jsxs)(S.Z,{form:i,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",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)(N.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)(N.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add member"})})]}),$=(e,l,s)=>(0,a.jsxs)(S.Z,{form:i,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)(z.Z,{value:l,children:W.map((e,l)=>(0,a.jsx)(V.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)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update role"})})]}),X=async e=>{try{if(null!=t&&null!=g){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=g.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"),g.push(l),Z(g)),k.ZP.success("Refresh tab to see updated user role"),E(!1)}}catch(e){console.error("Error creating the key:",e)}},Q=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),y(!1)}}catch(e){console.error("Error creating the key:",e)}},el=async e=>{try{if(null!=t&&null!=g){k.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await (0,u.pf)(t,e,"proxy_admin");console.log("response for team create call: ".concat(l));let s=g.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"),g.push(l),Z(g)),v(!1)}}catch(e){console.error("Error creating the key:",e)}},es=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==g?void 0:g.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(d,{level:4,children:"Admin Access "}),(0,a.jsxs)(c,{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)(F.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Member Name"}),(0,a.jsx)(B.Z,{children:"Role"})]})}),(0,a.jsx)(U.Z,{children:g?g.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(D.Z,{children:e.user_role}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(M.Z,{icon:T.Z,size:"sm",onClick:()=>E(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:A,width:800,footer:null,onOk:H,onCancel:Y,children:$(X,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:()=>v(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:b,width:800,footer:null,onOk:()=>{v(!1),o.resetFields()},onCancel:()=>{v(!1),o.resetFields()},children:J(el)}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>y(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:f,width:800,footer:null,onOk:()=>{y(!1),o.resetFields()},onCancel:()=>{y(!1),o.resetFields()},children:J(Q)})]})})]}),(0,a.jsxs)(x.Z,{children:[(0,a.jsx)(d,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(p.Z,{onClick:()=>P(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:C,width:800,footer:null,onOk:()=>{P(!1),i.resetFields()},onCancel:()=>{P(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{el(e),es(e),P(!1),R(!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)(N.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)(N.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)(N.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)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:O,width:800,footer:null,onOk:G,onCancel:()=>{R(!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)(I.ZP,{onClick:G,children:"Done"})})]})]}),(0,a.jsxs)(e_.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})," "]})]})]})]})},eM=s(42556),eL=s(90252),eU=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:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"===e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(D.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",children:(0,a.jsx)(D.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"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eL.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eD=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eU,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}: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);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})};let eK=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var eB=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)(eK),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[b,N]=(0,r.useState)([]),[A,E]=(0,r.useState)(""),[C,P]=(0,r.useState)({}),[T,O]=(0,r.useState)([]),M=e=>{T.includes(e)?O(T.filter(l=>l!==e)):O([...T,e])},z={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);let l=eK;o(l=l.map(l=>{let s=e.callbacks.find(e=>e.name===l.name);return s?{...l,variables:{...l.variables,...s.variables}}:l}));let s=e.alerts;if(console.log("alerts_data",s),s&&s.length>0){let e=s[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),O(e.active_alerts),E(l),P(e.alerts_to_webhook)}c(s)})},[l,s,t]);let V=e=>T&&T.includes(e),G=()=>{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")},W=e=>{if(!l)return;let s=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[s,t]=e;return[s,(null===(l=document.querySelector('input[name="'.concat(s,'"]')))||void 0===l?void 0:l.value)||t]}));console.log("updatedVariables",s),console.log("updateAlertTypes",b);let t={environment_variables:s,litellm_settings:{success_callback:[e.name]}};try{(0,u.K_)(l,t)}catch(e){k.ZP.error("Failed to update callback: "+e,20)}k.ZP.success("Callback updated successfully")},H=()=>{l&&g.validateFields().then(e=>{let s;if(console.log("Form values:",e),"langfuse"===e.callback){s={environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),s={general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}},(0,u.K_)(l,s),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};o(i?[...i,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),s={environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}},(0,u.K_)(l,s);let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};o(i?[...i,t]:[t])}else s={error:"Invalid callback value"};h(!1),g.resetFields(),f(null)})};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(e_.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(et.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(et.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(et.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Callback"}),(0,a.jsx)(B.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(U.Z,{children:i.filter(e=>"slack"!==e.name).map((e,s)=>{var t;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:(0,a.jsx)(R.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(t=e.variables)&&void 0!==t?t:{}).filter(l=>{let[s,t]=l;return s.toLowerCase().includes(e.name)}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password"})]},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>W(e),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"mx-2",children:"Test Callback"})]})]},s)})})]})})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.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)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{}),(0,a.jsx)(B.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(z).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eM.Z,{id:"switch",name:"switch",checked:V(s),onChange:()=>M(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)(eM.Z,{id:"switch",name:"switch",checked:V(s),onChange:()=>M(s)})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:A})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(z).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:T}};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)(er.Z,{children:(0,a.jsx)(eD,{accessToken:l,premiumUser:n})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{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)(D.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:()=>G(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})]}),(0,a.jsx)(w.Z,{title:"Add Callback",visible:m,onOk:H,width:800,onCancel:()=>{h(!1),g.resetFields(),f(null)},footer:null,children:(0,a.jsxs)(S.Z,{form:g,layout:"vertical",onFinish:H,children:[(0,a.jsx)(S.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(v.default,{onChange:e=>{f(e)},children:[(0,a.jsx)(v.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(v.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===Z&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(j.Z,{type:"password"})}),(0,a.jsx)(S.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(j.Z,{type:"password"})})]}),"openmeter"==Z&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(j.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eq}=v.default;var ez=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)(z.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(V.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)(eo.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(ed.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eV=s(12968);async function eG(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new eV.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 eW={ttl:3600,lowest_latency_buffer:0},eH=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)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.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 eY=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),[E,C]=(0,r.useState)(null),P={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(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)}}},G=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},W=(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){}},H=(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){}},Y=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)(en.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(ea.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(et.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(et.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(et.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.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)(F.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"})]})}),(0,a.jsx)(U.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)(q.Z,{children:[(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:P[l]})]}),(0,a.jsx)(D.Z,{children:"routing_strategy"==l?(0,a.jsxs)(z.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:I,children:[(0,a.jsx)(V.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(V.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(V.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)(eH,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eW,paramExplanation:P})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Model Name"}),(0,a.jsx)(B.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(U.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:t}),(0,a.jsx)(D.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eG(t,l),children:"Test Fallback"})}),(0,a.jsx)(D.Z,{children:(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>T(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(ez,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(er.Z,{children:(0,a.jsx)(F.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Setting"}),(0,a.jsx)(B.Z,{children:"Value"}),(0,a.jsx)(B.Z,{children:"Status"}),(0,a.jsx)(B.Z,{children:"Action"})]})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(D.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)(D.Z,{children:"Integer"==e.field_type?(0,a.jsx)(A.Z,{step:1,value:e.field_value,onChange:l=>G(e.field_name,l)}):null}),(0,a.jsx)(D.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eL.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(D.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>W(e.field_name,l),children:"Update"}),(0,a.jsx)(M.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},eJ=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:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(I.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},e$=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.ZP.success("Budget Deleted.")};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)(eJ,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Budget ID"}),(0,a.jsx)(B.Z,{children:"Max Budget"}),(0,a.jsx)(B.Z,{children:"TPM"}),(0,a.jsx)(B.Z,{children:"RPM"})]})}),(0,a.jsx)(U.Z,{children:n.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.budget_id}),(0,a.jsx)(D.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(D.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(D.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(M.Z,{icon:O.Z,size:"sm",onClick:()=>o(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(et.Z,{children:"Test it (Curl)"}),(0,a.jsx)(et.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.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)(er.Z,{children:(0,a.jsx)(eS.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{}=e;return(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)(en.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(et.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(et.Z,{children:"LlamaIndex"}),(0,a.jsx)(et.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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="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)(er.Z,{children:(0,a.jsx)(eS.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="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,a.jsx)(er.Z,{children:(0,a.jsx)(eS.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 = "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 e0(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new eV.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 e1=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}));console.log(l),b(l),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 e0(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}=ee.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)(F.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(et.Z,{children:"Chat"})}),(0,a.jsx)(ei.Z,{children:(0,a.jsxs)(er.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)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(K.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.Z,{})})}),(0,a.jsx)(U.Z,{children:m.map((e,l)=>(0,a.jsx)(q.Z,{children:(0,a.jsx)(D.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),placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e2=s(33509),e4=s(95781);let{Sider:e5}=e2.default;var e8=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e2.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e5,{width:120,children:(0,a.jsxs)(e4.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e4.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(e2.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e5,{width:145,children:(0,a.jsxs)(e4.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e4.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Internal Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Budgets"})},"9"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e4.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e4.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e4.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},e3=s(67989),e6=s(49167),e7=s(52703),e9=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)([]),[A,I]=(0,r.useState)([]),[E,C]=(0,r.useState)([]),[P,T]=(0,r.useState)([]),[O,R]=(0,r.useState)({}),[M,G]=(0,r.useState)([]),[W,H]=(0,r.useState)(""),[Y,$]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),X=new Date(d.getFullYear(),d.getMonth(),1),Q=new Date(d.getFullYear(),d.getMonth()+1,0),ee=eh(X),el=eh(Q);function eo(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 ed=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)},eu=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function eh(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)}return console.log("Start date is ".concat(ee)),console.log("End date is ".concat(el)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ee,el);console.log("provider_spend",n),T(n);let r=(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(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),I(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),C(d);let c=await (0,u.J$)(l,null===(e=Y.from)||void 0===e?void 0:e.toISOString(),null===(a=Y.to)||void 0===a?void 0:a.toISOString());N(c.spend_per_tag);let h=await (0,u.b1)(l,null,void 0,void 0);v(h),console.log("spend/user result",h);let x=await (0,u.wd)(l,ee,el);R(x);let p=await (0,u.xA)(l,ee,el);console.log("global activity per model",p),G(p)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ee,el).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ee,el]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(J,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{className:"mt-2",children:[(0,a.jsx)(et.Z,{children:"All Up"}),(0,a.jsx)(et.Z,{children:"Team Based Usage"}),(0,a.jsx)(et.Z,{children:"End User Usage"}),(0,a.jsx)(et.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(ea.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(et.Z,{children:"Cost"}),(0,a.jsx)(et.Z,{children:"Activity"})]}),(0,a.jsxs)(ei.Z,{children:[(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(em.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)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(em.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)(F.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)(e7.Z,{className:"mt-4 h-40",variant:"pie",data:P,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"Provider"}),(0,a.jsx)(B.Z,{children:"Spend"})]})}),(0,a.jsx)(U.Z,{children:P.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.provider}),(0,a.jsx)(D.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)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(F.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)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eo(O.sum_api_requests)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:O.daily_data,valueFormatter:eo,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eo(O.sum_total_tokens)]}),(0,a.jsx)(em.Z,{className:"h-40",data:O.daily_data,valueFormatter:eo,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:M.map((e,l)=>(0,a.jsxs)(F.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)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eo(e.sum_api_requests)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eo,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eo(e.sum_total_tokens)]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eo,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:M&&M.length>0&&M.slice(0,1).map((e,l)=>(0,a.jsxs)(F.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)(F.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)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eo(e.sum_api_requests)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eo,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(e6.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eo(e.sum_total_tokens)]}),(0,a.jsx)(em.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eo,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(er.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)(F.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(e3.Z,{data:E})]}),(0,a.jsxs)(F.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(em.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:A,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users 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)(es.Z,{enableSelect:!0,value:Y,onValueChange:e=>{$(e),ed(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(z.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(V.Z,{value:"all-keys",onClick:()=>{ed(Y.from,Y.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)(V.Z,{value:String(l),onClick:()=>{ed(Y.from,Y.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(F.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(K.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(B.Z,{children:"End User"}),(0,a.jsx)(B.Z,{children:"Spend"}),(0,a.jsx)(B.Z,{children:"Total Events"})]})}),(0,a.jsx)(U.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(D.Z,{children:e.end_user}),(0,a.jsx)(D.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(D.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsx)(es.Z,{className:"mb-4",enableSelect:!0,value:Y,onValueChange:e=>{$(e),eu(e.from,e.to)}}),(0,a.jsxs)(F.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/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(em.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})})]})]})]})},le=()=>{let{Title:e,Paragraph:l}=ee.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(!0),Z=(0,i.useSearchParams)(),[f,_]=(0,r.useState)({data:[]}),y=Z.get("userID"),b=Z.get("token"),[v,S]=(0,r.useState)("api-keys"),[k,w]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(b){let e=(0,Q.o)(b);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(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"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&S("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?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[b]),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:y,userRole:s,userEmail:d,showSSOBanner:j,premiumUser:n}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e8,{setPage:S,userRole:s,defaultSelectedKey:null})}),"api-keys"==v?(0,a.jsx)(el,{userID:y,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p}):"models"==v?(0,a.jsx)(eE,{userID:y,userRole:s,token:b,accessToken:k,modelData:f,setModelData:_,premiumUser:n}):"llm-playground"==v?(0,a.jsx)(e1,{userID:y,userRole:s,token:b,accessToken:k}):"users"==v?(0,a.jsx)(eO,{userID:y,userRole:s,token:b,keys:x,teams:u,accessToken:k,setKeys:p}):"teams"==v?(0,a.jsx)(eR,{teams:u,setTeams:h,searchParams:Z,accessToken:k,userID:y,userRole:s}):"admin-panel"==v?(0,a.jsx)(eF,{setTeams:h,searchParams:Z,accessToken:k,showSSOBanner:j}):"api_ref"==v?(0,a.jsx)(eQ,{}):"settings"==v?(0,a.jsx)(eB,{userID:y,userRole:s,accessToken:k,premiumUser:n}):"budgets"==v?(0,a.jsx)(e$,{accessToken:k}):"general-settings"==v?(0,a.jsx)(eY,{userID:y,userRole:s,accessToken:k,modelData:f}):"model-hub"==v?(0,a.jsx)(eX.Z,{accessToken:k,publicPage:!1,premiumUser:n}):(0,a.jsx)(e9,{userID:y,userRole:s,token:b,accessToken:k,keys:x,premiumUser:n})]})]})})}}},function(e){e.O(0,[936,359,440,134,971,69,744],function(){return e(e.s=20661)}),_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 b12c05bc4..28d620ebf 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 99372005b..15941a134 100644
--- a/ui/litellm-dashboard/out/index.txt
+++ b/ui/litellm-dashboard/out/index.txt
@@ -1,7 +1,7 @@
2:I[77831,[],""]
-3:I[62631,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","359","static/chunks/359-f105a7fb61fe8110.js","440","static/chunks/440-b9a05f116e1a696d.js","134","static/chunks/134-af41d2d267857018.js","931","static/chunks/app/page-0f6ae871c63eb14b.js"],""]
+3:I[5347,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","359","static/chunks/359-f105a7fb61fe8110.js","440","static/chunks/440-b9a05f116e1a696d.js","134","static/chunks/134-af41d2d267857018.js","931","static/chunks/app/page-1fb033a77b428a50.js"],""]
4:I[5613,[],""]
5:I[31778,[],""]
-0:["XsAEnZvT8GWmMEp4_0in-",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
+0:["QpcxqKJjVnif9CYPhpWjb",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
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 02ef53bef..75b1c508b 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 dd60dcaf6..3769dfc87 100644
--- a/ui/litellm-dashboard/out/model_hub.txt
+++ b/ui/litellm-dashboard/out/model_hub.txt
@@ -2,6 +2,6 @@
3:I[87494,["359","static/chunks/359-f105a7fb61fe8110.js","134","static/chunks/134-af41d2d267857018.js","418","static/chunks/app/model_hub/page-aa3c10cf9bb31255.js"],""]
4:I[5613,[],""]
5:I[31778,[],""]
-0:["XsAEnZvT8GWmMEp4_0in-",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
+0:["QpcxqKJjVnif9CYPhpWjb",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"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":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/338efd41b0181c1e.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
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/src/components/edit_user.tsx b/ui/litellm-dashboard/src/components/edit_user.tsx
index 4a822c4d1..850793d01 100644
--- a/ui/litellm-dashboard/src/components/edit_user.tsx
+++ b/ui/litellm-dashboard/src/components/edit_user.tsx
@@ -36,10 +36,6 @@ const EditUserModal: React.FC = ({ visible, onCancel, user,
form.resetFields();
}, [user]);
- const handleChange = (e) => {
- setEditedUser({ ...editedUser, [e.target.name]: e.target.value });
- };
-
const handleCancel = async () => {
form.resetFields();
onCancel();
diff --git a/ui/litellm-dashboard/src/components/usage.tsx b/ui/litellm-dashboard/src/components/usage.tsx
index 3e388b4c3..ea50422c2 100644
--- a/ui/litellm-dashboard/src/components/usage.tsx
+++ b/ui/litellm-dashboard/src/components/usage.tsx
@@ -162,7 +162,7 @@ const UsagePage: React.FC = ({
console.log("keys in usage", keys);
console.log("premium user in usage", premiumUser);
- function valueFormatterNumbers(number) {
+ function valueFormatterNumbers(number: number) {
const formatter = new Intl.NumberFormat('en-US', {
maximumFractionDigits: 0,
notation: 'compact',