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