diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html
index 88df94fcf..423a55d1f 100644
--- a/litellm/proxy/_experimental/out/404.html
+++ b/litellm/proxy/_experimental/out/404.html
@@ -1 +1 @@
-
404: This page could not be found.🚅 LiteLLM404
This page could not be found.
\ No newline at end of file
+404: This page could not be found.🚅 LiteLLM404
This page could not be found.
\ No newline at end of file
diff --git a/litellm/proxy/_experimental/out/_next/static/SgfgYknNTPjX1zfkhqLYs/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/aIO8mtlEIEUTmgL8cGjve/_buildManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/SgfgYknNTPjX1zfkhqLYs/_buildManifest.js
rename to litellm/proxy/_experimental/out/_next/static/aIO8mtlEIEUTmgL8cGjve/_buildManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/SgfgYknNTPjX1zfkhqLYs/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/aIO8mtlEIEUTmgL8cGjve/_ssgManifest.js
similarity index 100%
rename from litellm/proxy/_experimental/out/_next/static/SgfgYknNTPjX1zfkhqLYs/_ssgManifest.js
rename to litellm/proxy/_experimental/out/_next/static/aIO8mtlEIEUTmgL8cGjve/_ssgManifest.js
diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-144687b251040a22.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-144687b251040a22.js
new file mode 100644
index 000000000..761b3cd14
--- /dev/null
+++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-144687b251040a22.js
@@ -0,0 +1 @@
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{79615:function(e,t,s){Promise.resolve().then(s.bind(s,19914))},19914:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eM}});var l=s(3827),r=s(64090),n=s(47907),a=s(8792),o=s(2179),i=e=>{let{userID:t,userRole:s,userEmail:r,showSSOBanner:n}=e;return console.log("User ID:",t),console.log("userEmail:",r),(0,l.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,l.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,l.jsx)("div",{className:"flex flex-col items-center",children:(0,l.jsx)(a.default,{href:"/",children:(0,l.jsx)("button",{className:"text-gray-800 text-2xl py-1 rounded text-center",children:(0,l.jsx)("img",{src:"/get_image",width:200,height:200,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,l.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,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#setup-ssoauth-for-ui",target:"_blank",className:"mr-2",children:(0,l.jsx)(o.Z,{variant:"primary",size:"lg",children:"Enable SSO"})}):null,(0,l.jsxs)(o.Z,{variant:"secondary",size:"lg",children:[r,(0,l.jsxs)("p",{children:["Role: ",s]}),(0,l.jsxs)("p",{children:["ID: ",t]})]})]})]})},c=s(80588);let d=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw c.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw c.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},m=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let s=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},u=async function(e,t,s){let l=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let r="/user/info";"App Owner"==s&&t&&(r="".concat(r,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",l),l&&(r="".concat(r,"?view_all=true"));let n=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw c.ZP.error(e),Error("Network response was not ok")}let a=await n.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},x=async e=>{try{let t=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},p=async(e,t,s)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},j=async(e,t,s)=>{try{let t=await fetch("/model/metrics",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t,s)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,t)=>{try{let s="/global/spend/logs";console.log("in keySpendLogsCall:",s);let l=await fetch("".concat(s,"?api_key=").concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw c.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let s=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw c.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},Z=async(e,t,s,l,r,n)=>{try{console.log("user role in spend logs call: ".concat(s));let t="/spend/logs";t="App Owner"==s?"".concat(t,"?user_id=").concat(l,"&start_date=").concat(r,"&end_date=").concat(n):"".concat(t,"?start_date=").concat(r,"&end_date=").concat(n);let a=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw c.ZP.error(e),Error("Network response was not ok")}let o=await a.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},k=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t)=>{try{t&&JSON.stringify({api_key:t});let s={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};t&&(s.body=JSON.stringify({api_key:t}));let l=await fetch("/global/spend/end_users",s);if(!l.ok){let e=await l.text();throw c.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},b=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t)=>{try{let s=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!s.ok){let e=await s.text();throw c.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t,s,l)=>{try{let r=await fetch("/user/request_model",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({models:[t],user_id:s,justification:l})});if(!r.ok){let e=await r.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let n=await r.json();return console.log(n),n}catch(e){throw console.error("Failed to create key:",e),e}},N=async e=>{try{let t="/user/get_requests";console.log("in userGetRequesedtModelsCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to get requested models:",e),e}},A=async(e,t)=>{try{let s="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",s);let l=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},C=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let s=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,t,s)=>{try{console.log("Form Values in teamMemberAddCall:",s);let l=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:s})});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,t)=>{try{console.log("Form Values in userUpdateUserCall:",t);let s=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_role:"proxy_admin_viewer",...t})});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,t)=>{try{let s=await fetch("/global/predict/spend/logs",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:t})});if(!s.ok){let e=await s.text();throw c.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},P=async e=>{try{console.log("Checking Slack Budget Alerts service health");let t=await fetch("/health/services?service=slack_budget_alerts",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error("Failed Slack Alert test: "+e),Error(e)}let s=await t.json();return c.ZP.success("Test Slack Alert worked - check your Slack!"),console.log("Service Health Response:",s),s}catch(e){throw console.error("Failed to perform health check:",e),e}};var F=s(10384),O=s(46453),M=s(13810),R=s(71801),D=s(42440),U=s(17189),L=s(12143),B=s(77171),z=s(42539),K=s(88707),V=s(1861);let{Option:W}=U.default;var q=e=>{let{userID:t,teamID:s,userRole:n,accessToken:a,data:i,userModels:h,setData:m}=e,[u]=L.Z.useForm(),[x,p]=(0,r.useState)(!1),[j,y]=(0,r.useState)(null),[g,w]=(0,r.useState)(null),Z=()=>{p(!1),u.resetFields()},f=()=>{p(!1),y(null),u.resetFields()},k=async e=>{try{c.ZP.info("Making API Call"),p(!0);let s=await d(a,t,e);console.log("key create Response:",s),m(e=>e?[...e,s]:[s]),y(s.key),w(s.soft_budget),c.ZP.success("API Key Created"),u.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the key:",e)}},_=async()=>{try{console.log("Sending Slack alert...");let e=await P(a);console.log("slackBudgetAlertsHealthCheck Response:",e),console.log("Testing Slack alert successful")}catch(e){console.error("Error sending Slack alert:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{className:"mx-auto",onClick:()=>p(!0),children:"+ Create New Key"}),(0,l.jsx)(B.Z,{title:"Create Key",visible:x,width:800,footer:null,onOk:Z,onCancel:f,children:(0,l.jsxs)(L.Z,{form:u,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===n||"Admin"===n?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Key Name",name:"key_alias",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Team ID",name:"team_id",children:(0,l.jsx)(z.Z,{placeholder:"ai_team",defaultValue:s||""})}),(0,l.jsx)(L.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(U.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:h.map(e=>(0,l.jsx)(W,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Soft Budget (USD) Monthly",name:"soft_budget",initialValue:50,children:(0,l.jsx)(K.Z,{step:.01,precision:2,defaultValue:50,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(K.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,l.jsxs)(U.default,{defaultValue:null,placeholder:"n/a",children:[(0,l.jsx)(U.default.Option,{value:"24h",children:"daily"}),(0,l.jsx)(U.default.Option,{value:"30d",children:"monthly"})]})}),(0,l.jsx)(L.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(z.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Key Name",name:"key_alias",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Team ID (Contact Group)",name:"team_id",children:(0,l.jsx)(z.Z,{placeholder:"ai_team"})}),(0,l.jsx)(L.Z.Item,{label:"Description",name:"description",children:(0,l.jsx)(z.Z.TextArea,{placeholder:"Enter description",rows:4})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Create Key"})})]})}),j&&(0,l.jsx)(B.Z,{visible:x,onOk:Z,onCancel:f,footer:null,children:(0,l.jsx)(O.Z,{numItems:1,className:"gap-2 w-full",children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Save your Key"}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,l.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,l.jsx)(F.Z,{numColSpan:1,children:null!=j?(0,l.jsxs)("div",{children:[(0,l.jsxs)(R.Z,{children:["API Key: ",j]}),(0,l.jsx)(D.Z,{className:"mt-6",children:"Budgets"}),(0,l.jsxs)(R.Z,{children:["Soft Limit Budget: $",g]}),(0,l.jsx)(o.Z,{className:"mt-3",onClick:_,children:"Test Slack Alert"}),(0,l.jsxs)(R.Z,{className:"mt-2",children:["(LiteLLM Docs -",(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/alerting",target:"_blank",className:"text-blue-500",children:"Set Up Slack Alerting)"})]})]}):(0,l.jsx)(R.Z,{children:"Key being created, this might take 30s"})})]})})})]})},G=s(33393),J=s(61244),$=s(10827),H=s(3851),Y=s(2044),X=s(64167),Q=s(74480),ee=s(7178),et=s(9853),es=s(56863),el=e=>{let{token:t,accessToken:s,keySpend:n,keyBudget:a,keyName:i}=e,[c,d]=(0,r.useState)(!1),[h,m]=(0,r.useState)(null),[u,x]=(0,r.useState)(""),[p,j]=(0,r.useState)(null),y=async()=>{try{if(null==s||null==t)return;console.log("accessToken: ".concat(s,"; token: ").concat(t));let e=await g(s,t);console.log("Response:",e),m(e);let l=await E(s,e);console.log("Response2:",l);let r=[...e,...l.response];m(r),x(l.predicted_spend),console.log("Combined Data:",r)}catch(e){console.error("There was an error fetching the data",e)}};return t?(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{size:"xs",onClick:()=>{console.log("Show Modal triggered"),d(!0),y()},variant:"secondary",children:"Spend Report"}),(0,l.jsxs)(B.Z,{visible:c,width:1400,onOk:()=>{d(!1)},onCancel:()=>{d(!1)},footer:null,children:[(0,l.jsxs)(D.Z,{style:{textAlign:"left"},children:["Key Name: ",i]}),(0,l.jsxs)(es.Z,{children:["Monthly Spend $",n]}),(0,l.jsx)(D.Z,{children:u}),(0,l.jsx)(M.Z,{className:"mt-6 mb-6",children:h&&(0,l.jsx)(et.Z,{className:"mt-6",data:h,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})})]})]}):null},er=e=>{let{userID:t,accessToken:s,data:n,setData:a}=e,[i,c]=(0,r.useState)(!1),[d,h]=(0,r.useState)(!1),[u,x]=(0,r.useState)(null),p=async e=>{null!=n&&(x(e),localStorage.removeItem("userData"+t),h(!0))},j=async()=>{if(null!=u&&null!=n){try{await m(s,u);let e=n.filter(e=>e.token!==u);a(e)}catch(e){console.error("Error deleting the key:",e)}h(!1),x(null)}};if(null!=n)return console.log("RERENDER TRIGGERED"),(0,l.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:[(0,l.jsxs)($.Z,{className:"mt-5",children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Key Alias"}),(0,l.jsx)(Q.Z,{children:"Secret Key"}),(0,l.jsx)(Q.Z,{children:"Spend (USD)"}),(0,l.jsx)(Q.Z,{children:"Key Budget (USD)"}),(0,l.jsx)(Q.Z,{children:"Spend Report"}),(0,l.jsx)(Q.Z,{children:"Team ID"}),(0,l.jsx)(Q.Z,{children:"Metadata"}),(0,l.jsx)(Q.Z,{children:"Models"}),(0,l.jsx)(Q.Z,{children:"TPM / RPM Limits"}),(0,l.jsx)(Q.Z,{children:"Expires"})]})}),(0,l.jsx)(H.Z,{children:n.map(e=>(console.log(e),"litellm-dashboard"===e.team_id)?null:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,l.jsx)(R.Z,{children:e.key_alias}):(0,l.jsx)(R.Z,{children:"Not Set"})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:e.key_name})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(t){return e.spend}})()})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.max_budget?(0,l.jsx)(R.Z,{children:e.max_budget}):(0,l.jsx)(R.Z,{children:"Unlimited Budget"})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px"},children:(0,l.jsx)(el,{token:e.token,accessToken:s,keySpend:e.spend,keyBudget:e.max_budget,keyName:e.key_name})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:e.team_id})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:JSON.stringify(e.metadata).slice(0,400)})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:JSON.stringify(e.models)})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",overflowWrap:"break-word"},children:(0,l.jsxs)(R.Z,{children:["TPM Limit: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{})," RPM Limit:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",wordWrap:"break-word"},children:null!=e.expires?(0,l.jsx)(R.Z,{children:e.expires}):(0,l.jsx)(R.Z,{children:"Never"})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",wordWrap:"break-word"},children:(0,l.jsx)(J.Z,{onClick:()=>p(e.token),icon:G.Z,size:"sm"})})]},e.token))})]}),d&&(0,l.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,l.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,l.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,l.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,l.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,l.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,l.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,l.jsx)("div",{className:"sm:flex sm:items-start",children:(0,l.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,l.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,l.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,l.jsx)(o.Z,{onClick:j,color:"red",className:"ml-2",children:"Delete"}),(0,l.jsx)(o.Z,{onClick:()=>{h(!1),x(null)},children:"Cancel"})]})]})]})})]})},en=e=>{let{userID:t,userSpendData:s,userRole:n,accessToken:a}=e,[o,i]=(0,r.useState)(null==s?void 0:s.spend),[c,d]=(0,r.useState)((null==s?void 0:s.max_budget)||null);(0,r.useEffect)(()=>{(async()=>{if("Admin"===n)try{let e=await x(a);i(e.spend),d(e.max_budget||null)}catch(e){console.error("Error fetching global spend data:",e)}})()},[n,a]);let h=void 0!==o?o.toFixed(4):null;return(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(M.Z,{className:"mx-auto mb-4",children:[(0,l.jsxs)(es.Z,{children:["$",h]}),(0,l.jsxs)(D.Z,{children:["/ ",null!==c?"$".concat(c," limit"):"No limit"]})]})})},ea=s(36083),eo=s(68967),ei=s(27166),ec=e=>{let{teams:t,setSelectedTeam:s}=e,{Title:n,Paragraph:a}=ea.default,[o,i]=(0,r.useState)("");return(0,l.jsxs)("div",{className:"mt-10",children:[(0,l.jsx)(n,{level:4,children:"Default Team"}),(0,l.jsx)(a,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),t&&t.length>0?(0,l.jsx)(eo.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(ei.Z,{value:String(t),onClick:()=>s(e),children:e.team_alias},t))}):(0,l.jsxs)(a,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]})},ed=s(37963);console.log("isLocal:",!1);var eh=e=>{let{userID:t,userRole:s,teams:a,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:h,setKeys:m}=e,[p,j]=(0,r.useState)(null),g=(0,n.useSearchParams)();g.get("viewSpend"),(0,n.useRouter)();let w=g.get("token"),[Z,f]=(0,r.useState)(null),[k,_]=(0,r.useState)([]),[b,v]=(0,r.useState)(a?a[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(w){let e=(0,ed.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),f(e.key),e.user_role){let t=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:",t),i(t)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(t&&Z&&s&&!o&&!p){let e=sessionStorage.getItem("userModels"+t);e?_(JSON.parse(e)):(async()=>{try{let e=await u(Z,t,s);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await x(Z);j(e),console.log("globalSpend:",e)}else j(e.user_info);m(e.keys),h(e.teams),v(e.teams?e.teams[0]:null),sessionStorage.setItem("userData"+t,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+t,JSON.stringify(e.user_info));let l=(await y(Z,t,s)).data.map(e=>e.id);console.log("available_model_names:",l),_(l),console.log("userModels:",k),sessionStorage.setItem("userModels"+t,JSON.stringify(l))}catch(e){console.error("There was an error fetching the data",e)}})()}},[t,w,Z,o,s]),null==t||null==w){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==Z)return null;if(null==s&&i("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:t}=ea.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to create keys"})]})}return(0,l.jsx)("div",{children:(0,l.jsx)(O.Z,{numItems:1,className:"gap-0 p-10 h-[75vh] w-full",children:(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(en,{userID:t,userSpendData:p,userRole:s,accessToken:Z}),(0,l.jsx)(er,{userID:t,accessToken:Z,data:o,setData:m}),(0,l.jsx)(q,{userID:t,teamID:b?b.team_id:null,userRole:s,userModels:k,accessToken:Z,data:o,setData:m}),(0,l.jsx)(ec,{teams:a,setSelectedTeam:v})]})})})},em=s(5);let{Option:eu}=U.default;var ex=e=>{let{userModels:t,accessToken:s,userID:n}=e,[a]=L.Z.useForm(),[i,d]=(0,r.useState)(!1),h=async e=>{try{c.ZP.info("Requesting access");let{selectedModel:t,accessReason:l}=e;await S(s,t,n,l),d(!0)}catch(e){console.error("Error requesting access:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{size:"xs",onClick:()=>d(!0),children:"Request Access"}),(0,l.jsx)(B.Z,{title:"Request Access",visible:i,width:800,footer:null,onOk:()=>{d(!1),a.resetFields()},onCancel:()=>{d(!1),a.resetFields()},children:(0,l.jsxs)(L.Z,{form:a,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(L.Z.Item,{label:"Select Model",name:"selectedModel",children:(0,l.jsx)(U.default,{placeholder:"Select model",style:{width:"100%"},children:t.map(e=>(0,l.jsx)(eu,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Reason for Access",name:"accessReason",children:(0,l.jsx)(z.Z.TextArea,{rows:4,placeholder:"Enter reason for access"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(o.Z,{children:"Request Access"})})]})})]})},ep=e=>{let{accessToken:t,token:s,userRole:n,userID:a}=e,[o,i]=(0,r.useState)({data:[]}),[c,d]=(0,r.useState)([]),[h,m]=(0,r.useState)([]);if((0,r.useEffect)(()=>{if(!t||!s||!n||!a)return;let e=async()=>{try{let e=await p(t,a,n);console.log("Model data response:",e.data),i(e);let s=await j(t,a,n);if(console.log("Model metrics response:",s),d(s),"Admin"===n&&t){let e=await N(t);console.log("Pending Requests:",h),m(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&n&&a&&e()},[t,s,n,a]),!o||!t||!s||!n||!a)return(0,l.jsx)("div",{children:"Loading..."});let u=[];for(let e=0;e(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:(0,l.jsx)(D.Z,{children:e.model_name})}),(0,l.jsx)(Y.Z,{children:e.provider}),"Admin"===n&&(0,l.jsx)(Y.Z,{children:e.api_base}),(0,l.jsx)(Y.Z,{children:e.user_access?(0,l.jsx)(em.Z,{color:"green",children:"Yes"}):(0,l.jsx)(ex,{userModels:u,accessToken:t,userID:a})}),(0,l.jsx)(Y.Z,{children:e.input_cost}),(0,l.jsx)(Y.Z,{children:e.output_cost}),(0,l.jsx)(Y.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Model Statistics (Number Requests)"}),(0,l.jsx)(et.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Model Statistics (Latency)"}),(0,l.jsx)(et.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})})},ej=s(92836),ey=s(26734),eg=s(41608),ew=s(32126),eZ=s(23682);let{Option:ef}=U.default;var ek=e=>{let{userID:t,accessToken:s}=e,[n]=L.Z.useForm(),[a,i]=(0,r.useState)(!1),[d,m]=(0,r.useState)(null),[u,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await y(s,t,"any"),l=[];for(let t=0;t{i(!1),n.resetFields()},j=()=>{i(!1),m(null),n.resetFields()},g=async e=>{try{c.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let l=await h(s,t,e);console.log("user create Response:",l),m(l.key),c.ZP.success("API user Created"),n.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the user:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{className:"mx-auto",onClick:()=>i(!0),children:"+ Create New User"}),(0,l.jsx)(B.Z,{title:"Create User",visible:a,width:800,footer:null,onOk:p,onCancel:j,children:(0,l.jsxs)(L.Z,{form:n,onFinish:g,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(L.Z.Item,{label:"User ID",name:"user_id",children:(0,l.jsx)(z.Z,{placeholder:"Enter User ID"})}),(0,l.jsx)(L.Z.Item,{label:"Team ID",name:"team_id",children:(0,l.jsx)(z.Z,{placeholder:"ai_team"})}),(0,l.jsx)(L.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(U.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:u.map(e=>(0,l.jsx)(ef,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(K.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(z.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Create User"})})]})}),d&&(0,l.jsxs)(B.Z,{title:"Save Your User",visible:a,onOk:p,onCancel:j,footer:null,children:[(0,l.jsxs)("p",{children:["Please save this secret user somewhere safe and accessible. For security reasons, ",(0,l.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret user, you will need to generate a new one."]}),(0,l.jsx)("p",{children:null!=d?"API user: ".concat(d):"User being created, this might take 30s"})]})]})},e_=e=>{let{accessToken:t,token:s,keys:n,userRole:a,userID:o,setKeys:i}=e,[c,d]=(0,r.useState)(null),[h,m]=(0,r.useState)(null),[x,p]=(0,r.useState)(1);if((0,r.useEffect)(()=>{if(!t||!s||!a||!o)return;let e=async()=>{try{let e=await u(t,null,a,!0);console.log("user data response:",e),d(e)}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&a&&o&&!c&&e();let l=async()=>{try{let e=await _(t,null);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};a&&("Admin"==a||"Admin Viewer"==a)&&!h&&l()},[t,s,a,o]),!c||!t||!s||!a||!o)return(0,l.jsx)("div",{children:"Loading..."});let j=async e=>{try{let s=await _(t,e);console.log("user data response:",s),m(s)}catch(e){console.error("There was an error fetching the model data",e)}};return(0,l.jsx)("div",{style:{width:"100%"},children:(0,l.jsxs)(O.Z,{className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(ek,{userID:o,accessToken:t}),(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{variant:"line",defaultValue:"1",children:[(0,l.jsx)(ej.Z,{value:"1",children:"Key Owners"}),(0,l.jsx)(ej.Z,{value:"2",children:"End-Users"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsx)(ew.Z,{children:(0,l.jsxs)($.Z,{className:"mt-5",children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"User ID"}),(0,l.jsx)(Q.Z,{children:"User Role"}),(0,l.jsx)(Q.Z,{children:"User Models"}),(0,l.jsx)(Q.Z,{children:"User Spend ($ USD)"}),(0,l.jsx)(Q.Z,{children:"User Max Budget ($ USD)"})]})}),(0,l.jsx)(H.Z,{children:c.map(e=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.user_id}),(0,l.jsx)(Y.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,l.jsx)(Y.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,l.jsx)(Y.Z,{children:e.spend?e.spend:0}),(0,l.jsx)(Y.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,l.jsxs)(ew.Z,{children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("div",{className:"flex-1"}),(0,l.jsxs)("div",{className:"flex-1 flex justify-between items-center",children:[(0,l.jsx)(R.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,l.jsx)(eo.Z,{defaultValue:"1",className:"w-3/4",children:null==n?void 0:n.map((e,t)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,l.jsx)(ei.Z,{value:String(t),onClick:()=>j(e.token),children:e.key_name},t)})})]})]}),(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"End User"}),(0,l.jsx)(Q.Z,{children:"Spend"}),(0,l.jsx)(Q.Z,{children:"Total Events"})]})}),(0,l.jsx)(H.Z,{children:null==h?void 0:h.map((e,t)=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.end_user}),(0,l.jsx)(Y.Z,{children:e.total_spend}),(0,l.jsx)(Y.Z,{children:e.total_events})]},t))})]})]})]})]})}),function(){if(!c)return null;let e=Math.ceil(c.length/25),t=Math.min(25*x,c.length);return(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsxs)("div",{children:["Showing ",(x-1)*25+1," – ",t," of ",c.length]}),(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===x,onClick:()=>p(x-1),children:"← Prev"}),(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:x===e,onClick:()=>p(x+1),children:"Next →"})]})]})}()]})})},eb=s(8510),ev=e=>{let{teams:t,searchParams:s,accessToken:n,setTeams:a,userID:i,userRole:d}=e,[h]=L.Z.useForm(),[m]=L.Z.useForm(),{Title:u,Paragraph:x}=ea.default,[p,j]=(0,r.useState)(""),[g,w]=(0,r.useState)(t?t[0]:null),[Z,f]=(0,r.useState)(!1),[k,_]=(0,r.useState)(!1),[b,v]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===i||null===d)return;if(null!==n){let e=(await y(n,i,d)).data.map(e=>e.id);console.log("available_model_names:",e),v(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,i,d]);let S=async e=>{try{if(null!=n){let s=await C(n,e);null!==t?a([...t,s]):a([s]),console.log("response for team create call: ".concat(s)),c.ZP.success("Team created"),f(!1)}}catch(e){console.error("Error creating the key:",e),c.ZP.error("Error creating the team: "+e)}},N=async e=>{try{if(null!=n&&null!=t){c.ZP.info("Making API Call");let s={role:"user",user_email:e.user_email,user_id:e.user_id},l=await T(n,g.team_id,s);console.log("response for team create call: ".concat(l.data));let r=t.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(l.data.team_id)),e.team_id===l.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...t];e[r]=l.data,a(e),w(l.data)}_(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("received teams ".concat(t)),(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)(O.Z,{numItems:1,className:"gap-2 p-2 h-[75vh] w-full",children:[(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(u,{level:4,children:"All Teams"}),(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Team Name"}),(0,l.jsx)(Q.Z,{children:"Spend (USD)"}),(0,l.jsx)(Q.Z,{children:"Budget (USD)"}),(0,l.jsx)(Q.Z,{children:"TPM / RPM Limits"})]})}),(0,l.jsx)(H.Z,{children:t&&t.length>0?t.map(e=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.team_alias}),(0,l.jsx)(Y.Z,{children:e.spend}),(0,l.jsx)(Y.Z,{children:e.max_budget?e.max_budget:"No limit"}),(0,l.jsx)(Y.Z,{children:(0,l.jsxs)(R.Z,{children:["TPM Limit:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{})," RPM Limit:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsx)(Y.Z,{children:(0,l.jsx)(J.Z,{icon:eb.Z,size:"sm"})})]},e.team_id)):null})]})})]}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(o.Z,{className:"mx-auto",onClick:()=>f(!0),children:"+ Create New Team"}),(0,l.jsx)(B.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{f(!1),h.resetFields()},onCancel:()=>{f(!1),h.resetFields()},children:(0,l.jsxs)(L.Z,{form:h,onFinish:S,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Team Name",name:"team_alias",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(U.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:b.map(e=>(0,l.jsx)(U.default.Option,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(K.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(u,{level:4,children:"Team Members"}),(0,l.jsx)(x,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),t&&t.length>0?(0,l.jsx)(eo.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(ei.Z,{value:String(t),onClick:()=>{w(e)},children:e.team_alias},t))}):(0,l.jsxs)(x,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Member Name"}),(0,l.jsx)(Q.Z,{children:"Role"}),(0,l.jsx)(Q.Z,{children:"Action"})]})}),(0,l.jsx)(H.Z,{children:g?g.members_with_roles.map((e,t)=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(Y.Z,{children:e.role}),(0,l.jsx)(Y.Z,{children:(0,l.jsx)(J.Z,{icon:eb.Z,size:"sm"})})]},t)):null})]})})}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(o.Z,{className:"mx-auto mb-5",onClick:()=>_(!0),children:"+ Add member"}),(0,l.jsx)(B.Z,{title:"Add member",visible:k,width:800,footer:null,onOk:()=>{_(!1),m.resetFields()},onCancel:()=>{_(!1),m.resetFields()},children:(0,l.jsxs)(L.Z,{form:h,onFinish:N,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(L.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eS=e=>{let{searchParams:t,accessToken:s}=e,[n]=L.Z.useForm(),[a]=L.Z.useForm(),{Title:i,Paragraph:d}=ea.default,[h,m]=(0,r.useState)(""),[u,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{if(null!=s){let e=[],t=await A(s,"proxy_admin_viewer");t.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy viewers: ".concat(t));let l=await A(s,"proxy_admin");l.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy admins: ".concat(l)),console.log("combinedList: ".concat(e)),x(e)}})()},[s]);let y=async e=>{try{if(null!=s&&null!=u){c.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await I(s,e);console.log("response for team create call: ".concat(t));let l=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(t.user_id)),e.user_id===t.user_id));console.log("foundIndex: ".concat(l)),-1==l&&(console.log("updates admin with new user"),u.push(t),x(u)),j(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("admins: ".concat(null==u?void 0:u.length)),(0,l.jsxs)("div",{className:"w-full m-2",children:[(0,l.jsx)(i,{level:4,children:"Restricted Access"}),(0,l.jsxs)(d,{children:["Add other people to just view spend. They cannot create keys, teams or grant users access to new models."," ",(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"})]}),(0,l.jsxs)(O.Z,{numItems:1,className:"gap-2 p-0 w-full",children:[(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Member Name"}),(0,l.jsx)(Q.Z,{children:"Role"}),(0,l.jsx)(Q.Z,{children:"Action"})]})}),(0,l.jsx)(H.Z,{children:u?u.map((e,t)=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(Y.Z,{children:e.user_role}),(0,l.jsx)(Y.Z,{children:(0,l.jsx)(J.Z,{icon:eb.Z,size:"sm"})})]},t)):null})]})})}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(o.Z,{className:"mx-auto mb-5",onClick:()=>j(!0),children:"+ Add viewer"}),(0,l.jsx)(B.Z,{title:"Add viewer",visible:p,width:800,footer:null,onOk:()=>{j(!1),a.resetFields()},onCancel:()=>{j(!1),a.resetFields()},children:(0,l.jsxs)(L.Z,{form:n,onFinish:y,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(L.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})]})},eN=s(12968),eA=s(67951);async function eC(e,t,s,l){console.log("isLocal:",!1);let r=window.location.origin,n=new eN.ZP.OpenAI({apiKey:l,baseURL:r,dangerouslyAllowBrowser:!0});for await(let l of(await n.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(l),l.choices[0].delta.content&&t(l.choices[0].delta.content)}var eT=e=>{let{accessToken:t,token:s,userRole:n,userID:a}=e,[o,i]=(0,r.useState)(""),[c,d]=(0,r.useState)([]),[h,m]=(0,r.useState)(void 0),[u,x]=(0,r.useState)(null);(0,r.useEffect)(()=>{t&&s&&n&&a&&(async()=>{let e=await y(t,a,n);console.log("model_info:",e),(null==e?void 0:e.data.length)>0&&(x(e.data),m(e.data[0].id))})()},[t,a,n]);let p=(e,t)=>{d(s=>{let l=s[s.length-1];return l&&l.role===e?[...s.slice(0,s.length-1),{role:e,content:l.content+t}]:[...s,{role:e,content:t}]})},j=async()=>{if(""!==o.trim()&&t&&s&&n&&a){d(e=>[...e,{role:"user",content:o}]);try{h&&await eC(o,e=>p("assistant",e),h,t)}catch(e){console.error("Error fetching model response",e),p("assistant","Error fetching model response")}i("")}};if(n&&"Admin Viewer"==n){let{Title:e,Paragraph:t}=ea.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to test models"})]})}return(0,l.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,l.jsx)(O.Z,{className:"gap-2 p-10 h-[75vh] w-full",children:(0,l.jsx)(M.Z,{children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{className:"mt-4",children:[(0,l.jsx)(ej.Z,{children:"Chat"}),(0,l.jsx)(ej.Z,{children:"API Reference"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsxs)(ew.Z,{children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{children:"Select Model:"}),(0,l.jsx)("select",{value:h||"",onChange:e=>m(e.target.value),children:null==u?void 0:u.map(e=>(0,l.jsx)("option",{value:e.id,children:e.id},e.id))})]}),(0,l.jsxs)($.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,l.jsx)(X.Z,{children:(0,l.jsx)(ee.Z,{children:(0,l.jsx)(Y.Z,{children:(0,l.jsx)(D.Z,{children:"Chat"})})})}),(0,l.jsx)(H.Z,{children:c.map((e,t)=>(0,l.jsx)(ee.Z,{children:(0,l.jsx)(Y.Z,{children:"".concat(e.role,": ").concat(e.content)})},t))})]}),(0,l.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("input",{type:"text",value:o,onChange:e=>i(e.target.value),className:"flex-1 p-2 border rounded-md mr-2",placeholder:"Type your message..."}),(0,l.jsx)("button",{onClick:j,className:"p-2 bg-blue-500 text-white rounded-md",children:"Send"})]})})]}),(0,l.jsx)(ew.Z,{children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{children:[(0,l.jsx)(ej.Z,{children:"OpenAI Python SDK"}),(0,l.jsx)(ej.Z,{children:"LlamaIndex"}),(0,l.jsx)(ej.Z,{children:"Langchain Py"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsx)(ew.Z,{children:(0,l.jsx)(eA.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # proxy base url\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to use from Models Tab\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ],\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-openai-client",\n "generation_id": "openai-client-gen-id22",\n "trace_id": "openai-client-trace-id22",\n "trace_user_id": "openai-client-user-id2"\n }\n }\n)\n\nprint(response)\n '})}),(0,l.jsx)(ew.Z,{children:(0,l.jsx)(eA.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="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,l.jsx)(ew.Z,{children:(0,l.jsx)(eA.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:8000",\n model = "gpt-3.5-turbo",\n temperature=0.1,\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-langchain-client",\n "generation_id": "langchain-client-gen-id22",\n "trace_id": "langchain-client-trace-id22",\n "trace_user_id": "langchain-client-user-id2"\n }\n }\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 '})})]})]})})]})]})})})})},eI=s(33509),eE=s(30569);let{Sider:eP}=eI.default;var eF=e=>{let{setPage:t,userRole:s,defaultSelectedKey:r}=e;return"Admin Viewer"==s?(0,l.jsx)(eI.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,l.jsx)(eP,{width:120,children:(0,l.jsxs)(eE.Z,{mode:"inline",defaultSelectedKeys:r||["4"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eE.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"4"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"1")]})})}):(0,l.jsx)(eI.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,l.jsx)(eP,{width:120,children:(0,l.jsxs)(eE.Z,{mode:"inline",defaultSelectedKeys:r||["1"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eE.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"1"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"4"),"Admin"==s?(0,l.jsx)(eE.Z.Item,{onClick:()=>t("users"),children:"Users"},"5"):null,"Admin"==s?(0,l.jsx)(eE.Z.Item,{onClick:()=>t("teams"),children:"Teams"},"6"):null,"Admin"==s?(0,l.jsx)(eE.Z.Item,{onClick:()=>t("admin-panel"),children:"Admin"},"7"):null]})})})},eO=e=>{let{accessToken:t,token:s,userRole:n,userID:a}=e,o=new Date,[i,c]=(0,r.useState)([]),[d,h]=(0,r.useState)([]),[m,u]=(0,r.useState)([]),[x,p]=(0,r.useState)([]),[j,y]=(0,r.useState)([]),[g,_]=(0,r.useState)([]),[S,N]=(0,r.useState)([]),A=new Date(o.getFullYear(),o.getMonth(),1),C=new Date(o.getFullYear(),o.getMonth()+1,0),T=E(A),I=E(C);function E(e){let t=e.getFullYear(),s=e.getMonth()+1,l=e.getDate();return"".concat(t,"-").concat(s<10?"0"+s:s,"-").concat(l<10?"0"+l:l)}return console.log("Start date is ".concat(T)),console.log("End date is ".concat(I)),(0,r.useEffect)(()=>{t&&s&&n&&a&&(async()=>{try{if(console.log("user role: ".concat(n)),"Admin"==n||"Admin Viewer"==n){let e=await f(t);c(e);let s=(await k(t)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,7),spend:e.total_spend}));h(s);let l=(await b(t)).map(e=>({key:e.model,spend:e.total_spend}));u(l);let r=await w(t);console.log("teamSpend",r),y(r.daily_spend),_(r.teams),N(r.total_spend_per_team)}else"App Owner"==n&&await Z(t,s,n,a,T,I).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let t=e.daily_spend;console.log("daily spend",t),c(t);let s=e.top_api_keys;h(s)}else{let s=(await v(t,function(e){let t=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,l]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&t.push({key:s,spend:l})})}),t.sort((e,t)=>Number(t.spend)-Number(e.spend));let s=t.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||e.token).substring(0,7),spend:e.spend}));h(s),p(function(e){let t={};e.forEach(e=>{Object.entries(e.users).forEach(e=>{let[s,l]=e;""!==s&&null!=s&&"None"!=s&&(t[s]||(t[s]=0),t[s]+=l)})});let s=Object.entries(t).map(e=>{let[t,s]=e;return{user_id:t,spend:s}});s.sort((e,t)=>t.spend-e.spend);let l=s.slice(0,5);return console.log("topKeys: ".concat(Object.values(l[0]))),l}(e)),c(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[t,s,n,a,T,I]),(0,l.jsx)("div",{style:{width:"100%"},children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{className:"mt-4",children:[(0,l.jsx)(ej.Z,{children:"All Up"}),(0,l.jsx)(ej.Z,{children:"Team Based Usage"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsx)(ew.Z,{children:(0,l.jsxs)(O.Z,{numItems:2,className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(F.Z,{numColSpan:2,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Monthly Spend"}),(0,l.jsx)(et.Z,{data:i,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Top API Keys"}),(0,l.jsx)(et.Z,{className:"mt-4 h-40",data:d,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Top Users"}),(0,l.jsx)(et.Z,{className:"mt-4 h-40",data:x,index:"user_id",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Top Models"}),(0,l.jsx)(et.Z,{className:"mt-4 h-40",data:m,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,l.jsx)(ew.Z,{children:(0,l.jsxs)(O.Z,{numItems:2,className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(F.Z,{numColSpan:2,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Daily Spend Per Team"}),(0,l.jsx)(et.Z,{className:"h-72",data:j,index:"date",categories:g,yAxisWidth:30,stack:!0})]})}),(0,l.jsx)(F.Z,{numColSpan:2,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Total Spend Per Team"}),(0,l.jsx)(et.Z,{className:"h-72",data:S,index:"team_id",categories:["total_spend"],yAxisWidth:30})]})})]})})]})]})})},eM=()=>{let{Title:e,Paragraph:t}=ea.default,[s,a]=(0,r.useState)(""),[o,c]=(0,r.useState)(null),[d,h]=(0,r.useState)(null),[m,u]=(0,r.useState)(null),[x,p]=(0,r.useState)(!0),j=(0,n.useSearchParams)(),y=j.get("userID"),g=j.get("token"),[w,Z]=(0,r.useState)("api-keys"),[f,k]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(g){let e=(0,ed.o)(g);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),k(e.key),e.user_role){let t=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:",t),a(t),"Admin Viewer"==t&&Z("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?p("username_password"==e.login_method):console.log("User Email is not set ".concat(e))}}},[g]),(0,l.jsx)(r.Suspense,{fallback:(0,l.jsx)("div",{children:"Loading..."}),children:(0,l.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,l.jsx)(i,{userID:y,userRole:s,userEmail:o,showSSOBanner:x}),(0,l.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,l.jsx)(eF,{setPage:Z,userRole:s,defaultSelectedKey:null}),"api-keys"==w?(0,l.jsx)(eh,{userID:y,userRole:s,teams:d,keys:m,setUserRole:a,userEmail:o,setUserEmail:c,setTeams:h,setKeys:u}):"models"==w?(0,l.jsx)(ep,{userID:y,userRole:s,token:g,accessToken:f}):"llm-playground"==w?(0,l.jsx)(eT,{userID:y,userRole:s,token:g,accessToken:f}):"users"==w?(0,l.jsx)(e_,{userID:y,userRole:s,token:g,keys:m,accessToken:f,setKeys:u}):"teams"==w?(0,l.jsx)(ev,{teams:d,setTeams:h,searchParams:j,accessToken:f,userID:y,userRole:s}):"admin-panel"==w?(0,l.jsx)(eS,{setTeams:h,searchParams:j,accessToken:f}):(0,l.jsx)(eO,{userID:y,userRole:s,token:g,accessToken:f})]})]})})}}},function(e){e.O(0,[730,971,69,744],function(){return e(e.s=79615)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-23f3f2a4358844b5.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-23f3f2a4358844b5.js
deleted file mode 100644
index 239427df8..000000000
--- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-23f3f2a4358844b5.js
+++ /dev/null
@@ -1 +0,0 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{79615:function(e,t,s){Promise.resolve().then(s.bind(s,19914))},19914:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eM}});var l=s(3827),r=s(64090),n=s(47907),a=s(8792),o=s(2179),i=e=>{let{userID:t,userRole:s,userEmail:r,showSSOBanner:n}=e;return console.log("User ID:",t),console.log("userEmail:",r),(0,l.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,l.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,l.jsx)("div",{className:"flex flex-col items-center",children:(0,l.jsx)(a.default,{href:"/",children:(0,l.jsx)("button",{className:"text-gray-800 text-2xl py-1 rounded text-center",children:(0,l.jsx)("img",{src:"/get_image",width:200,height:200,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,l.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,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#setup-ssoauth-for-ui",target:"_blank",className:"mr-2",children:(0,l.jsx)(o.Z,{variant:"primary",size:"lg",children:"Enable SSO"})}):null,(0,l.jsxs)(o.Z,{variant:"secondary",size:"lg",children:[r,(0,l.jsxs)("p",{children:["Role: ",s]}),(0,l.jsxs)("p",{children:["ID: ",t]})]})]})]})},c=s(80588);let d=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw c.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw c.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},m=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let s=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},u=async function(e,t,s){let l=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let r="/user/info";"App Owner"==s&&t&&(r="".concat(r,"/?user_id=").concat(t)),console.log("in userInfoCall viewAll=",l),l&&(r="".concat(r,"?view_all=true"));let n=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw c.ZP.error(e),Error("Network response was not ok")}let a=await n.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},x=async e=>{try{let t=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},p=async(e,t,s)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},j=async(e,t,s)=>{try{let t=await fetch("/model/metrics",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t,s)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,t)=>{try{let s="/global/spend/logs";console.log("in keySpendLogsCall:",s);let l=await fetch("".concat(s,"/?api_key=").concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw c.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let s=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw c.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},Z=async(e,t,s,l,r,n)=>{try{console.log("user role in spend logs call: ".concat(s));let t="/spend/logs";t="App Owner"==s?"".concat(t,"/?user_id=").concat(l,"&start_date=").concat(r,"&end_date=").concat(n):"".concat(t,"/?start_date=").concat(r,"&end_date=").concat(n);let a=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw c.ZP.error(e),Error("Network response was not ok")}let o=await a.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},k=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t)=>{try{t&&JSON.stringify({api_key:t});let s={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};t&&(s.body=JSON.stringify({api_key:t}));let l=await fetch("/global/spend/end_users",s);if(!l.ok){let e=await l.text();throw c.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},b=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t)=>{try{let s=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!s.ok){let e=await s.text();throw c.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t,s,l)=>{try{let r=await fetch("/user/request_model",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({models:[t],user_id:s,justification:l})});if(!r.ok){let e=await r.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let n=await r.json();return console.log(n),n}catch(e){throw console.error("Failed to create key:",e),e}},N=async e=>{try{let t="/user/get_requests";console.log("in userGetRequesedtModelsCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to get requested models:",e),e}},A=async(e,t)=>{try{let s="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",s);let l=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},C=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let s=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,t,s)=>{try{console.log("Form Values in teamMemberAddCall:",s);let l=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:s})});if(!l.ok){let e=await l.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,t)=>{try{console.log("Form Values in userUpdateUserCall:",t);let s=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_role:"proxy_admin_viewer",...t})});if(!s.ok){let e=await s.text();throw c.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,t)=>{try{let s=await fetch("/global/predict/spend/logs",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:t})});if(!s.ok){let e=await s.text();throw c.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},P=async e=>{try{console.log("Checking Slack Budget Alerts service health");let t=await fetch("/health/services?service=slack_budget_alerts",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw c.ZP.error("Failed Slack Alert test: "+e),Error(e)}let s=await t.json();return c.ZP.success("Test Slack Alert worked - check your Slack!"),console.log("Service Health Response:",s),s}catch(e){throw console.error("Failed to perform health check:",e),e}};var F=s(10384),O=s(46453),M=s(13810),R=s(71801),D=s(42440),U=s(17189),L=s(12143),B=s(77171),z=s(42539),K=s(88707),V=s(1861);let{Option:W}=U.default;var q=e=>{let{userID:t,teamID:s,userRole:n,accessToken:a,data:i,userModels:h,setData:m}=e,[u]=L.Z.useForm(),[x,p]=(0,r.useState)(!1),[j,y]=(0,r.useState)(null),[g,w]=(0,r.useState)(null),Z=()=>{p(!1),u.resetFields()},f=()=>{p(!1),y(null),u.resetFields()},k=async e=>{try{c.ZP.info("Making API Call"),p(!0);let s=await d(a,t,e);console.log("key create Response:",s),m(e=>e?[...e,s]:[s]),y(s.key),w(s.soft_budget),c.ZP.success("API Key Created"),u.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the key:",e)}},_=async()=>{try{console.log("Sending Slack alert...");let e=await P(a);console.log("slackBudgetAlertsHealthCheck Response:",e),console.log("Testing Slack alert successful")}catch(e){console.error("Error sending Slack alert:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{className:"mx-auto",onClick:()=>p(!0),children:"+ Create New Key"}),(0,l.jsx)(B.Z,{title:"Create Key",visible:x,width:800,footer:null,onOk:Z,onCancel:f,children:(0,l.jsxs)(L.Z,{form:u,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===n||"Admin"===n?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Key Name",name:"key_alias",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Team ID",name:"team_id",children:(0,l.jsx)(z.Z,{placeholder:"ai_team",defaultValue:s||""})}),(0,l.jsx)(L.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(U.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:h.map(e=>(0,l.jsx)(W,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Soft Budget (USD) Monthly",name:"soft_budget",initialValue:50,children:(0,l.jsx)(K.Z,{step:.01,precision:2,defaultValue:50,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(K.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Reset Budget",name:"budget_duration",children:(0,l.jsxs)(U.default,{defaultValue:null,placeholder:"n/a",children:[(0,l.jsx)(U.default.Option,{value:"24h",children:"daily"}),(0,l.jsx)(U.default.Option,{value:"30d",children:"monthly"})]})}),(0,l.jsx)(L.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(z.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Key Name",name:"key_alias",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Team ID (Contact Group)",name:"team_id",children:(0,l.jsx)(z.Z,{placeholder:"ai_team"})}),(0,l.jsx)(L.Z.Item,{label:"Description",name:"description",children:(0,l.jsx)(z.Z.TextArea,{placeholder:"Enter description",rows:4})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Create Key"})})]})}),j&&(0,l.jsx)(B.Z,{visible:x,onOk:Z,onCancel:f,footer:null,children:(0,l.jsx)(O.Z,{numItems:1,className:"gap-2 w-full",children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Save your Key"}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,l.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,l.jsx)(F.Z,{numColSpan:1,children:null!=j?(0,l.jsxs)("div",{children:[(0,l.jsxs)(R.Z,{children:["API Key: ",j]}),(0,l.jsx)(D.Z,{className:"mt-6",children:"Budgets"}),(0,l.jsxs)(R.Z,{children:["Soft Limit Budget: $",g]}),(0,l.jsx)(o.Z,{className:"mt-3",onClick:_,children:"Test Slack Alert"}),(0,l.jsxs)(R.Z,{className:"mt-2",children:["(LiteLLM Docs -",(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/alerting",target:"_blank",className:"text-blue-500",children:"Set Up Slack Alerting)"})]})]}):(0,l.jsx)(R.Z,{children:"Key being created, this might take 30s"})})]})})})]})},G=s(33393),J=s(61244),$=s(10827),H=s(3851),Y=s(2044),X=s(64167),Q=s(74480),ee=s(7178),et=s(9853),es=s(56863),el=e=>{let{token:t,accessToken:s,keySpend:n,keyBudget:a,keyName:i}=e,[c,d]=(0,r.useState)(!1),[h,m]=(0,r.useState)(null),[u,x]=(0,r.useState)(""),[p,j]=(0,r.useState)(null),y=async()=>{try{if(null==s||null==t)return;console.log("accessToken: ".concat(s,"; token: ").concat(t));let e=await g(s,t);console.log("Response:",e),m(e);let l=await E(s,e);console.log("Response2:",l);let r=[...e,...l.response];m(r),x(l.predicted_spend),console.log("Combined Data:",r)}catch(e){console.error("There was an error fetching the data",e)}};return t?(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{size:"xs",onClick:()=>{console.log("Show Modal triggered"),d(!0),y()},variant:"secondary",children:"Spend Report"}),(0,l.jsxs)(B.Z,{visible:c,width:1400,onOk:()=>{d(!1)},onCancel:()=>{d(!1)},footer:null,children:[(0,l.jsxs)(D.Z,{style:{textAlign:"left"},children:["Key Name: ",i]}),(0,l.jsxs)(es.Z,{children:["Monthly Spend $",n]}),(0,l.jsx)(D.Z,{children:u}),(0,l.jsx)(M.Z,{className:"mt-6 mb-6",children:h&&(0,l.jsx)(et.Z,{className:"mt-6",data:h,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})})]})]}):null},er=e=>{let{userID:t,accessToken:s,data:n,setData:a}=e,[i,c]=(0,r.useState)(!1),[d,h]=(0,r.useState)(!1),[u,x]=(0,r.useState)(null),p=async e=>{null!=n&&(x(e),localStorage.removeItem("userData"+t),h(!0))},j=async()=>{if(null!=u&&null!=n){try{await m(s,u);let e=n.filter(e=>e.token!==u);a(e)}catch(e){console.error("Error deleting the key:",e)}h(!1),x(null)}};if(null!=n)return console.log("RERENDER TRIGGERED"),(0,l.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:[(0,l.jsxs)($.Z,{className:"mt-5",children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Key Alias"}),(0,l.jsx)(Q.Z,{children:"Secret Key"}),(0,l.jsx)(Q.Z,{children:"Spend (USD)"}),(0,l.jsx)(Q.Z,{children:"Key Budget (USD)"}),(0,l.jsx)(Q.Z,{children:"Spend Report"}),(0,l.jsx)(Q.Z,{children:"Team ID"}),(0,l.jsx)(Q.Z,{children:"Metadata"}),(0,l.jsx)(Q.Z,{children:"Models"}),(0,l.jsx)(Q.Z,{children:"TPM / RPM Limits"}),(0,l.jsx)(Q.Z,{children:"Expires"})]})}),(0,l.jsx)(H.Z,{children:n.map(e=>(console.log(e),"litellm-dashboard"===e.team_id)?null:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,l.jsx)(R.Z,{children:e.key_alias}):(0,l.jsx)(R.Z,{children:"Not Set"})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:e.key_name})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(t){return e.spend}})()})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.max_budget?(0,l.jsx)(R.Z,{children:e.max_budget}):(0,l.jsx)(R.Z,{children:"Unlimited Budget"})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px"},children:(0,l.jsx)(el,{token:e.token,accessToken:s,keySpend:e.spend,keyBudget:e.max_budget,keyName:e.key_name})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:e.team_id})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:JSON.stringify(e.metadata).slice(0,400)})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsx)(R.Z,{children:JSON.stringify(e.models)})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",overflowWrap:"break-word"},children:(0,l.jsxs)(R.Z,{children:["TPM Limit: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{})," RPM Limit:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",wordWrap:"break-word"},children:null!=e.expires?(0,l.jsx)(R.Z,{children:e.expires}):(0,l.jsx)(R.Z,{children:"Never"})}),(0,l.jsx)(Y.Z,{style:{maxWidth:"2px",wordWrap:"break-word"},children:(0,l.jsx)(J.Z,{onClick:()=>p(e.token),icon:G.Z,size:"sm"})})]},e.token))})]}),d&&(0,l.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,l.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,l.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,l.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,l.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:""}),(0,l.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,l.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,l.jsx)("div",{className:"sm:flex sm:items-start",children:(0,l.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,l.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,l.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,l.jsx)(o.Z,{onClick:j,color:"red",className:"ml-2",children:"Delete"}),(0,l.jsx)(o.Z,{onClick:()=>{h(!1),x(null)},children:"Cancel"})]})]})]})})]})},en=e=>{let{userID:t,userSpendData:s,userRole:n,accessToken:a}=e,[o,i]=(0,r.useState)(null==s?void 0:s.spend),[c,d]=(0,r.useState)((null==s?void 0:s.max_budget)||null);(0,r.useEffect)(()=>{(async()=>{if("Admin"===n)try{let e=await x(a);i(e.spend),d(e.max_budget||null)}catch(e){console.error("Error fetching global spend data:",e)}})()},[n,a]);let h=void 0!==o?o.toFixed(4):null;return(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(M.Z,{className:"mx-auto mb-4",children:[(0,l.jsxs)(es.Z,{children:["$",h]}),(0,l.jsxs)(D.Z,{children:["/ ",null!==c?"$".concat(c," limit"):"No limit"]})]})})},ea=s(36083),eo=s(68967),ei=s(27166),ec=e=>{let{teams:t,setSelectedTeam:s}=e,{Title:n,Paragraph:a}=ea.default,[o,i]=(0,r.useState)("");return(0,l.jsxs)("div",{className:"mt-10",children:[(0,l.jsx)(n,{level:4,children:"Default Team"}),(0,l.jsx)(a,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),t&&t.length>0?(0,l.jsx)(eo.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(ei.Z,{value:String(t),onClick:()=>s(e),children:e.team_alias},t))}):(0,l.jsxs)(a,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]})},ed=s(37963);console.log("isLocal:",!1);var eh=e=>{let{userID:t,userRole:s,teams:a,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:h,setKeys:m}=e,[p,j]=(0,r.useState)(null),g=(0,n.useSearchParams)();g.get("viewSpend"),(0,n.useRouter)();let w=g.get("token"),[Z,f]=(0,r.useState)(null),[k,_]=(0,r.useState)([]),[b,v]=(0,r.useState)(a?a[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(w){let e=(0,ed.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),f(e.key),e.user_role){let t=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:",t),i(t)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(t&&Z&&s&&!o&&!p){let e=sessionStorage.getItem("userModels"+t);e?_(JSON.parse(e)):(async()=>{try{let e=await u(Z,t,s);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await x(Z);j(e),console.log("globalSpend:",e)}else j(e.user_info);m(e.keys),h(e.teams),v(e.teams?e.teams[0]:null),sessionStorage.setItem("userData"+t,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+t,JSON.stringify(e.user_info));let l=(await y(Z,t,s)).data.map(e=>e.id);console.log("available_model_names:",l),_(l),console.log("userModels:",k),sessionStorage.setItem("userModels"+t,JSON.stringify(l))}catch(e){console.error("There was an error fetching the data",e)}})()}},[t,w,Z,o,s]),null==t||null==w){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==Z)return null;if(null==s&&i("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:t}=ea.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to create keys"})]})}return(0,l.jsx)("div",{children:(0,l.jsx)(O.Z,{numItems:1,className:"gap-0 p-10 h-[75vh] w-full",children:(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(en,{userID:t,userSpendData:p,userRole:s,accessToken:Z}),(0,l.jsx)(er,{userID:t,accessToken:Z,data:o,setData:m}),(0,l.jsx)(q,{userID:t,teamID:b?b.team_id:null,userRole:s,userModels:k,accessToken:Z,data:o,setData:m}),(0,l.jsx)(ec,{teams:a,setSelectedTeam:v})]})})})},em=s(5);let{Option:eu}=U.default;var ex=e=>{let{userModels:t,accessToken:s,userID:n}=e,[a]=L.Z.useForm(),[i,d]=(0,r.useState)(!1),h=async e=>{try{c.ZP.info("Requesting access");let{selectedModel:t,accessReason:l}=e;await S(s,t,n,l),d(!0)}catch(e){console.error("Error requesting access:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{size:"xs",onClick:()=>d(!0),children:"Request Access"}),(0,l.jsx)(B.Z,{title:"Request Access",visible:i,width:800,footer:null,onOk:()=>{d(!1),a.resetFields()},onCancel:()=>{d(!1),a.resetFields()},children:(0,l.jsxs)(L.Z,{form:a,onFinish:h,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(L.Z.Item,{label:"Select Model",name:"selectedModel",children:(0,l.jsx)(U.default,{placeholder:"Select model",style:{width:"100%"},children:t.map(e=>(0,l.jsx)(eu,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Reason for Access",name:"accessReason",children:(0,l.jsx)(z.Z.TextArea,{rows:4,placeholder:"Enter reason for access"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(o.Z,{children:"Request Access"})})]})})]})},ep=e=>{let{accessToken:t,token:s,userRole:n,userID:a}=e,[o,i]=(0,r.useState)({data:[]}),[c,d]=(0,r.useState)([]),[h,m]=(0,r.useState)([]);if((0,r.useEffect)(()=>{if(!t||!s||!n||!a)return;let e=async()=>{try{let e=await p(t,a,n);console.log("Model data response:",e.data),i(e);let s=await j(t,a,n);if(console.log("Model metrics response:",s),d(s),"Admin"===n&&t){let e=await N(t);console.log("Pending Requests:",h),m(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&n&&a&&e()},[t,s,n,a]),!o||!t||!s||!n||!a)return(0,l.jsx)("div",{children:"Loading..."});let u=[];for(let e=0;e(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:(0,l.jsx)(D.Z,{children:e.model_name})}),(0,l.jsx)(Y.Z,{children:e.provider}),"Admin"===n&&(0,l.jsx)(Y.Z,{children:e.api_base}),(0,l.jsx)(Y.Z,{children:e.user_access?(0,l.jsx)(em.Z,{color:"green",children:"Yes"}):(0,l.jsx)(ex,{userModels:u,accessToken:t,userID:a})}),(0,l.jsx)(Y.Z,{children:e.input_cost}),(0,l.jsx)(Y.Z,{children:e.output_cost}),(0,l.jsx)(Y.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Model Statistics (Number Requests)"}),(0,l.jsx)(et.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Model Statistics (Latency)"}),(0,l.jsx)(et.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})})},ej=s(92836),ey=s(26734),eg=s(41608),ew=s(32126),eZ=s(23682);let{Option:ef}=U.default;var ek=e=>{let{userID:t,accessToken:s}=e,[n]=L.Z.useForm(),[a,i]=(0,r.useState)(!1),[d,m]=(0,r.useState)(null),[u,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await y(s,t,"any"),l=[];for(let t=0;t{i(!1),n.resetFields()},j=()=>{i(!1),m(null),n.resetFields()},g=async e=>{try{c.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let l=await h(s,t,e);console.log("user create Response:",l),m(l.key),c.ZP.success("API user Created"),n.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the user:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(o.Z,{className:"mx-auto",onClick:()=>i(!0),children:"+ Create New User"}),(0,l.jsx)(B.Z,{title:"Create User",visible:a,width:800,footer:null,onOk:p,onCancel:j,children:(0,l.jsxs)(L.Z,{form:n,onFinish:g,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(L.Z.Item,{label:"User ID",name:"user_id",children:(0,l.jsx)(z.Z,{placeholder:"Enter User ID"})}),(0,l.jsx)(L.Z.Item,{label:"Team ID",name:"team_id",children:(0,l.jsx)(z.Z,{placeholder:"ai_team"})}),(0,l.jsx)(L.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(U.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:u.map(e=>(0,l.jsx)(ef,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(K.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(z.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Create User"})})]})}),d&&(0,l.jsxs)(B.Z,{title:"Save Your User",visible:a,onOk:p,onCancel:j,footer:null,children:[(0,l.jsxs)("p",{children:["Please save this secret user somewhere safe and accessible. For security reasons, ",(0,l.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret user, you will need to generate a new one."]}),(0,l.jsx)("p",{children:null!=d?"API user: ".concat(d):"User being created, this might take 30s"})]})]})},e_=e=>{let{accessToken:t,token:s,keys:n,userRole:a,userID:o,setKeys:i}=e,[c,d]=(0,r.useState)(null),[h,m]=(0,r.useState)(null),[x,p]=(0,r.useState)(1);if((0,r.useEffect)(()=>{if(!t||!s||!a||!o)return;let e=async()=>{try{let e=await u(t,null,a,!0);console.log("user data response:",e),d(e)}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&a&&o&&!c&&e();let l=async()=>{try{let e=await _(t,null);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};a&&("Admin"==a||"Admin Viewer"==a)&&!h&&l()},[t,s,a,o]),!c||!t||!s||!a||!o)return(0,l.jsx)("div",{children:"Loading..."});let j=async e=>{try{let s=await _(t,e);console.log("user data response:",s),m(s)}catch(e){console.error("There was an error fetching the model data",e)}};return(0,l.jsx)("div",{style:{width:"100%"},children:(0,l.jsxs)(O.Z,{className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(ek,{userID:o,accessToken:t}),(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{variant:"line",defaultValue:"1",children:[(0,l.jsx)(ej.Z,{value:"1",children:"Key Owners"}),(0,l.jsx)(ej.Z,{value:"2",children:"End-Users"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsx)(ew.Z,{children:(0,l.jsxs)($.Z,{className:"mt-5",children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"User ID"}),(0,l.jsx)(Q.Z,{children:"User Role"}),(0,l.jsx)(Q.Z,{children:"User Models"}),(0,l.jsx)(Q.Z,{children:"User Spend ($ USD)"}),(0,l.jsx)(Q.Z,{children:"User Max Budget ($ USD)"})]})}),(0,l.jsx)(H.Z,{children:c.map(e=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.user_id}),(0,l.jsx)(Y.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,l.jsx)(Y.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,l.jsx)(Y.Z,{children:e.spend?e.spend:0}),(0,l.jsx)(Y.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,l.jsxs)(ew.Z,{children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("div",{className:"flex-1"}),(0,l.jsxs)("div",{className:"flex-1 flex justify-between items-center",children:[(0,l.jsx)(R.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,l.jsx)(eo.Z,{defaultValue:"1",className:"w-3/4",children:null==n?void 0:n.map((e,t)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,l.jsx)(ei.Z,{value:String(t),onClick:()=>j(e.token),children:e.key_name},t)})})]})]}),(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"End User"}),(0,l.jsx)(Q.Z,{children:"Spend"}),(0,l.jsx)(Q.Z,{children:"Total Events"})]})}),(0,l.jsx)(H.Z,{children:null==h?void 0:h.map((e,t)=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.end_user}),(0,l.jsx)(Y.Z,{children:e.total_spend}),(0,l.jsx)(Y.Z,{children:e.total_events})]},t))})]})]})]})]})}),function(){if(!c)return null;let e=Math.ceil(c.length/25),t=Math.min(25*x,c.length);return(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsxs)("div",{children:["Showing ",(x-1)*25+1," – ",t," of ",c.length]}),(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===x,onClick:()=>p(x-1),children:"← Prev"}),(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:x===e,onClick:()=>p(x+1),children:"Next →"})]})]})}()]})})},eb=s(8510),ev=e=>{let{teams:t,searchParams:s,accessToken:n,setTeams:a,userID:i,userRole:d}=e,[h]=L.Z.useForm(),[m]=L.Z.useForm(),{Title:u,Paragraph:x}=ea.default,[p,j]=(0,r.useState)(""),[g,w]=(0,r.useState)(t?t[0]:null),[Z,f]=(0,r.useState)(!1),[k,_]=(0,r.useState)(!1),[b,v]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===i||null===d)return;if(null!==n){let e=(await y(n,i,d)).data.map(e=>e.id);console.log("available_model_names:",e),v(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,i,d]);let S=async e=>{try{if(null!=n){let s=await C(n,e);null!==t?a([...t,s]):a([s]),console.log("response for team create call: ".concat(s)),c.ZP.success("Team created"),f(!1)}}catch(e){console.error("Error creating the key:",e),c.ZP.error("Error creating the team: "+e)}},N=async e=>{try{if(null!=n&&null!=t){c.ZP.info("Making API Call");let s={role:"user",user_email:e.user_email,user_id:e.user_id},l=await T(n,g.team_id,s);console.log("response for team create call: ".concat(l.data));let r=t.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(l.data.team_id)),e.team_id===l.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...t];e[r]=l.data,a(e),w(l.data)}_(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("received teams ".concat(t)),(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)(O.Z,{numItems:1,className:"gap-2 p-2 h-[75vh] w-full",children:[(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(u,{level:4,children:"All Teams"}),(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Team Name"}),(0,l.jsx)(Q.Z,{children:"Spend (USD)"}),(0,l.jsx)(Q.Z,{children:"Budget (USD)"}),(0,l.jsx)(Q.Z,{children:"TPM / RPM Limits"})]})}),(0,l.jsx)(H.Z,{children:t&&t.length>0?t.map(e=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.team_alias}),(0,l.jsx)(Y.Z,{children:e.spend}),(0,l.jsx)(Y.Z,{children:e.max_budget?e.max_budget:"No limit"}),(0,l.jsx)(Y.Z,{children:(0,l.jsxs)(R.Z,{children:["TPM Limit:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{})," RPM Limit:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsx)(Y.Z,{children:(0,l.jsx)(J.Z,{icon:eb.Z,size:"sm"})})]},e.team_id)):null})]})})]}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(o.Z,{className:"mx-auto",onClick:()=>f(!0),children:"+ Create New Team"}),(0,l.jsx)(B.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{f(!1),h.resetFields()},onCancel:()=>{f(!1),h.resetFields()},children:(0,l.jsxs)(L.Z,{form:h,onFinish:S,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Team Name",name:"team_alias",children:(0,l.jsx)(z.Z,{})}),(0,l.jsx)(L.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(U.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:b.map(e=>(0,l.jsx)(U.default.Option,{value:e,children:e},e))})}),(0,l.jsx)(L.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(K.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(L.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})}),(0,l.jsx)(L.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(K.Z,{step:1,width:400})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(u,{level:4,children:"Team Members"}),(0,l.jsx)(x,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),t&&t.length>0?(0,l.jsx)(eo.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(ei.Z,{value:String(t),onClick:()=>{w(e)},children:e.team_alias},t))}):(0,l.jsxs)(x,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Member Name"}),(0,l.jsx)(Q.Z,{children:"Role"}),(0,l.jsx)(Q.Z,{children:"Action"})]})}),(0,l.jsx)(H.Z,{children:g?g.members_with_roles.map((e,t)=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(Y.Z,{children:e.role}),(0,l.jsx)(Y.Z,{children:(0,l.jsx)(J.Z,{icon:eb.Z,size:"sm"})})]},t)):null})]})})}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(o.Z,{className:"mx-auto mb-5",onClick:()=>_(!0),children:"+ Add member"}),(0,l.jsx)(B.Z,{title:"Add member",visible:k,width:800,footer:null,onOk:()=>{_(!1),m.resetFields()},onCancel:()=>{_(!1),m.resetFields()},children:(0,l.jsxs)(L.Z,{form:h,onFinish:N,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(L.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eS=e=>{let{searchParams:t,accessToken:s}=e,[n]=L.Z.useForm(),[a]=L.Z.useForm(),{Title:i,Paragraph:d}=ea.default,[h,m]=(0,r.useState)(""),[u,x]=(0,r.useState)(null),[p,j]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{if(null!=s){let e=[],t=await A(s,"proxy_admin_viewer");t.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy viewers: ".concat(t));let l=await A(s,"proxy_admin");l.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy admins: ".concat(l)),console.log("combinedList: ".concat(e)),x(e)}})()},[s]);let y=async e=>{try{if(null!=s&&null!=u){c.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await I(s,e);console.log("response for team create call: ".concat(t));let l=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(t.user_id)),e.user_id===t.user_id));console.log("foundIndex: ".concat(l)),-1==l&&(console.log("updates admin with new user"),u.push(t),x(u)),j(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("admins: ".concat(null==u?void 0:u.length)),(0,l.jsxs)("div",{className:"w-full m-2",children:[(0,l.jsx)(i,{level:4,children:"Restricted Access"}),(0,l.jsxs)(d,{children:["Add other people to just view spend. They cannot create keys, teams or grant users access to new models."," ",(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"})]}),(0,l.jsxs)(O.Z,{numItems:1,className:"gap-2 p-0 w-full",children:[(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)($.Z,{children:[(0,l.jsx)(X.Z,{children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Q.Z,{children:"Member Name"}),(0,l.jsx)(Q.Z,{children:"Role"}),(0,l.jsx)(Q.Z,{children:"Action"})]})}),(0,l.jsx)(H.Z,{children:u?u.map((e,t)=>(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(Y.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(Y.Z,{children:e.user_role}),(0,l.jsx)(Y.Z,{children:(0,l.jsx)(J.Z,{icon:eb.Z,size:"sm"})})]},t)):null})]})})}),(0,l.jsxs)(F.Z,{numColSpan:1,children:[(0,l.jsx)(o.Z,{className:"mx-auto mb-5",onClick:()=>j(!0),children:"+ Add viewer"}),(0,l.jsx)(B.Z,{title:"Add viewer",visible:p,width:800,footer:null,onOk:()=>{j(!1),a.resetFields()},onCancel:()=>{j(!1),a.resetFields()},children:(0,l.jsxs)(L.Z,{form:n,onFinish:y,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(L.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(z.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(V.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})]})},eN=s(12968),eA=s(67951);async function eC(e,t,s,l){console.log("isLocal:",!1);let r=window.location.origin,n=new eN.ZP.OpenAI({apiKey:l,baseURL:r,dangerouslyAllowBrowser:!0});for await(let l of(await n.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(l),l.choices[0].delta.content&&t(l.choices[0].delta.content)}var eT=e=>{let{accessToken:t,token:s,userRole:n,userID:a}=e,[o,i]=(0,r.useState)(""),[c,d]=(0,r.useState)([]),[h,m]=(0,r.useState)(void 0),[u,x]=(0,r.useState)(null);(0,r.useEffect)(()=>{t&&s&&n&&a&&(async()=>{let e=await y(t,a,n);console.log("model_info:",e),(null==e?void 0:e.data.length)>0&&(x(e.data),m(e.data[0].id))})()},[t,a,n]);let p=(e,t)=>{d(s=>{let l=s[s.length-1];return l&&l.role===e?[...s.slice(0,s.length-1),{role:e,content:l.content+t}]:[...s,{role:e,content:t}]})},j=async()=>{if(""!==o.trim()&&t&&s&&n&&a){d(e=>[...e,{role:"user",content:o}]);try{h&&await eC(o,e=>p("assistant",e),h,t)}catch(e){console.error("Error fetching model response",e),p("assistant","Error fetching model response")}i("")}};if(n&&"Admin Viewer"==n){let{Title:e,Paragraph:t}=ea.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to test models"})]})}return(0,l.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,l.jsx)(O.Z,{className:"gap-2 p-10 h-[75vh] w-full",children:(0,l.jsx)(M.Z,{children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{className:"mt-4",children:[(0,l.jsx)(ej.Z,{children:"Chat"}),(0,l.jsx)(ej.Z,{children:"API Reference"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsxs)(ew.Z,{children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{children:"Select Model:"}),(0,l.jsx)("select",{value:h||"",onChange:e=>m(e.target.value),children:null==u?void 0:u.map(e=>(0,l.jsx)("option",{value:e.id,children:e.id},e.id))})]}),(0,l.jsxs)($.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,l.jsx)(X.Z,{children:(0,l.jsx)(ee.Z,{children:(0,l.jsx)(Y.Z,{children:(0,l.jsx)(D.Z,{children:"Chat"})})})}),(0,l.jsx)(H.Z,{children:c.map((e,t)=>(0,l.jsx)(ee.Z,{children:(0,l.jsx)(Y.Z,{children:"".concat(e.role,": ").concat(e.content)})},t))})]}),(0,l.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("input",{type:"text",value:o,onChange:e=>i(e.target.value),className:"flex-1 p-2 border rounded-md mr-2",placeholder:"Type your message..."}),(0,l.jsx)("button",{onClick:j,className:"p-2 bg-blue-500 text-white rounded-md",children:"Send"})]})})]}),(0,l.jsx)(ew.Z,{children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{children:[(0,l.jsx)(ej.Z,{children:"OpenAI Python SDK"}),(0,l.jsx)(ej.Z,{children:"LlamaIndex"}),(0,l.jsx)(ej.Z,{children:"Langchain Py"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsx)(ew.Z,{children:(0,l.jsx)(eA.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # proxy base url\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to use from Models Tab\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ],\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-openai-client",\n "generation_id": "openai-client-gen-id22",\n "trace_id": "openai-client-trace-id22",\n "trace_user_id": "openai-client-user-id2"\n }\n }\n)\n\nprint(response)\n '})}),(0,l.jsx)(ew.Z,{children:(0,l.jsx)(eA.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="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,l.jsx)(ew.Z,{children:(0,l.jsx)(eA.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:8000",\n model = "gpt-3.5-turbo",\n temperature=0.1,\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-langchain-client",\n "generation_id": "langchain-client-gen-id22",\n "trace_id": "langchain-client-trace-id22",\n "trace_user_id": "langchain-client-user-id2"\n }\n }\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 '})})]})]})})]})]})})})})},eI=s(33509),eE=s(30569);let{Sider:eP}=eI.default;var eF=e=>{let{setPage:t,userRole:s,defaultSelectedKey:r}=e;return"Admin Viewer"==s?(0,l.jsx)(eI.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,l.jsx)(eP,{width:120,children:(0,l.jsxs)(eE.Z,{mode:"inline",defaultSelectedKeys:r||["4"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eE.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"4"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"1")]})})}):(0,l.jsx)(eI.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,l.jsx)(eP,{width:120,children:(0,l.jsxs)(eE.Z,{mode:"inline",defaultSelectedKeys:r||["1"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eE.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"1"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,l.jsx)(eE.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"4"),"Admin"==s?(0,l.jsx)(eE.Z.Item,{onClick:()=>t("users"),children:"Users"},"5"):null,"Admin"==s?(0,l.jsx)(eE.Z.Item,{onClick:()=>t("teams"),children:"Teams"},"6"):null,"Admin"==s?(0,l.jsx)(eE.Z.Item,{onClick:()=>t("admin-panel"),children:"Admin"},"7"):null]})})})},eO=e=>{let{accessToken:t,token:s,userRole:n,userID:a}=e,o=new Date,[i,c]=(0,r.useState)([]),[d,h]=(0,r.useState)([]),[m,u]=(0,r.useState)([]),[x,p]=(0,r.useState)([]),[j,y]=(0,r.useState)([]),[g,_]=(0,r.useState)([]),[S,N]=(0,r.useState)([]),A=new Date(o.getFullYear(),o.getMonth(),1),C=new Date(o.getFullYear(),o.getMonth()+1,0),T=E(A),I=E(C);function E(e){let t=e.getFullYear(),s=e.getMonth()+1,l=e.getDate();return"".concat(t,"-").concat(s<10?"0"+s:s,"-").concat(l<10?"0"+l:l)}return console.log("Start date is ".concat(T)),console.log("End date is ".concat(I)),(0,r.useEffect)(()=>{t&&s&&n&&a&&(async()=>{try{if(console.log("user role: ".concat(n)),"Admin"==n||"Admin Viewer"==n){let e=await f(t);c(e);let s=(await k(t)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,7),spend:e.total_spend}));h(s);let l=(await b(t)).map(e=>({key:e.model,spend:e.total_spend}));u(l);let r=await w(t);console.log("teamSpend",r),y(r.daily_spend),_(r.teams),N(r.total_spend_per_team)}else"App Owner"==n&&await Z(t,s,n,a,T,I).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let t=e.daily_spend;console.log("daily spend",t),c(t);let s=e.top_api_keys;h(s)}else{let s=(await v(t,function(e){let t=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,l]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&t.push({key:s,spend:l})})}),t.sort((e,t)=>Number(t.spend)-Number(e.spend));let s=t.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||e.token).substring(0,7),spend:e.spend}));h(s),p(function(e){let t={};e.forEach(e=>{Object.entries(e.users).forEach(e=>{let[s,l]=e;""!==s&&null!=s&&"None"!=s&&(t[s]||(t[s]=0),t[s]+=l)})});let s=Object.entries(t).map(e=>{let[t,s]=e;return{user_id:t,spend:s}});s.sort((e,t)=>t.spend-e.spend);let l=s.slice(0,5);return console.log("topKeys: ".concat(Object.values(l[0]))),l}(e)),c(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[t,s,n,a,T,I]),(0,l.jsx)("div",{style:{width:"100%"},children:(0,l.jsxs)(ey.Z,{children:[(0,l.jsxs)(eg.Z,{className:"mt-4",children:[(0,l.jsx)(ej.Z,{children:"All Up"}),(0,l.jsx)(ej.Z,{children:"Team Based Usage"})]}),(0,l.jsxs)(eZ.Z,{children:[(0,l.jsx)(ew.Z,{children:(0,l.jsxs)(O.Z,{numItems:2,className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(F.Z,{numColSpan:2,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Monthly Spend"}),(0,l.jsx)(et.Z,{data:i,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Top API Keys"}),(0,l.jsx)(et.Z,{className:"mt-4 h-40",data:d,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Top Users"}),(0,l.jsx)(et.Z,{className:"mt-4 h-40",data:x,index:"user_id",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(F.Z,{numColSpan:1,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Top Models"}),(0,l.jsx)(et.Z,{className:"mt-4 h-40",data:m,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,l.jsx)(ew.Z,{children:(0,l.jsxs)(O.Z,{numItems:2,className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(F.Z,{numColSpan:2,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Daily Spend Per Team"}),(0,l.jsx)(et.Z,{className:"h-72",data:j,index:"date",categories:g,yAxisWidth:30,stack:!0})]})}),(0,l.jsx)(F.Z,{numColSpan:2,children:(0,l.jsxs)(M.Z,{children:[(0,l.jsx)(D.Z,{children:"Total Spend Per Team"}),(0,l.jsx)(et.Z,{className:"h-72",data:S,index:"team_id",categories:["total_spend"],yAxisWidth:30})]})})]})})]})]})})},eM=()=>{let{Title:e,Paragraph:t}=ea.default,[s,a]=(0,r.useState)(""),[o,c]=(0,r.useState)(null),[d,h]=(0,r.useState)(null),[m,u]=(0,r.useState)(null),[x,p]=(0,r.useState)(!0),j=(0,n.useSearchParams)(),y=j.get("userID"),g=j.get("token"),[w,Z]=(0,r.useState)("api-keys"),[f,k]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(g){let e=(0,ed.o)(g);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),k(e.key),e.user_role){let t=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:",t),a(t),"Admin Viewer"==t&&Z("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?p("username_password"==e.login_method):console.log("User Email is not set ".concat(e))}}},[g]),(0,l.jsx)(r.Suspense,{fallback:(0,l.jsx)("div",{children:"Loading..."}),children:(0,l.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,l.jsx)(i,{userID:y,userRole:s,userEmail:o,showSSOBanner:x}),(0,l.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,l.jsx)(eF,{setPage:Z,userRole:s,defaultSelectedKey:null}),"api-keys"==w?(0,l.jsx)(eh,{userID:y,userRole:s,teams:d,keys:m,setUserRole:a,userEmail:o,setUserEmail:c,setTeams:h,setKeys:u}):"models"==w?(0,l.jsx)(ep,{userID:y,userRole:s,token:g,accessToken:f}):"llm-playground"==w?(0,l.jsx)(eT,{userID:y,userRole:s,token:g,accessToken:f}):"users"==w?(0,l.jsx)(e_,{userID:y,userRole:s,token:g,keys:m,accessToken:f,setKeys:u}):"teams"==w?(0,l.jsx)(ev,{teams:d,setTeams:h,searchParams:j,accessToken:f,userID:y,userRole:s}):"admin-panel"==w?(0,l.jsx)(eS,{setTeams:h,searchParams:j,accessToken:f}):(0,l.jsx)(eO,{userID:y,userRole:s,token:g,accessToken:f})]})]})})}}},function(e){e.O(0,[730,971,69,744],function(){return e(e.s=79615)}),_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 4e934e447..b138e2de3 100644
--- a/litellm/proxy/_experimental/out/index.html
+++ b/litellm/proxy/_experimental/out/index.html
@@ -1 +1 @@
-🚅 LiteLLM
\ No newline at end of file
+🚅 LiteLLM
\ No newline at end of file
diff --git a/litellm/proxy/_experimental/out/index.txt b/litellm/proxy/_experimental/out/index.txt
index db1aebdd9..d70e09bac 100644
--- a/litellm/proxy/_experimental/out/index.txt
+++ b/litellm/proxy/_experimental/out/index.txt
@@ -1,7 +1,7 @@
2:I[77831,[],""]
-3:I[19914,["730","static/chunks/730-1411b729a1c79695.js","931","static/chunks/app/page-23f3f2a4358844b5.js"],""]
+3:I[19914,["730","static/chunks/730-1411b729a1c79695.js","931","static/chunks/app/page-144687b251040a22.js"],""]
4:I[5613,[],""]
5:I[31778,[],""]
-0:["SgfgYknNTPjX1zfkhqLYs",[[["",{"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/68a21c6e6697f7ca.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
+0:["aIO8mtlEIEUTmgL8cGjve",[[["",{"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/68a21c6e6697f7ca.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"}],["$","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 88df94fcf..423a55d1f 100644
--- a/ui/litellm-dashboard/out/404.html
+++ b/ui/litellm-dashboard/out/404.html
@@ -1 +1 @@
-404: This page could not be found.🚅 LiteLLM404
This page could not be found.
\ No newline at end of file
+404: This page could not be found.🚅 LiteLLM404
This page could not be found.
\ No newline at end of file
diff --git a/ui/litellm-dashboard/out/index.html b/ui/litellm-dashboard/out/index.html
index 4e934e447..b138e2de3 100644
--- a/ui/litellm-dashboard/out/index.html
+++ b/ui/litellm-dashboard/out/index.html
@@ -1 +1 @@
-🚅 LiteLLM
\ No newline at end of file
+🚅 LiteLLM
\ No newline at end of file
diff --git a/ui/litellm-dashboard/out/index.txt b/ui/litellm-dashboard/out/index.txt
index db1aebdd9..d70e09bac 100644
--- a/ui/litellm-dashboard/out/index.txt
+++ b/ui/litellm-dashboard/out/index.txt
@@ -1,7 +1,7 @@
2:I[77831,[],""]
-3:I[19914,["730","static/chunks/730-1411b729a1c79695.js","931","static/chunks/app/page-23f3f2a4358844b5.js"],""]
+3:I[19914,["730","static/chunks/730-1411b729a1c79695.js","931","static/chunks/app/page-144687b251040a22.js"],""]
4:I[5613,[],""]
5:I[31778,[],""]
-0:["SgfgYknNTPjX1zfkhqLYs",[[["",{"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/68a21c6e6697f7ca.css","precedence":"next","crossOrigin":""}]],"$L6"]]]]
+0:["aIO8mtlEIEUTmgL8cGjve",[[["",{"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/68a21c6e6697f7ca.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"}],["$","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/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx
index f9524e5cc..23920df10 100644
--- a/ui/litellm-dashboard/src/components/networking.tsx
+++ b/ui/litellm-dashboard/src/components/networking.tsx
@@ -174,7 +174,7 @@ export const userInfoCall = async (
try {
let url = proxyBaseUrl ? `${proxyBaseUrl}/user/info` : `/user/info`;
if (userRole == "App Owner" && userID) {
- url = `${url}/?user_id=${userID}`;
+ url = `${url}?user_id=${userID}`;
}
console.log("in userInfoCall viewAll=", viewAll);
if (viewAll) {
@@ -353,7 +353,7 @@ export const keySpendLogsCall = async (accessToken: String, token: String) => {
? `${proxyBaseUrl}/global/spend/logs`
: `/global/spend/logs`;
console.log("in keySpendLogsCall:", url);
- const response = await fetch(`${url}/?api_key=${token}`, {
+ const response = await fetch(`${url}?api_key=${token}`, {
method: "GET",
headers: {
Authorization: `Bearer ${accessToken}`,
@@ -416,9 +416,9 @@ export const userSpendLogsCall = async (
console.log(`user role in spend logs call: ${userRole}`);
let url = proxyBaseUrl ? `${proxyBaseUrl}/spend/logs` : `/spend/logs`;
if (userRole == "App Owner") {
- url = `${url}/?user_id=${userID}&start_date=${startTime}&end_date=${endTime}`;
+ url = `${url}?user_id=${userID}&start_date=${startTime}&end_date=${endTime}`;
} else {
- url = `${url}/?start_date=${startTime}&end_date=${endTime}`;
+ url = `${url}?start_date=${startTime}&end_date=${endTime}`;
}
//message.info("Making spend logs request");
const response = await fetch(url, {
@@ -620,7 +620,7 @@ export const spendUsersCall = async (accessToken: String, userID: String) => {
try {
const url = proxyBaseUrl ? `${proxyBaseUrl}/spend/users` : `/spend/users`;
console.log("in spendUsersCall:", url);
- const response = await fetch(`${url}/?user_id=${userID}`, {
+ const response = await fetch(`${url}?user_id=${userID}`, {
method: "GET",
headers: {
Authorization: `Bearer ${accessToken}`,