diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html index 33d640a28..8c80c9bc8 100644 --- a/litellm/proxy/_experimental/out/404.html +++ b/litellm/proxy/_experimental/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/9QubL0PO5JZ-hNit5iXPw/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/KnyD0lgLk9_a0erHwSSu-/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/9QubL0PO5JZ-hNit5iXPw/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/KnyD0lgLk9_a0erHwSSu-/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/9QubL0PO5JZ-hNit5iXPw/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/KnyD0lgLk9_a0erHwSSu-/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/9QubL0PO5JZ-hNit5iXPw/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/KnyD0lgLk9_a0erHwSSu-/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-a485c9c659128852.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-a485c9c659128852.js new file mode 100644 index 000000000..940987415 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-a485c9c659128852.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{79615:function(e,t,l){Promise.resolve().then(l.bind(l,46502))},46502:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return eX}});var s=l(3827),a=l(64090),r=l(47907),n=l(8792),o=l(40491),i=l(65270),c=e=>{let{userID:t,userRole:l,userEmail:a,showSSOBanner:r}=e;console.log("User ID:",t),console.log("userEmail:",a);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:[r?(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:a})})})]})]})},d=l(80588);let m=async(e,t)=>{try{let l=await fetch("/model/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),d.ZP.success("Model created successfully. Wait 60s and refresh."),s}catch(e){throw console.error("Failed to create key:",e),e}},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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},u=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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},x=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}},p=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let l=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to delete team: "+e),Error("Network response was not ok")}let s=await l.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},j=async function(e,t,l){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4?arguments[4]:void 0,r=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==l&&t&&(n="".concat(n,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",s),s&&a&&r&&(n="".concat(n,"?view_all=true&page=").concat(a,"&page_size=").concat(r));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw d.ZP.error(e),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},g=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}},y=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}},Z=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}},f=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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=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}},k=async e=>{try{let t="/global/spend/tags";console.log("in tagsSpendLogsCall:",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}},_=async(e,t,l,s,a,r)=>{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(a,"&end_date=").concat(r):"".concat(t,"?start_date=").concat(a,"&end_date=").concat(r);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}},v=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}},S=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}},N=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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},A=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}},T=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}},C=async(e,t,l,s)=>{try{let a=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(!a.ok){let e=await a.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},I=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}},P=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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to get requested models:",e),e}},E=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}},F=async(e,t)=>{try{console.log("Form Values in keyUpdateCall:",t);let l=await fetch("/key/update",{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 update key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await l.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let l=await fetch("/team/update",{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 update team: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await l.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=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}},D=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}};var U=l(10384),z=l(46453),B=l(2179),q=l(71801),L=l(42440),K=l(42308),V=l(50670),G=l(81583),J=l(77171),W=l(42539),Y=l(88707),$=l(1861);let{Option:H}=V.default;var X=e=>{let{userID:t,team:l,userRole:r,accessToken:n,data:o,setData:i}=e,[c]=G.Z.useForm(),[m,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)(null),[j,g]=(0,a.useState)(null),[y,Z]=(0,a.useState)([]),w=()=>{u(!1),c.resetFields()},b=()=>{u(!1),p(null),c.resetFields()};(0,a.useEffect)(()=>{(async()=>{try{if(null===t||null===r)return;if(null!==n){let e=(await f(n,t,r)).data.map(e=>e.id);console.log("available_model_names:",e),Z(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,t,r]);let k=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)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,s.jsx)(J.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:w,onCancel:b,children:(0,s.jsxs)(G.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===r||"Admin"===r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,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)(G.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(H,{value:"all-team-models",children:"All Team Models"},"all-team-models"),l&&l.models?l.models.includes("all-proxy-models")?y.map(e=>(0,s.jsx)(H,{value:e,children:e},e)):l.models.map(e=>(0,s.jsx)(H,{value:e,children:e},e)):y.map(e=>(0,s.jsx)(H,{value:e,children:e},e))]})}),(0,s.jsx)(G.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)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.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)(V.default,{defaultValue:null,placeholder:"n/a",children:[(0,s.jsx)(V.default.Option,{value:"24h",children:"daily"}),(0,s.jsx)(V.default.Option,{value:"30d",children:"monthly"})]})}),(0,s.jsx)(G.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)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.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)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,s.jsx)(W.Z,{})}),(0,s.jsx)(G.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)(G.Z.Item,{label:"Key Name",name:"key_alias",children:(0,s.jsx)(W.Z,{})}),(0,s.jsx)(G.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)(G.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)($.ZP,{htmlType:"submit",children:"Create Key"})})]})}),x&&(0,s.jsx)(J.Z,{visible:m,onOk:w,onCancel:b,footer:null,children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 w-full",children:[(0,s.jsx)(L.Z,{children:"Save your Key"}),(0,s.jsx)(U.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)(U.Z,{numColSpan:1,children:null!=x?(0,s.jsxs)("div",{children:[(0,s.jsx)(q.Z,{className:"mt-3",children:"API Key:"}),(0,s.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,s.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:x})}),(0,s.jsx)(K.CopyToClipboard,{text:x,onCopy:()=>{d.ZP.success("API Key copied to clipboard")},children:(0,s.jsx)(B.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,s.jsx)(q.Z,{children:"Key being created, this might take 30s"})})]})})]})},Q=l(9454),ee=l(98941),et=l(33393),el=l(5),es=l(9853),ea=l(13810),er=l(39290),en=l(66952),eo=l(61244),ei=l(10827),ec=l(3851),ed=l(2044),em=l(64167),eh=l(74480),eu=l(7178);let{Option:ex}=V.default;var ep=e=>{let{userID:t,userRole:l,accessToken:r,selectedTeam:n,data:o,setData:i}=e,[c,m]=(0,a.useState)(!1),[h,u]=(0,a.useState)(!1),[p,j]=(0,a.useState)(null),[g,y]=a.useState(null),[Z,b]=(0,a.useState)(null),[k,_]=(0,a.useState)(null),[v,S]=(0,a.useState)(""),[N,A]=(0,a.useState)(!1),[T,C]=(0,a.useState)(null),[I,P]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{if(null===t)return;if(null!==r&&null!==l){let e=(await f(r,t,l)).data.map(e=>e.id);console.log("available_model_names:",e),P(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,t,l]);let E=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),C(e),A(!0)},M=async e=>{if(null==r)return;let t=e.token;e.key=t,console.log("handleEditSubmit:",e);let l=await F(r,e);console.log("handleEditSubmit: newKeyValues",l),o&&i(o.map(e=>e.token===t?l:e)),d.ZP.success("Key updated successfully"),A(!1),C(null)},O=async e=>{try{if(null==r||null==e)return;console.log("accessToken: ".concat(r,"; token: ").concat(e.token));let t=await w(r,e.token);console.log("Response:",t),_(t);try{let e=await D(r,t);console.log("Response2:",e);let l=[...t,...e.response];_(l),S(e.predicted_spend),console.log("Combined Data:",l)}catch(e){console.error("There was an error fetching the predicted data",e)}}catch(e){console.error("There was an error fetching the data",e)}};(0,a.useEffect)(()=>{O(Z)},[Z]);let R=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+t),u(!0))},U=async()=>{if(null!=p&&null!=o){try{await x(r,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}u(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,s.jsxs)("div",{children:[(0,s.jsxs)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,s.jsxs)(ei.Z,{className:"mt-5",children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Key Alias"}),(0,s.jsx)(eh.Z,{children:"Secret Key"}),(0,s.jsx)(eh.Z,{children:"Spend (USD)"}),(0,s.jsx)(eh.Z,{children:"Budget (USD)"}),(0,s.jsx)(eh.Z,{children:"Models"}),(0,s.jsx)(eh.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ec.Z,{children:o.map(e=>(console.log(e),"litellm-dashboard"===e.team_id||n&&e.team_id!=n.team_id)?null:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,s.jsx)(q.Z,{children:e.key_alias}):(0,s.jsx)(q.Z,{children:"Not Set"})}),(0,s.jsx)(ed.Z,{children:(0,s.jsx)(q.Z,{children:e.key_name})}),(0,s.jsx)(ed.Z,{children:(0,s.jsx)(q.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(t){return e.spend}})()})}),(0,s.jsx)(ed.Z,{children:null!=e.max_budget?(0,s.jsx)(q.Z,{children:e.max_budget}):(0,s.jsx)(q.Z,{children:"Unlimited"})}),(0,s.jsx)(ed.Z,{children:Array.isArray(e.models)?(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,s.jsx)(s.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,t)=>"all-proxy-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})},t):"all-team-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Team Models"})},t):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t)):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:"all-proxy-models"})})}):e.models.map((e,t)=>"all-proxy-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})},t):"all-team-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Team Models"})},t):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,s.jsx)(ed.Z,{children:(0,s.jsxs)(q.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(ed.Z,{children:[(0,s.jsx)(eo.Z,{onClick:()=>{b(e),y(e.id)},icon:Q.Z,size:"sm"}),(0,s.jsx)(er.Z,{open:null!==g,onClose:()=>{y(null),b(null)},children:(0,s.jsx)(en.Z,{children:Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3",children:[(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(Z.spend).toFixed(4)}catch(e){return Z.spend}})()})})]}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.max_budget?(0,s.jsx)(s.Fragment,{children:Z.max_budget}):(0,s.jsx)(s.Fragment,{children:"Unlimited"})})})]},e.name),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.expires?(0,s.jsx)(s.Fragment,{children:new Date(Z.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,s.jsx)(s.Fragment,{children:"Never"})})})]},e.name)]}),(0,s.jsx)(ea.Z,{className:"mt-6 mb-6",children:k&&(0,s.jsx)(es.Z,{className:"mt-6",data:k,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})}),(0,s.jsx)(L.Z,{children:"Metadata"}),(0,s.jsx)(q.Z,{children:JSON.stringify(Z.metadata)}),(0,s.jsx)(B.Z,{variant:"light",className:"mx-auto flex items-center",onClick:()=>{y(null),b(null)},children:"Close"})]})})}),(0,s.jsx)(eo.Z,{icon:ee.Z,size:"sm",onClick:()=>E(e)}),(0,s.jsx)(eo.Z,{onClick:()=>R(e),icon:et.Z,size:"sm"})]})]},e.token))})]}),h&&(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)(B.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{u(!1),j(null)},children:"Cancel"})]})]})]})})]}),T&&(0,s.jsx)(e=>{let{visible:t,onCancel:l,token:a,onSubmit:r}=e,[o]=G.Z.useForm();return console.log("in edit key modal:",a),console.log("in edit key modal, team:",n),(0,s.jsx)(J.Z,{title:"Edit Key",visible:t,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:l,children:(0,s.jsxs)(G.Z,{form:o,onFinish:M,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(ex,{value:"all-team-models",children:"All Team Models"},"all-team-models"),n&&n.models?n.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,s.jsx)(ex,{value:e,children:e},e)):n.models.map(e=>(0,s.jsx)(ex,{value:e,children:e},e)):I.map(e=>(0,s.jsx)(ex,{value:e,children:e},e))]})}),(0,s.jsx)(G.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==n?void 0:n.max_budget)!==null&&(null==n?void 0:n.max_budget)!==void 0?null==n?void 0:n.max_budget:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&n&&null!==n.max_budget&&t>n.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(n.max_budget))}}],children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"token",name:"token",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:N,onCancel:()=>{A(!1),C(null)},token:T,onSubmit:M})]})},ej=e=>{let{userID:t,userRole:l,accessToken:r}=e,[n,o]=(0,a.useState)(0),[i,c]=(0,a.useState)(0);(0,a.useEffect)(()=>{(async()=>{if(r&&t&&l&&"Admin"===l)try{let e=await g(r);e&&(e.spend?o(e.spend):o(0),e.max_budget?c(e.max_budget):c(0))}catch(e){console.error("Error fetching global spend data:",e)}})()},[l,r]);let d=void 0!==n?n.toFixed(5):null;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend (across all teams)"}),(0,s.jsxs)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",d]})]})},eg=l(55901),ey=l(27166),eZ=e=>{let{teams:t,setSelectedTeam:l}=e,r={models:[],team_id:null,team_alias:"Default Team"},[n,o]=(0,a.useState)(r),i=t?[...t,r]:[r];return(0,s.jsxs)("div",{className:"mt-5 mb-5",children:[(0,s.jsx)(L.Z,{children:"Select Team"}),(0,s.jsx)(q.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,s.jsxs)(q.Z,{className:"mt-3 mb-3",children:[(0,s.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),i&&i.length>0?(0,s.jsx)(eg.Z,{defaultValue:"0",children:i.map((e,t)=>(0,s.jsx)(ey.Z,{value:String(t),onClick:()=>l(e),children:e.team_alias},t))}):(0,s.jsxs)(q.Z,{children:["No team created. ",(0,s.jsx)("b",{children:"Defaulting to personal account."})]})]})},ef=l(37963),ew=l(36083);console.log("isLocal:",!1);var eb=e=>{let{userID:t,userRole:l,teams:n,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,a.useState)(null),p=(0,r.useSearchParams)();p.get("viewSpend"),(0,r.useRouter)();let y=p.get("token"),[Z,w]=(0,a.useState)(null),[b,k]=(0,a.useState)([]),[_,v]=(0,a.useState)(n?n[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,a.useEffect)(()=>{if(y){let e=(0,ef.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(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?k(JSON.parse(e)):(async()=>{try{let e=await j(Z,t,l,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==l){let e=await g(Z);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(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 f(Z,t,l)).data.map(e=>e.id);console.log("available_model_names:",s),k(s),console.log("userModels:",b),sessionStorage.setItem("userModels"+t,JSON.stringify(s))}catch(e){console.error("There was an error fetching the data",e)}})()}},[t,y,Z,o,l]),null==t||null==y){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}=ew.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",_),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsx)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(ej,{userID:t,userRole:l,accessToken:Z}),(0,s.jsx)(ep,{userID:t,userRole:l,accessToken:Z,selectedTeam:_||null,data:o,setData:h}),(0,s.jsx)(X,{userID:t,team:_||null,userRole:l,accessToken:Z,data:o,setData:h},_?_.team_id:null),(0,s.jsx)(eZ,{teams:n,setSelectedTeam:v})]})})})},ek=l(92836),e_=l(26734),ev=l(41608),eS=l(32126),eN=l(23682),eA=l(52273),eT=l(38302),eC=l(28683),eI=l(1460);let{Option:eP}=V.default;var eE=e=>{let{userModels:t,accessToken:l,userID:r}=e,[n]=G.Z.useForm(),[o,i]=(0,a.useState)(!1),c=async e=>{try{d.ZP.info("Requesting access");let{selectedModel:t,accessReason:s}=e;await C(l,t,r,s),i(!0)}catch(e){console.error("Error requesting access:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{size:"xs",onClick:()=>i(!0),children:"Request Access"}),(0,s.jsx)(J.Z,{title:"Request Access",visible:o,width:800,footer:null,onOk:()=>{i(!1),n.resetFields()},onCancel:()=>{i(!1),n.resetFields()},children:(0,s.jsxs)(G.Z,{form:n,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsx)(G.Z.Item,{label:"Select Model",name:"selectedModel",children:(0,s.jsx)(V.default,{placeholder:"Select model",style:{width:"100%"},children:t.map(e=>(0,s.jsx)(eP,{value:e,children:e},e))})}),(0,s.jsx)(G.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)(B.Z,{children:"Request Access"})})]})})]})};let{Title:eF,Link:eM}=ew.default;var eO=e=>{let{accessToken:t,token:l,userRole:r,userID:n}=e,[o,i]=(0,a.useState)({data:[]}),[c,d]=(0,a.useState)([]),[h,u]=(0,a.useState)([]),[x]=G.Z.useForm(),[p,j]=(0,a.useState)("OpenAI");if((0,a.useEffect)(()=>{if(!t||!l||!r||!n)return;let e=async()=>{try{let e=await y(t,n,r);console.log("Model data response:",e.data),i(e);let l=await Z(t,n,r);if(console.log("Model metrics response:",l),d(l),"Admin"===r&&t){let e=await I(t);console.log("Pending Requests:",h),u(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};t&&l&&r&&n&&e()},[t,l,r,n]),!o||!t||!l||!r||!n)return(0,s.jsx)("div",{children:"Loading..."});let g=[];for(let e=0;e{let l={},s={},a="";for(let[t,r]of Object.entries(e))"model_name"==t&&(a=r),("api_key"===t||"model"===t||"api_base"===t||"api_version"===t||t.startsWith("aws_"))&&(l[t]=r),"base_model"===t&&(s[t]=r);let r={model_name:a,litellm_params:l,model_info:s},n=await m(t,r);console.log("response for model create call: ".concat(n.data))};return console.log("selectedProvider: ".concat(p)),(0,s.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,s.jsxs)(e_.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(ev.Z,{className:"mt-2",children:[(0,s.jsx)(ek.Z,{children:"All Models"}),(0,s.jsx)(ek.Z,{children:"Add Model"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{children:[(0,s.jsx)(ea.Z,{children:(0,s.jsxs)(ei.Z,{className:"mt-5",children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Model Name "}),(0,s.jsx)(eh.Z,{children:"Provider"}),"Admin"===r&&(0,s.jsx)(eh.Z,{children:"API Base"}),(0,s.jsx)(eh.Z,{children:"Access"}),(0,s.jsx)(eh.Z,{children:"Input Price per token ($)"}),(0,s.jsx)(eh.Z,{children:"Output Price per token ($)"}),(0,s.jsx)(eh.Z,{children:"Max Tokens"})]})}),(0,s.jsx)(ec.Z,{children:o.data.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:(0,s.jsx)(q.Z,{children:e.model_name})}),(0,s.jsx)(ed.Z,{children:e.provider}),"Admin"===r&&(0,s.jsx)(ed.Z,{children:e.api_base}),(0,s.jsx)(ed.Z,{children:e.user_access?(0,s.jsx)(el.Z,{color:"green",children:"Yes"}):(0,s.jsx)(eE,{userModels:g,accessToken:t,userID:n})}),(0,s.jsx)(ed.Z,{children:e.input_cost}),(0,s.jsx)(ed.Z,{children:e.output_cost}),(0,s.jsx)(ed.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Model Statistics (Number Requests)"}),(0,s.jsx)(es.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Model Statistics (Latency)"}),(0,s.jsx)(es.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})}),(0,s.jsxs)(eS.Z,{className:"h-full",children:[(0,s.jsx)(eF,{level:2,children:"Add new model"}),(0,s.jsx)(ea.Z,{children:(0,s.jsxs)(G.Z,{form:x,onFinish:()=>{x.validateFields().then(e=>{b(e),x.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(eg.Z,{value:p.toString(),children:["OpenAI","Azure OpenAI","Anthropic","Gemini (Google AI Studio)","Amazon Bedrock","OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"].map((e,t)=>(0,s.jsx)(ey.Z,{value:e,onClick:()=>{j(e)},children:e},t))})}),(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,s.jsx)(eA.Z,{placeholder:"gpt-3.5-turbo"})}),(0,s.jsxs)(eT.Z,{children:[(0,s.jsx)(eC.Z,{span:10}),(0,s.jsx)(eC.Z,{span:10,children:(0,s.jsxs)(q.Z,{className:"mb-3 mt-1",children:["Model name your users will pass in. Also used for ",(0,s.jsx)(eM,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalancing."})]})})]}),(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:(0,s.jsx)(eA.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,s.jsxs)(eT.Z,{children:[(0,s.jsx)(eC.Z,{span:10}),(0,s.jsx)(eC.Z,{span:10,children:(0,s.jsxs)(q.Z,{className:"mb-3 mt-1",children:["Actual model name used for making ",(0,s.jsx)(eM,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"})]})})]}),"Amazon Bedrock"!=p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,s.jsx)(eA.Z,{placeholder:"sk-",type:"password"})}),"Azure OpenAI"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,s.jsx)(eA.Z,{placeholder:"https://..."})}),"Azure OpenAI"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,s.jsx)(eA.Z,{placeholder:"2023-07-01-preview"})}),"Azure OpenAI"==p&&(0,s.jsxs)(G.Z.Item,{label:"Base Model",name:"base_model",children:[(0,s.jsx)(eA.Z,{placeholder:"azure/gpt-3.5-turbo"}),(0,s.jsxs)(q.Z,{children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from ",(0,s.jsx)(eM,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})]}),"Amazon Bedrock"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eA.Z,{placeholder:""})}),"Amazon Bedrock"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eA.Z,{placeholder:""})}),"Amazon Bedrock"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eA.Z,{placeholder:"us-east-1"})})]}),(0,s.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Add Model"})}),(0,s.jsx)(eI.Z,{title:"Get help on our github",children:(0,s.jsx)(ew.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]})]})]})})};let{Option:eR}=V.default;var eD=e=>{let{userID:t,accessToken:l}=e,[r]=G.Z.useForm(),[n,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),[m,h]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{let e=await f(l,t,"any"),s=[];for(let t=0;t{o(!1),r.resetFields()},p=()=>{o(!1),c(null),r.resetFields()},j=async e=>{try{d.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let s=await u(l,t,e);console.log("user create Response:",s),c(s.key),d.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the user:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Create New User"}),(0,s.jsx)(J.Z,{title:"Create User",visible:n,width:800,footer:null,onOk:x,onCancel:p,children:(0,s.jsxs)(G.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsx)(G.Z.Item,{label:"User ID",name:"user_id",children:(0,s.jsx)(W.Z,{placeholder:"Enter User ID"})}),(0,s.jsx)(G.Z.Item,{label:"Team ID",name:"team_id",children:(0,s.jsx)(W.Z,{placeholder:"ai_team"})}),(0,s.jsx)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsx)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:m.map(e=>(0,s.jsx)(eR,{value:e,children:e},e))})}),(0,s.jsx)(G.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,s.jsx)(W.Z,{})}),(0,s.jsx)(G.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)($.ZP,{htmlType:"submit",children:"Create User"})})]})}),i&&(0,s.jsxs)(J.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"})]})]})},eU=e=>{let{accessToken:t,token:l,keys:r,userRole:n,userID:o,setKeys:i}=e,[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[u,x]=(0,a.useState)(1);if((0,a.useEffect)(()=>{if(!t||!l||!n||!o)return;let e=async()=>{try{let e=await j(t,null,n,!0,u,25);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&&e();let s=async()=>{try{let e=await N(t,null);console.log("user data response:",e),h(e)}catch(e){console.error("There was an error fetching the model data",e)}};n&&("Admin"==n||"Admin Viewer"==n)&&!m&&s()},[t,l,n,o,u]),!c||!t||!l||!n||!o)return(0,s.jsx)("div",{children:"Loading..."});let p=async e=>{try{let l=await N(t,e);console.log("user data response:",l),h(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)(z.Z,{className:"gap-2 p-2 h-[75vh] w-full mt-8",children:[(0,s.jsx)(eD,{userID:o,accessToken:t}),(0,s.jsx)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{variant:"line",defaultValue:"1",children:[(0,s.jsx)(ek.Z,{value:"1",children:"Key Owners"}),(0,s.jsx)(ek.Z,{value:"2",children:"End-Users"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(ei.Z,{className:"mt-5",children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"User ID"}),(0,s.jsx)(eh.Z,{children:"User Role"}),(0,s.jsx)(eh.Z,{children:"User Models"}),(0,s.jsx)(eh.Z,{children:"User Spend ($ USD)"}),(0,s.jsx)(eh.Z,{children:"User Max Budget ($ USD)"})]})}),(0,s.jsx)(ec.Z,{children:c.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.user_id}),(0,s.jsx)(ed.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,s.jsx)(ed.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,s.jsx)(ed.Z,{children:e.spend?e.spend:0}),(0,s.jsx)(ed.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,s.jsxs)(eS.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)(q.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,s.jsx)(eg.Z,{defaultValue:"1",className:"w-3/4",children:null==r?void 0:r.map((e,t)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,s.jsx)(ey.Z,{value:String(t),onClick:()=>p(e.token),children:e.key_name},t)})})]})]}),(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"End User"}),(0,s.jsx)(eh.Z,{children:"Spend"}),(0,s.jsx)(eh.Z,{children:"Total Events"})]})}),(0,s.jsx)(ec.Z,{children:null==m?void 0:m.map((e,t)=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.end_user}),(0,s.jsx)(ed.Z,{children:e.total_spend}),(0,s.jsx)(ed.Z,{children:e.total_events})]},t))})]})]})]})]})}),function(){if(!c)return null;let e=(u-1)*25+1,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 ",e," – ",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:()=>x(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",onClick:()=>{x(u+1)},children:"Next →"})]})]})}()]})})},ez=e=>{let{teams:t,searchParams:l,accessToken:r,setTeams:n,userID:o,userRole:i}=e,[c]=G.Z.useForm(),[m]=G.Z.useForm(),{Title:h,Paragraph:u}=ew.default,[x,j]=(0,a.useState)(""),[g,y]=(0,a.useState)(!1),[Z,w]=(0,a.useState)(t?t[0]:null),[b,k]=(0,a.useState)(!1),[_,v]=(0,a.useState)(!1),[S,N]=(0,a.useState)([]),[A,T]=(0,a.useState)(!1),[C,I]=(0,a.useState)(null),P=e=>{w(e),y(!0)},F=async e=>{let l=e.team_id;if(console.log("handleEditSubmit:",e),null==r)return;let s=await M(r,e);t&&n(t.map(e=>e.team_id===l?s.data:e)),d.ZP.success("Team updated successfully"),y(!1),w(null)},R=async e=>{I(e),T(!0)},D=async()=>{if(null!=C&&null!=t&&null!=r){try{await p(r,C);let e=t.filter(e=>e.team_id!==C);n(e)}catch(e){console.error("Error deleting the team:",e)}T(!1),I(null)}};(0,a.useEffect)(()=>{(async()=>{try{if(null===o||null===i)return;if(null!==r){let e=(await f(r,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,o,i]);let L=async e=>{try{if(null!=r){d.ZP.info("Creating Team");let l=await E(r,e);null!==t?n([...t,l]):n([l]),console.log("response for team create call: ".concat(l)),d.ZP.success("Team created"),k(!1)}}catch(e){console.error("Error creating the team:",e),d.ZP.error("Error creating the team: "+e)}},K=async e=>{try{if(null!=r&&null!=t){d.ZP.info("Adding Member");let l={role:"user",user_email:e.user_email,user_id:e.user_id},s=await O(r,Z.team_id,l);console.log("response for team create call: ".concat(s.data));let a=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(a)),-1!==a){let e=[...t];e[a]=s.data,n(e),w(s.data)}v(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(t)),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(h,{level:4,children:"All Teams"}),(0,s.jsxs)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Team Name"}),(0,s.jsx)(eh.Z,{children:"Spend (USD)"}),(0,s.jsx)(eh.Z,{children:"Budget (USD)"}),(0,s.jsx)(eh.Z,{children:"Models"}),(0,s.jsx)(eh.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ec.Z,{children:t&&t.length>0?t.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,s.jsx)(ed.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:0===e.models.length?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})}):e.models.map((e,t)=>"all-proxy-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})},t):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,s.jsxs)(q.Z,{children:["TPM:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(ed.Z,{children:[(0,s.jsx)(eo.Z,{icon:ee.Z,size:"sm",onClick:()=>P(e)}),(0,s.jsx)(eo.Z,{onClick:()=>R(e.team_id),icon:et.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(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 Team"}),(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 team ?"})})]})})}),(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)(B.Z,{onClick:D,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{T(!1),I(null)},children:"Cancel"})]})]})]})})]})]}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>k(!0),children:"+ Create New Team"}),(0,s.jsx)(J.Z,{title:"Create Team",visible:b,width:800,footer:null,onOk:()=>{k(!1),c.resetFields()},onCancel:()=>{k(!1),c.resetFields()},children:(0,s.jsxs)(G.Z,{form:c,onFinish:L,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(V.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,s.jsx)(V.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(G.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(h,{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)(eg.Z,{defaultValue:"0",children:t.map((e,t)=>(0,s.jsx)(ey.Z,{value:String(t),onClick:()=>{w(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.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Member Name"}),(0,s.jsx)(eh.Z,{children:"Role"})]})}),(0,s.jsx)(ec.Z,{children:Z?Z.members_with_roles.map((e,t)=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(ed.Z,{children:e.role})]},t)):null})]})}),Z&&(0,s.jsx)(e=>{let{visible:t,onCancel:l,team:a,onSubmit:r}=e,[n]=G.Z.useForm();return(0,s.jsx)(J.Z,{title:"Edit Team",visible:t,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:a.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:l,children:(0,s.jsxs)(G.Z,{form:n,onFinish:F,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(V.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,s.jsx)(V.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(G.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:g,onCancel:()=>{y(!1),w(null)},team:Z,onSubmit:F})]}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto mb-5",onClick:()=>v(!0),children:"+ Add member"}),(0,s.jsx)(J.Z,{title:"Add member",visible:_,width:800,footer:null,onOk:()=>{v(!1),m.resetFields()},onCancel:()=>{v(!1),m.resetFields()},children:(0,s.jsxs)(G.Z,{form:c,onFinish:K,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.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)($.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eB=e=>{let{searchParams:t,accessToken:l}=e,[r]=G.Z.useForm(),[n]=G.Z.useForm(),{Title:o,Paragraph:i}=ew.default,[c,m]=(0,a.useState)(""),[h,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(async()=>{if(null!=l){let e=[],t=await P(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 P(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!=h){d.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await R(l,e);console.log("response for team create call: ".concat(t));let s=h.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"),h.push(t),u(h)),p(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("admins: ".concat(null==h?void 0:h.length)),(0,s.jsxs)("div",{className:"w-full m-2 mt-2 p-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)(z.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,s.jsx)(U.Z,{numColSpan:1,children:(0,s.jsx)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Member Name"}),(0,s.jsx)(eh.Z,{children:"Role"})]})}),(0,s.jsx)(ec.Z,{children:h?h.map((e,t)=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(ed.Z,{children:e.user_role})]},t)):null})]})})}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto mb-5",onClick:()=>p(!0),children:"+ Add viewer"}),(0,s.jsx)(J.Z,{title:"Add viewer",visible:x,width:800,footer:null,onOk:()=>{p(!1),n.resetFields()},onCancel:()=>{p(!1),n.resetFields()},children:(0,s.jsxs)(G.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.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)($.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})]})},eq=l(12968),eL=l(67951);async function eK(e,t,l,s){console.log("isLocal:",!1);let a=window.location.origin,r=new eq.ZP.OpenAI({apiKey:s,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let s of(await r.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)}catch(e){d.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e))}}var eV=e=>{let{accessToken:t,token:l,userRole:r,userID:n}=e,[o,i]=(0,a.useState)(""),[c,d]=(0,a.useState)(""),[m,h]=(0,a.useState)([]),[u,x]=(0,a.useState)(void 0),[p,j]=(0,a.useState)([]);(0,a.useEffect)(()=>{t&&l&&r&&n&&(async()=>{try{let e=await f(t,n,r);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let t=e.data.map(e=>({value:e.id,label:e.id}));console.log(t),j(t),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[t,n,r]);let g=(e,t)=>{h(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}]})},y=async()=>{if(""!==c.trim()&&o&&l&&r&&n){h(e=>[...e,{role:"user",content:c}]);try{u&&await eK(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(r&&"Admin Viewer"==r){let{Title:e,Paragraph:t}=ew.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)(z.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,s.jsx)(ea.Z,{children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{children:[(0,s.jsx)(ek.Z,{children:"Chat"}),(0,s.jsx)(ek.Z,{children:"API Reference"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsxs)(eS.Z,{children:[(0,s.jsx)("div",{className:"sm:max-w-2xl",children:(0,s.jsxs)(z.Z,{numItems:2,children:[(0,s.jsxs)(U.Z,{children:[(0,s.jsx)(q.Z,{children:"API Key"}),(0,s.jsx)(eA.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,s.jsxs)(U.Z,{className:"mx-2",children:[(0,s.jsx)(q.Z,{children:"Select Model:"}),(0,s.jsx)(V.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,s.jsxs)(ei.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,s.jsx)(em.Z,{children:(0,s.jsx)(eu.Z,{children:(0,s.jsx)(ed.Z,{})})}),(0,s.jsx)(ec.Z,{children:m.map((e,t)=>(0,s.jsx)(eu.Z,{children:(0,s.jsx)(ed.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)(eA.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,s.jsx)(B.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]}),(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{children:[(0,s.jsx)(ek.Z,{children:"OpenAI Python SDK"}),(0,s.jsx)(ek.Z,{children:"LlamaIndex"}),(0,s.jsx)(ek.Z,{children:"Langchain Py"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsx)(eL.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)(eS.Z,{children:(0,s.jsx)(eL.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)(eS.Z,{children:(0,s.jsx)(eL.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 '})})]})]})})]})]})})})})},eG=l(33509),eJ=l(95781);let{Sider:eW}=eG.default;var eY=e=>{let{setPage:t,userRole:l,defaultSelectedKey:a}=e;return"Admin Viewer"==l?(0,s.jsx)(eG.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,s.jsx)(eW,{width:120,children:(0,s.jsxs)(eJ.Z,{mode:"inline",defaultSelectedKeys:a||["4"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"4"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"1")]})})}):(0,s.jsx)(eG.default,{style:{minHeight:"100vh",maxWidth:"100px"},children:(0,s.jsx)(eW,{width:100,children:(0,s.jsxs)(eJ.Z,{mode:"inline",defaultSelectedKeys:a||["1"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("api-keys"),children:(0,s.jsx)(q.Z,{children:"API Keys"})},"1"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("llm-playground"),children:(0,s.jsx)(q.Z,{children:"Test Key"})},"3"),"Admin"==l?(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("teams"),children:(0,s.jsx)(q.Z,{children:"Teams"})},"6"):null,(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("usage"),children:(0,s.jsx)(q.Z,{children:"Usage"})},"4"),"Admin"==l?(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("users"),children:(0,s.jsx)(q.Z,{children:"Users"})},"5"):null,(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("models"),children:(0,s.jsx)(q.Z,{children:"Models"})},"2"),"Admin"==l?(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("admin-panel"),children:(0,s.jsx)(q.Z,{children:"Admin"})},"7"):null]})})})},e$=l(67989),eH=e=>{let{accessToken:t,token:l,userRole:r,userID:n}=e,o=new Date,[i,c]=(0,a.useState)([]),[d,m]=(0,a.useState)([]),[h,u]=(0,a.useState)([]),[x,p]=(0,a.useState)([]),[j,g]=(0,a.useState)([]),[y,Z]=(0,a.useState)([]),[f,w]=(0,a.useState)([]),[N,C]=(0,a.useState)([]),I=new Date(o.getFullYear(),o.getMonth(),1),P=new Date(o.getFullYear(),o.getMonth()+1,0),E=M(I),F=M(P);function M(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(E)),console.log("End date is ".concat(F)),(0,a.useEffect)(()=>{t&&l&&r&&n&&(async()=>{try{if(console.log("user role: ".concat(r)),"Admin"==r||"Admin Viewer"==r){let e=await v(t);c(e);let l=(await S(t)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,10),spend:e.total_spend}));m(l);let s=(await A(t)).map(e=>({key:e.model,spend:e.total_spend}));u(s);let a=await b(t);console.log("teamSpend",a),g(a.daily_spend),w(a.teams);let r=a.total_spend_per_team;r=r.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e)),C(r);let n=await k(t);Z(n.top_10_tags)}else"App Owner"==r&&await _(t,l,r,n,E,F).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;m(l)}else{let l=(await T(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).substring(0,10),spend:e.spend}));m(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,r,n,E,F]),(0,s.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,s.jsx)(ej,{userID:n,userRole:r,accessToken:t}),(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{className:"mt-2",children:[(0,s.jsx)(ek.Z,{children:"All Up"}),(0,s.jsx)(ek.Z,{children:"Team Based Usage"}),(0,s.jsx)(ek.Z,{children:"Tag Based Usage"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsx)(U.Z,{numColSpan:2,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Monthly Spend"}),(0,s.jsx)(es.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)(U.Z,{numColSpan:1,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Top API Keys"}),(0,s.jsx)(es.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)(U.Z,{numColSpan:1,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Top Users"}),(0,s.jsx)(es.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)(U.Z,{numColSpan:1,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Top Models"}),(0,s.jsx)(es.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsxs)(U.Z,{numColSpan:2,children:[(0,s.jsxs)(ea.Z,{className:"mb-2",children:[(0,s.jsx)(L.Z,{children:"Total Spend Per Team"}),(0,s.jsx)(e$.Z,{data:N})]}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Daily Spend Per Team"}),(0,s.jsx)(es.Z,{className:"h-72",data:j,showLegend:!0,index:"date",categories:f,yAxisWidth:80,stack:!0})]})]}),(0,s.jsx)(U.Z,{numColSpan:2})]})}),(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,s.jsx)(U.Z,{numColSpan:2,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Spend Per Tag - Last 30 Days"}),(0,s.jsxs)(q.Z,{children:["Get Started Tracking cost per tag ",(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Tag"}),(0,s.jsx)(eh.Z,{children:"Spend"}),(0,s.jsx)(eh.Z,{children:"Requests"})]})}),(0,s.jsx)(ec.Z,{children:y.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.name}),(0,s.jsx)(ed.Z,{children:e.value}),(0,s.jsx)(ed.Z,{children:e.log_count})]},e.name))})]})]})}),(0,s.jsx)(U.Z,{numColSpan:2})]})})]})]})]})},eX=()=>{let{Title:e,Paragraph:t}=ew.default,[l,n]=(0,a.useState)(""),[o,i]=(0,a.useState)(null),[d,m]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(!0),j=(0,r.useSearchParams)(),g=j.get("userID"),y=j.get("token"),[Z,f]=(0,a.useState)("api-keys"),[w,b]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(y){let e=(0,ef.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),b(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&&f("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)(a.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)(eY,{setPage:f,userRole:l,defaultSelectedKey:null})}),"api-keys"==Z?(0,s.jsx)(eb,{userID:g,userRole:l,teams:d,keys:h,setUserRole:n,userEmail:o,setUserEmail:i,setTeams:m,setKeys:u}):"models"==Z?(0,s.jsx)(eO,{userID:g,userRole:l,token:y,accessToken:w}):"llm-playground"==Z?(0,s.jsx)(eV,{userID:g,userRole:l,token:y,accessToken:w}):"users"==Z?(0,s.jsx)(eU,{userID:g,userRole:l,token:y,keys:h,accessToken:w,setKeys:u}):"teams"==Z?(0,s.jsx)(ez,{teams:d,setTeams:m,searchParams:j,accessToken:w,userID:g,userRole:l}):"admin-panel"==Z?(0,s.jsx)(eB,{setTeams:m,searchParams:j,accessToken:w}):(0,s.jsx)(eH,{userID:g,userRole:l,token:y,accessToken:w})]})]})})}}},function(e){e.O(0,[253,971,69,744],function(){return e(e.s=79615)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-ce736ee5eac792c0.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-ce736ee5eac792c0.js deleted file mode 100644 index ee7b163c3..000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-ce736ee5eac792c0.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{79615:function(e,t,l){Promise.resolve().then(l.bind(l,46502))},46502:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return eX}});var s=l(3827),a=l(64090),r=l(47907),n=l(8792),o=l(40491),i=l(65270),c=e=>{let{userID:t,userRole:l,userEmail:a,showSSOBanner:r}=e;console.log("User ID:",t),console.log("userEmail:",a);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:[r?(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:a})})})]})]})},d=l(80588);let m=async(e,t)=>{try{let l=await fetch("/model/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),d.ZP.success("Model created successfully. Wait 60s and refresh."),s}catch(e){throw console.error("Failed to create key:",e),e}},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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},u=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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},x=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}},p=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let l=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to delete team: "+e),Error("Network response was not ok")}let s=await l.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},j=async function(e,t,l){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let a="/user/info";"App Owner"==l&&t&&(a="".concat(a,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",s),s&&(a="".concat(a,"?view_all=true"));let r=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok){let e=await r.text();throw d.ZP.error(e),Error("Network response was not ok")}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},g=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}},y=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}},Z=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}},f=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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=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}},k=async e=>{try{let t="/global/spend/tags";console.log("in tagsSpendLogsCall:",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}},_=async(e,t,l,s,a,r)=>{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(a,"&end_date=").concat(r):"".concat(t,"?start_date=").concat(a,"&end_date=").concat(r);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}},v=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}},S=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}},N=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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},A=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}},T=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}},C=async(e,t,l,s)=>{try{let a=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(!a.ok){let e=await a.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},I=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}},P=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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to get requested models:",e),e}},E=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}},F=async(e,t)=>{try{console.log("Form Values in keyUpdateCall:",t);let l=await fetch("/key/update",{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 update key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await l.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let l=await fetch("/team/update",{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 update team: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await l.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=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}},D=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}};var U=l(10384),z=l(46453),B=l(2179),q=l(71801),L=l(42440),K=l(42308),V=l(50670),G=l(81583),J=l(77171),W=l(42539),Y=l(88707),$=l(1861);let{Option:H}=V.default;var X=e=>{let{userID:t,team:l,userRole:r,accessToken:n,data:o,setData:i}=e,[c]=G.Z.useForm(),[m,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)(null),[j,g]=(0,a.useState)(null),[y,Z]=(0,a.useState)([]),w=()=>{u(!1),c.resetFields()},b=()=>{u(!1),p(null),c.resetFields()};(0,a.useEffect)(()=>{(async()=>{try{if(null===t||null===r)return;if(null!==n){let e=(await f(n,t,r)).data.map(e=>e.id);console.log("available_model_names:",e),Z(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,t,r]);let k=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)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,s.jsx)(J.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:w,onCancel:b,children:(0,s.jsxs)(G.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===r||"Admin"===r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,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)(G.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(H,{value:"all-team-models",children:"All Team Models"},"all-team-models"),l&&l.models?l.models.includes("all-proxy-models")?y.map(e=>(0,s.jsx)(H,{value:e,children:e},e)):l.models.map(e=>(0,s.jsx)(H,{value:e,children:e},e)):y.map(e=>(0,s.jsx)(H,{value:e,children:e},e))]})}),(0,s.jsx)(G.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)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.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)(V.default,{defaultValue:null,placeholder:"n/a",children:[(0,s.jsx)(V.default.Option,{value:"24h",children:"daily"}),(0,s.jsx)(V.default.Option,{value:"30d",children:"monthly"})]})}),(0,s.jsx)(G.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)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.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)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,s.jsx)(W.Z,{})}),(0,s.jsx)(G.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)(G.Z.Item,{label:"Key Name",name:"key_alias",children:(0,s.jsx)(W.Z,{})}),(0,s.jsx)(G.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)(G.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)($.ZP,{htmlType:"submit",children:"Create Key"})})]})}),x&&(0,s.jsx)(J.Z,{visible:m,onOk:w,onCancel:b,footer:null,children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 w-full",children:[(0,s.jsx)(L.Z,{children:"Save your Key"}),(0,s.jsx)(U.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)(U.Z,{numColSpan:1,children:null!=x?(0,s.jsxs)("div",{children:[(0,s.jsx)(q.Z,{className:"mt-3",children:"API Key:"}),(0,s.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,s.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:x})}),(0,s.jsx)(K.CopyToClipboard,{text:x,onCopy:()=>{d.ZP.success("API Key copied to clipboard")},children:(0,s.jsx)(B.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,s.jsx)(q.Z,{children:"Key being created, this might take 30s"})})]})})]})},Q=l(9454),ee=l(98941),et=l(33393),el=l(5),es=l(9853),ea=l(13810),er=l(39290),en=l(66952),eo=l(61244),ei=l(10827),ec=l(3851),ed=l(2044),em=l(64167),eh=l(74480),eu=l(7178);let{Option:ex}=V.default;var ep=e=>{let{userID:t,userRole:l,accessToken:r,selectedTeam:n,data:o,setData:i}=e,[c,m]=(0,a.useState)(!1),[h,u]=(0,a.useState)(!1),[p,j]=(0,a.useState)(null),[g,y]=a.useState(null),[Z,b]=(0,a.useState)(null),[k,_]=(0,a.useState)(null),[v,S]=(0,a.useState)(""),[N,A]=(0,a.useState)(!1),[T,C]=(0,a.useState)(null),[I,P]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{if(null===t)return;if(null!==r&&null!==l){let e=(await f(r,t,l)).data.map(e=>e.id);console.log("available_model_names:",e),P(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,t,l]);let E=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),C(e),A(!0)},M=async e=>{if(null==r)return;let t=e.token;e.key=t,console.log("handleEditSubmit:",e);let l=await F(r,e);console.log("handleEditSubmit: newKeyValues",l),o&&i(o.map(e=>e.token===t?l:e)),d.ZP.success("Key updated successfully"),A(!1),C(null)},O=async e=>{try{if(null==r||null==e)return;console.log("accessToken: ".concat(r,"; token: ").concat(e.token));let t=await w(r,e.token);console.log("Response:",t),_(t);try{let e=await D(r,t);console.log("Response2:",e);let l=[...t,...e.response];_(l),S(e.predicted_spend),console.log("Combined Data:",l)}catch(e){console.error("There was an error fetching the predicted data",e)}}catch(e){console.error("There was an error fetching the data",e)}};(0,a.useEffect)(()=>{O(Z)},[Z]);let R=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+t),u(!0))},U=async()=>{if(null!=p&&null!=o){try{await x(r,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}u(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,s.jsxs)("div",{children:[(0,s.jsxs)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,s.jsxs)(ei.Z,{className:"mt-5",children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Key Alias"}),(0,s.jsx)(eh.Z,{children:"Secret Key"}),(0,s.jsx)(eh.Z,{children:"Spend (USD)"}),(0,s.jsx)(eh.Z,{children:"Budget (USD)"}),(0,s.jsx)(eh.Z,{children:"Models"}),(0,s.jsx)(eh.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ec.Z,{children:o.map(e=>(console.log(e),"litellm-dashboard"===e.team_id||n&&e.team_id!=n.team_id)?null:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,s.jsx)(q.Z,{children:e.key_alias}):(0,s.jsx)(q.Z,{children:"Not Set"})}),(0,s.jsx)(ed.Z,{children:(0,s.jsx)(q.Z,{children:e.key_name})}),(0,s.jsx)(ed.Z,{children:(0,s.jsx)(q.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(t){return e.spend}})()})}),(0,s.jsx)(ed.Z,{children:null!=e.max_budget?(0,s.jsx)(q.Z,{children:e.max_budget}):(0,s.jsx)(q.Z,{children:"Unlimited"})}),(0,s.jsx)(ed.Z,{children:Array.isArray(e.models)?(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,s.jsx)(s.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,t)=>"all-proxy-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})},t):"all-team-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Team Models"})},t):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t)):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:"all-proxy-models"})})}):e.models.map((e,t)=>"all-proxy-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})},t):"all-team-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Team Models"})},t):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,s.jsx)(ed.Z,{children:(0,s.jsxs)(q.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(ed.Z,{children:[(0,s.jsx)(eo.Z,{onClick:()=>{b(e),y(e.id)},icon:Q.Z,size:"sm"}),(0,s.jsx)(er.Z,{open:null!==g,onClose:()=>{y(null),b(null)},children:(0,s.jsx)(en.Z,{children:Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3",children:[(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(Z.spend).toFixed(4)}catch(e){return Z.spend}})()})})]}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.max_budget?(0,s.jsx)(s.Fragment,{children:Z.max_budget}):(0,s.jsx)(s.Fragment,{children:"Unlimited"})})})]},e.name),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.expires?(0,s.jsx)(s.Fragment,{children:new Date(Z.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,s.jsx)(s.Fragment,{children:"Never"})})})]},e.name)]}),(0,s.jsx)(ea.Z,{className:"mt-6 mb-6",children:k&&(0,s.jsx)(es.Z,{className:"mt-6",data:k,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})}),(0,s.jsx)(L.Z,{children:"Metadata"}),(0,s.jsx)(q.Z,{children:JSON.stringify(Z.metadata)}),(0,s.jsx)(B.Z,{variant:"light",className:"mx-auto flex items-center",onClick:()=>{y(null),b(null)},children:"Close"})]})})}),(0,s.jsx)(eo.Z,{icon:ee.Z,size:"sm",onClick:()=>E(e)}),(0,s.jsx)(eo.Z,{onClick:()=>R(e),icon:et.Z,size:"sm"})]})]},e.token))})]}),h&&(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)(B.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{u(!1),j(null)},children:"Cancel"})]})]})]})})]}),T&&(0,s.jsx)(e=>{let{visible:t,onCancel:l,token:a,onSubmit:r}=e,[o]=G.Z.useForm();return console.log("in edit key modal:",a),console.log("in edit key modal, team:",n),(0,s.jsx)(J.Z,{title:"Edit Key",visible:t,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:l,children:(0,s.jsxs)(G.Z,{form:o,onFinish:M,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(ex,{value:"all-team-models",children:"All Team Models"},"all-team-models"),n&&n.models?n.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,s.jsx)(ex,{value:e,children:e},e)):n.models.map(e=>(0,s.jsx)(ex,{value:e,children:e},e)):I.map(e=>(0,s.jsx)(ex,{value:e,children:e},e))]})}),(0,s.jsx)(G.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==n?void 0:n.max_budget)!==null&&(null==n?void 0:n.max_budget)!==void 0?null==n?void 0:n.max_budget:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&n&&null!==n.max_budget&&t>n.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(n.max_budget))}}],children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"token",name:"token",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:N,onCancel:()=>{A(!1),C(null)},token:T,onSubmit:M})]})},ej=e=>{let{userID:t,userRole:l,accessToken:r}=e,[n,o]=(0,a.useState)(0),[i,c]=(0,a.useState)(0);(0,a.useEffect)(()=>{(async()=>{if(r&&t&&l&&"Admin"===l)try{let e=await g(r);e&&(e.spend?o(e.spend):o(0),e.max_budget?c(e.max_budget):c(0))}catch(e){console.error("Error fetching global spend data:",e)}})()},[l,r]);let d=void 0!==n?n.toFixed(5):null;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend (across all teams)"}),(0,s.jsxs)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",d]})]})},eg=l(55901),ey=l(27166),eZ=e=>{let{teams:t,setSelectedTeam:l}=e,r={models:[],team_id:null,team_alias:"Default Team"},[n,o]=(0,a.useState)(r),i=t?[...t,r]:[r];return(0,s.jsxs)("div",{className:"mt-5 mb-5",children:[(0,s.jsx)(L.Z,{children:"Select Team"}),(0,s.jsx)(q.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,s.jsxs)(q.Z,{className:"mt-3 mb-3",children:[(0,s.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),i&&i.length>0?(0,s.jsx)(eg.Z,{defaultValue:"0",children:i.map((e,t)=>(0,s.jsx)(ey.Z,{value:String(t),onClick:()=>l(e),children:e.team_alias},t))}):(0,s.jsxs)(q.Z,{children:["No team created. ",(0,s.jsx)("b",{children:"Defaulting to personal account."})]})]})},ef=l(37963),ew=l(36083);console.log("isLocal:",!1);var eb=e=>{let{userID:t,userRole:l,teams:n,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,a.useState)(null),p=(0,r.useSearchParams)();p.get("viewSpend"),(0,r.useRouter)();let y=p.get("token"),[Z,w]=(0,a.useState)(null),[b,k]=(0,a.useState)([]),[_,v]=(0,a.useState)(n?n[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,a.useEffect)(()=>{if(y){let e=(0,ef.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(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?k(JSON.parse(e)):(async()=>{try{let e=await j(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 g(Z);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(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 f(Z,t,l)).data.map(e=>e.id);console.log("available_model_names:",s),k(s),console.log("userModels:",b),sessionStorage.setItem("userModels"+t,JSON.stringify(s))}catch(e){console.error("There was an error fetching the data",e)}})()}},[t,y,Z,o,l]),null==t||null==y){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}=ew.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",_),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsx)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(ej,{userID:t,userRole:l,accessToken:Z}),(0,s.jsx)(ep,{userID:t,userRole:l,accessToken:Z,selectedTeam:_||null,data:o,setData:h}),(0,s.jsx)(X,{userID:t,team:_||null,userRole:l,accessToken:Z,data:o,setData:h},_?_.team_id:null),(0,s.jsx)(eZ,{teams:n,setSelectedTeam:v})]})})})},ek=l(92836),e_=l(26734),ev=l(41608),eS=l(32126),eN=l(23682),eA=l(52273),eT=l(38302),eC=l(28683),eI=l(1460);let{Option:eP}=V.default;var eE=e=>{let{userModels:t,accessToken:l,userID:r}=e,[n]=G.Z.useForm(),[o,i]=(0,a.useState)(!1),c=async e=>{try{d.ZP.info("Requesting access");let{selectedModel:t,accessReason:s}=e;await C(l,t,r,s),i(!0)}catch(e){console.error("Error requesting access:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{size:"xs",onClick:()=>i(!0),children:"Request Access"}),(0,s.jsx)(J.Z,{title:"Request Access",visible:o,width:800,footer:null,onOk:()=>{i(!1),n.resetFields()},onCancel:()=>{i(!1),n.resetFields()},children:(0,s.jsxs)(G.Z,{form:n,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsx)(G.Z.Item,{label:"Select Model",name:"selectedModel",children:(0,s.jsx)(V.default,{placeholder:"Select model",style:{width:"100%"},children:t.map(e=>(0,s.jsx)(eP,{value:e,children:e},e))})}),(0,s.jsx)(G.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)(B.Z,{children:"Request Access"})})]})})]})};let{Title:eF,Link:eM}=ew.default;var eO=e=>{let{accessToken:t,token:l,userRole:r,userID:n}=e,[o,i]=(0,a.useState)({data:[]}),[c,d]=(0,a.useState)([]),[h,u]=(0,a.useState)([]),[x]=G.Z.useForm(),[p,j]=(0,a.useState)("OpenAI");if((0,a.useEffect)(()=>{if(!t||!l||!r||!n)return;let e=async()=>{try{let e=await y(t,n,r);console.log("Model data response:",e.data),i(e);let l=await Z(t,n,r);if(console.log("Model metrics response:",l),d(l),"Admin"===r&&t){let e=await I(t);console.log("Pending Requests:",h),u(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};t&&l&&r&&n&&e()},[t,l,r,n]),!o||!t||!l||!r||!n)return(0,s.jsx)("div",{children:"Loading..."});let g=[];for(let e=0;e{let l={},s={},a="";for(let[t,r]of Object.entries(e))"model_name"==t&&(a=r),("api_key"===t||"model"===t||"api_base"===t||"api_version"===t||t.startsWith("aws_"))&&(l[t]=r),"base_model"===t&&(s[t]=r);let r={model_name:a,litellm_params:l,model_info:s},n=await m(t,r);console.log("response for model create call: ".concat(n.data))};return console.log("selectedProvider: ".concat(p)),(0,s.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,s.jsxs)(e_.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(ev.Z,{className:"mt-2",children:[(0,s.jsx)(ek.Z,{children:"All Models"}),(0,s.jsx)(ek.Z,{children:"Add Model"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{children:[(0,s.jsx)(ea.Z,{children:(0,s.jsxs)(ei.Z,{className:"mt-5",children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Model Name "}),(0,s.jsx)(eh.Z,{children:"Provider"}),"Admin"===r&&(0,s.jsx)(eh.Z,{children:"API Base"}),(0,s.jsx)(eh.Z,{children:"Access"}),(0,s.jsx)(eh.Z,{children:"Input Price per token ($)"}),(0,s.jsx)(eh.Z,{children:"Output Price per token ($)"}),(0,s.jsx)(eh.Z,{children:"Max Tokens"})]})}),(0,s.jsx)(ec.Z,{children:o.data.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:(0,s.jsx)(q.Z,{children:e.model_name})}),(0,s.jsx)(ed.Z,{children:e.provider}),"Admin"===r&&(0,s.jsx)(ed.Z,{children:e.api_base}),(0,s.jsx)(ed.Z,{children:e.user_access?(0,s.jsx)(el.Z,{color:"green",children:"Yes"}):(0,s.jsx)(eE,{userModels:g,accessToken:t,userID:n})}),(0,s.jsx)(ed.Z,{children:e.input_cost}),(0,s.jsx)(ed.Z,{children:e.output_cost}),(0,s.jsx)(ed.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Model Statistics (Number Requests)"}),(0,s.jsx)(es.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Model Statistics (Latency)"}),(0,s.jsx)(es.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})}),(0,s.jsxs)(eS.Z,{className:"h-full",children:[(0,s.jsx)(eF,{level:2,children:"Add new model"}),(0,s.jsx)(ea.Z,{children:(0,s.jsxs)(G.Z,{form:x,onFinish:()=>{x.validateFields().then(e=>{b(e),x.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(eg.Z,{value:p.toString(),children:["OpenAI","Azure OpenAI","Anthropic","Gemini (Google AI Studio)","Amazon Bedrock","OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"].map((e,t)=>(0,s.jsx)(ey.Z,{value:e,onClick:()=>{j(e)},children:e},t))})}),(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,s.jsx)(eA.Z,{placeholder:"gpt-3.5-turbo"})}),(0,s.jsxs)(eT.Z,{children:[(0,s.jsx)(eC.Z,{span:10}),(0,s.jsx)(eC.Z,{span:10,children:(0,s.jsxs)(q.Z,{className:"mb-3 mt-1",children:["Model name your users will pass in. Also used for ",(0,s.jsx)(eM,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalancing."})]})})]}),(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:(0,s.jsx)(eA.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,s.jsxs)(eT.Z,{children:[(0,s.jsx)(eC.Z,{span:10}),(0,s.jsx)(eC.Z,{span:10,children:(0,s.jsxs)(q.Z,{className:"mb-3 mt-1",children:["Actual model name used for making ",(0,s.jsx)(eM,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"})]})})]}),"Amazon Bedrock"!=p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,s.jsx)(eA.Z,{placeholder:"sk-",type:"password"})}),"Azure OpenAI"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,s.jsx)(eA.Z,{placeholder:"https://..."})}),"Azure OpenAI"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,s.jsx)(eA.Z,{placeholder:"2023-07-01-preview"})}),"Azure OpenAI"==p&&(0,s.jsxs)(G.Z.Item,{label:"Base Model",name:"base_model",children:[(0,s.jsx)(eA.Z,{placeholder:"azure/gpt-3.5-turbo"}),(0,s.jsxs)(q.Z,{children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from ",(0,s.jsx)(eM,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})]}),"Amazon Bedrock"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eA.Z,{placeholder:""})}),"Amazon Bedrock"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eA.Z,{placeholder:""})}),"Amazon Bedrock"==p&&(0,s.jsx)(G.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eA.Z,{placeholder:"us-east-1"})})]}),(0,s.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Add Model"})}),(0,s.jsx)(eI.Z,{title:"Get help on our github",children:(0,s.jsx)(ew.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]})]})]})})};let{Option:eR}=V.default;var eD=e=>{let{userID:t,accessToken:l}=e,[r]=G.Z.useForm(),[n,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),[m,h]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{let e=await f(l,t,"any"),s=[];for(let t=0;t{o(!1),r.resetFields()},p=()=>{o(!1),c(null),r.resetFields()},j=async e=>{try{d.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let s=await u(l,t,e);console.log("user create Response:",s),c(s.key),d.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the user:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Create New User"}),(0,s.jsx)(J.Z,{title:"Create User",visible:n,width:800,footer:null,onOk:x,onCancel:p,children:(0,s.jsxs)(G.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsx)(G.Z.Item,{label:"User ID",name:"user_id",children:(0,s.jsx)(W.Z,{placeholder:"Enter User ID"})}),(0,s.jsx)(G.Z.Item,{label:"Team ID",name:"team_id",children:(0,s.jsx)(W.Z,{placeholder:"ai_team"})}),(0,s.jsx)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsx)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:m.map(e=>(0,s.jsx)(eR,{value:e,children:e},e))})}),(0,s.jsx)(G.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,s.jsx)(W.Z,{})}),(0,s.jsx)(G.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)($.ZP,{htmlType:"submit",children:"Create User"})})]})}),i&&(0,s.jsxs)(J.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"})]})]})},eU=e=>{let{accessToken:t,token:l,keys:r,userRole:n,userID:o,setKeys:i}=e,[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[u,x]=(0,a.useState)(1);if((0,a.useEffect)(()=>{if(!t||!l||!n||!o)return;let e=async()=>{try{let e=await j(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 N(t,null);console.log("user data response:",e),h(e)}catch(e){console.error("There was an error fetching the model data",e)}};n&&("Admin"==n||"Admin Viewer"==n)&&!m&&s()},[t,l,n,o]),!c||!t||!l||!n||!o)return(0,s.jsx)("div",{children:"Loading..."});let p=async e=>{try{let l=await N(t,e);console.log("user data response:",l),h(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)(z.Z,{className:"gap-2 p-2 h-[75vh] w-full mt-8",children:[(0,s.jsx)(eD,{userID:o,accessToken:t}),(0,s.jsx)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{variant:"line",defaultValue:"1",children:[(0,s.jsx)(ek.Z,{value:"1",children:"Key Owners"}),(0,s.jsx)(ek.Z,{value:"2",children:"End-Users"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(ei.Z,{className:"mt-5",children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"User ID"}),(0,s.jsx)(eh.Z,{children:"User Role"}),(0,s.jsx)(eh.Z,{children:"User Models"}),(0,s.jsx)(eh.Z,{children:"User Spend ($ USD)"}),(0,s.jsx)(eh.Z,{children:"User Max Budget ($ USD)"})]})}),(0,s.jsx)(ec.Z,{children:c.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.user_id}),(0,s.jsx)(ed.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,s.jsx)(ed.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,s.jsx)(ed.Z,{children:e.spend?e.spend:0}),(0,s.jsx)(ed.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,s.jsxs)(eS.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)(q.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,s.jsx)(eg.Z,{defaultValue:"1",className:"w-3/4",children:null==r?void 0:r.map((e,t)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,s.jsx)(ey.Z,{value:String(t),onClick:()=>p(e.token),children:e.key_name},t)})})]})]}),(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"End User"}),(0,s.jsx)(eh.Z,{children:"Spend"}),(0,s.jsx)(eh.Z,{children:"Total Events"})]})}),(0,s.jsx)(ec.Z,{children:null==m?void 0:m.map((e,t)=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.end_user}),(0,s.jsx)(ed.Z,{children:e.total_spend}),(0,s.jsx)(ed.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:()=>x(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:()=>x(u+1),children:"Next →"})]})]})}()]})})},ez=e=>{let{teams:t,searchParams:l,accessToken:r,setTeams:n,userID:o,userRole:i}=e,[c]=G.Z.useForm(),[m]=G.Z.useForm(),{Title:h,Paragraph:u}=ew.default,[x,j]=(0,a.useState)(""),[g,y]=(0,a.useState)(!1),[Z,w]=(0,a.useState)(t?t[0]:null),[b,k]=(0,a.useState)(!1),[_,v]=(0,a.useState)(!1),[S,N]=(0,a.useState)([]),[A,T]=(0,a.useState)(!1),[C,I]=(0,a.useState)(null),P=e=>{w(e),y(!0)},F=async e=>{let l=e.team_id;if(console.log("handleEditSubmit:",e),null==r)return;let s=await M(r,e);t&&n(t.map(e=>e.team_id===l?s.data:e)),d.ZP.success("Team updated successfully"),y(!1),w(null)},R=async e=>{I(e),T(!0)},D=async()=>{if(null!=C&&null!=t&&null!=r){try{await p(r,C);let e=t.filter(e=>e.team_id!==C);n(e)}catch(e){console.error("Error deleting the team:",e)}T(!1),I(null)}};(0,a.useEffect)(()=>{(async()=>{try{if(null===o||null===i)return;if(null!==r){let e=(await f(r,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,o,i]);let L=async e=>{try{if(null!=r){d.ZP.info("Creating Team");let l=await E(r,e);null!==t?n([...t,l]):n([l]),console.log("response for team create call: ".concat(l)),d.ZP.success("Team created"),k(!1)}}catch(e){console.error("Error creating the team:",e),d.ZP.error("Error creating the team: "+e)}},K=async e=>{try{if(null!=r&&null!=t){d.ZP.info("Adding Member");let l={role:"user",user_email:e.user_email,user_id:e.user_id},s=await O(r,Z.team_id,l);console.log("response for team create call: ".concat(s.data));let a=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(a)),-1!==a){let e=[...t];e[a]=s.data,n(e),w(s.data)}v(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(t)),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(h,{level:4,children:"All Teams"}),(0,s.jsxs)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Team Name"}),(0,s.jsx)(eh.Z,{children:"Spend (USD)"}),(0,s.jsx)(eh.Z,{children:"Budget (USD)"}),(0,s.jsx)(eh.Z,{children:"Models"}),(0,s.jsx)(eh.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ec.Z,{children:t&&t.length>0?t.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,s.jsx)(ed.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:0===e.models.length?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})}):e.models.map((e,t)=>"all-proxy-models"===e?(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(q.Z,{children:"All Proxy Models"})},t):(0,s.jsx)(el.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(q.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,s.jsx)(ed.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,s.jsxs)(q.Z,{children:["TPM:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(ed.Z,{children:[(0,s.jsx)(eo.Z,{icon:ee.Z,size:"sm",onClick:()=>P(e)}),(0,s.jsx)(eo.Z,{onClick:()=>R(e.team_id),icon:et.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(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 Team"}),(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 team ?"})})]})})}),(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)(B.Z,{onClick:D,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{T(!1),I(null)},children:"Cancel"})]})]})]})})]})]}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>k(!0),children:"+ Create New Team"}),(0,s.jsx)(J.Z,{title:"Create Team",visible:b,width:800,footer:null,onOk:()=>{k(!1),c.resetFields()},onCancel:()=>{k(!1),c.resetFields()},children:(0,s.jsxs)(G.Z,{form:c,onFinish:L,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(V.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,s.jsx)(V.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(G.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(h,{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)(eg.Z,{defaultValue:"0",children:t.map((e,t)=>(0,s.jsx)(ey.Z,{value:String(t),onClick:()=>{w(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.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Member Name"}),(0,s.jsx)(eh.Z,{children:"Role"})]})}),(0,s.jsx)(ec.Z,{children:Z?Z.members_with_roles.map((e,t)=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(ed.Z,{children:e.role})]},t)):null})]})}),Z&&(0,s.jsx)(e=>{let{visible:t,onCancel:l,team:a,onSubmit:r}=e,[n]=G.Z.useForm();return(0,s.jsx)(J.Z,{title:"Edit Team",visible:t,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:a.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:l,children:(0,s.jsxs)(G.Z,{form:n,onFinish:F,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(V.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(V.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,s.jsx)(V.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(G.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)(Y.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(G.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)(Y.Z,{step:1,width:400})}),(0,s.jsx)(G.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)($.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:g,onCancel:()=>{y(!1),w(null)},team:Z,onSubmit:F})]}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto mb-5",onClick:()=>v(!0),children:"+ Add member"}),(0,s.jsx)(J.Z,{title:"Add member",visible:_,width:800,footer:null,onOk:()=>{v(!1),m.resetFields()},onCancel:()=>{v(!1),m.resetFields()},children:(0,s.jsxs)(G.Z,{form:c,onFinish:K,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.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)($.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eB=e=>{let{searchParams:t,accessToken:l}=e,[r]=G.Z.useForm(),[n]=G.Z.useForm(),{Title:o,Paragraph:i}=ew.default,[c,m]=(0,a.useState)(""),[h,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(async()=>{if(null!=l){let e=[],t=await P(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 P(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!=h){d.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await R(l,e);console.log("response for team create call: ".concat(t));let s=h.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"),h.push(t),u(h)),p(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("admins: ".concat(null==h?void 0:h.length)),(0,s.jsxs)("div",{className:"w-full m-2 mt-2 p-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)(z.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,s.jsx)(U.Z,{numColSpan:1,children:(0,s.jsx)(ea.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Member Name"}),(0,s.jsx)(eh.Z,{children:"Role"})]})}),(0,s.jsx)(ec.Z,{children:h?h.map((e,t)=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(ed.Z,{children:e.user_role})]},t)):null})]})})}),(0,s.jsxs)(U.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto mb-5",onClick:()=>p(!0),children:"+ Add viewer"}),(0,s.jsx)(J.Z,{title:"Add viewer",visible:x,width:800,footer:null,onOk:()=>{p(!1),n.resetFields()},onCancel:()=>{p(!1),n.resetFields()},children:(0,s.jsxs)(G.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.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)(G.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)($.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})]})},eq=l(12968),eL=l(67951);async function eK(e,t,l,s){console.log("isLocal:",!1);let a=window.location.origin,r=new eq.ZP.OpenAI({apiKey:s,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let s of(await r.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)}catch(e){d.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e))}}var eV=e=>{let{accessToken:t,token:l,userRole:r,userID:n}=e,[o,i]=(0,a.useState)(""),[c,d]=(0,a.useState)(""),[m,h]=(0,a.useState)([]),[u,x]=(0,a.useState)(void 0),[p,j]=(0,a.useState)([]);(0,a.useEffect)(()=>{t&&l&&r&&n&&(async()=>{try{let e=await f(t,n,r);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let t=e.data.map(e=>({value:e.id,label:e.id}));console.log(t),j(t),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[t,n,r]);let g=(e,t)=>{h(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}]})},y=async()=>{if(""!==c.trim()&&o&&l&&r&&n){h(e=>[...e,{role:"user",content:c}]);try{u&&await eK(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(r&&"Admin Viewer"==r){let{Title:e,Paragraph:t}=ew.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)(z.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,s.jsx)(ea.Z,{children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{children:[(0,s.jsx)(ek.Z,{children:"Chat"}),(0,s.jsx)(ek.Z,{children:"API Reference"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsxs)(eS.Z,{children:[(0,s.jsx)("div",{className:"sm:max-w-2xl",children:(0,s.jsxs)(z.Z,{numItems:2,children:[(0,s.jsxs)(U.Z,{children:[(0,s.jsx)(q.Z,{children:"API Key"}),(0,s.jsx)(eA.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,s.jsxs)(U.Z,{className:"mx-2",children:[(0,s.jsx)(q.Z,{children:"Select Model:"}),(0,s.jsx)(V.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,s.jsxs)(ei.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,s.jsx)(em.Z,{children:(0,s.jsx)(eu.Z,{children:(0,s.jsx)(ed.Z,{})})}),(0,s.jsx)(ec.Z,{children:m.map((e,t)=>(0,s.jsx)(eu.Z,{children:(0,s.jsx)(ed.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)(eA.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,s.jsx)(B.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]}),(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{children:[(0,s.jsx)(ek.Z,{children:"OpenAI Python SDK"}),(0,s.jsx)(ek.Z,{children:"LlamaIndex"}),(0,s.jsx)(ek.Z,{children:"Langchain Py"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsx)(eL.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)(eS.Z,{children:(0,s.jsx)(eL.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)(eS.Z,{children:(0,s.jsx)(eL.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 '})})]})]})})]})]})})})})},eG=l(33509),eJ=l(95781);let{Sider:eW}=eG.default;var eY=e=>{let{setPage:t,userRole:l,defaultSelectedKey:a}=e;return"Admin Viewer"==l?(0,s.jsx)(eG.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,s.jsx)(eW,{width:120,children:(0,s.jsxs)(eJ.Z,{mode:"inline",defaultSelectedKeys:a||["4"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"4"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"1")]})})}):(0,s.jsx)(eG.default,{style:{minHeight:"100vh",maxWidth:"100px"},children:(0,s.jsx)(eW,{width:100,children:(0,s.jsxs)(eJ.Z,{mode:"inline",defaultSelectedKeys:a||["1"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("api-keys"),children:(0,s.jsx)(q.Z,{children:"API Keys"})},"1"),(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("llm-playground"),children:(0,s.jsx)(q.Z,{children:"Test Key"})},"3"),"Admin"==l?(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("teams"),children:(0,s.jsx)(q.Z,{children:"Teams"})},"6"):null,(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("usage"),children:(0,s.jsx)(q.Z,{children:"Usage"})},"4"),"Admin"==l?(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("users"),children:(0,s.jsx)(q.Z,{children:"Users"})},"5"):null,(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("models"),children:(0,s.jsx)(q.Z,{children:"Models"})},"2"),"Admin"==l?(0,s.jsx)(eJ.Z.Item,{onClick:()=>t("admin-panel"),children:(0,s.jsx)(q.Z,{children:"Admin"})},"7"):null]})})})},e$=l(67989),eH=e=>{let{accessToken:t,token:l,userRole:r,userID:n}=e,o=new Date,[i,c]=(0,a.useState)([]),[d,m]=(0,a.useState)([]),[h,u]=(0,a.useState)([]),[x,p]=(0,a.useState)([]),[j,g]=(0,a.useState)([]),[y,Z]=(0,a.useState)([]),[f,w]=(0,a.useState)([]),[N,C]=(0,a.useState)([]),I=new Date(o.getFullYear(),o.getMonth(),1),P=new Date(o.getFullYear(),o.getMonth()+1,0),E=M(I),F=M(P);function M(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(E)),console.log("End date is ".concat(F)),(0,a.useEffect)(()=>{t&&l&&r&&n&&(async()=>{try{if(console.log("user role: ".concat(r)),"Admin"==r||"Admin Viewer"==r){let e=await v(t);c(e);let l=(await S(t)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,10),spend:e.total_spend}));m(l);let s=(await A(t)).map(e=>({key:e.model,spend:e.total_spend}));u(s);let a=await b(t);console.log("teamSpend",a),g(a.daily_spend),w(a.teams);let r=a.total_spend_per_team;r=r.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e)),C(r);let n=await k(t);Z(n.top_10_tags)}else"App Owner"==r&&await _(t,l,r,n,E,F).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;m(l)}else{let l=(await T(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).substring(0,10),spend:e.spend}));m(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,r,n,E,F]),(0,s.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,s.jsx)(ej,{userID:n,userRole:r,accessToken:t}),(0,s.jsxs)(e_.Z,{children:[(0,s.jsxs)(ev.Z,{className:"mt-2",children:[(0,s.jsx)(ek.Z,{children:"All Up"}),(0,s.jsx)(ek.Z,{children:"Team Based Usage"}),(0,s.jsx)(ek.Z,{children:"Tag Based Usage"})]}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsx)(U.Z,{numColSpan:2,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Monthly Spend"}),(0,s.jsx)(es.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)(U.Z,{numColSpan:1,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Top API Keys"}),(0,s.jsx)(es.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)(U.Z,{numColSpan:1,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Top Users"}),(0,s.jsx)(es.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)(U.Z,{numColSpan:1,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Top Models"}),(0,s.jsx)(es.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsxs)(U.Z,{numColSpan:2,children:[(0,s.jsxs)(ea.Z,{className:"mb-2",children:[(0,s.jsx)(L.Z,{children:"Total Spend Per Team"}),(0,s.jsx)(e$.Z,{data:N})]}),(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Daily Spend Per Team"}),(0,s.jsx)(es.Z,{className:"h-72",data:j,showLegend:!0,index:"date",categories:f,yAxisWidth:80,stack:!0})]})]}),(0,s.jsx)(U.Z,{numColSpan:2})]})}),(0,s.jsx)(eS.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,s.jsx)(U.Z,{numColSpan:2,children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(L.Z,{children:"Spend Per Tag - Last 30 Days"}),(0,s.jsxs)(q.Z,{children:["Get Started Tracking cost per tag ",(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,s.jsxs)(ei.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(eh.Z,{children:"Tag"}),(0,s.jsx)(eh.Z,{children:"Spend"}),(0,s.jsx)(eh.Z,{children:"Requests"})]})}),(0,s.jsx)(ec.Z,{children:y.map(e=>(0,s.jsxs)(eu.Z,{children:[(0,s.jsx)(ed.Z,{children:e.name}),(0,s.jsx)(ed.Z,{children:e.value}),(0,s.jsx)(ed.Z,{children:e.log_count})]},e.name))})]})]})}),(0,s.jsx)(U.Z,{numColSpan:2})]})})]})]})]})},eX=()=>{let{Title:e,Paragraph:t}=ew.default,[l,n]=(0,a.useState)(""),[o,i]=(0,a.useState)(null),[d,m]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(!0),j=(0,r.useSearchParams)(),g=j.get("userID"),y=j.get("token"),[Z,f]=(0,a.useState)("api-keys"),[w,b]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(y){let e=(0,ef.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),b(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&&f("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)(a.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)(eY,{setPage:f,userRole:l,defaultSelectedKey:null})}),"api-keys"==Z?(0,s.jsx)(eb,{userID:g,userRole:l,teams:d,keys:h,setUserRole:n,userEmail:o,setUserEmail:i,setTeams:m,setKeys:u}):"models"==Z?(0,s.jsx)(eO,{userID:g,userRole:l,token:y,accessToken:w}):"llm-playground"==Z?(0,s.jsx)(eV,{userID:g,userRole:l,token:y,accessToken:w}):"users"==Z?(0,s.jsx)(eU,{userID:g,userRole:l,token:y,keys:h,accessToken:w,setKeys:u}):"teams"==Z?(0,s.jsx)(ez,{teams:d,setTeams:m,searchParams:j,accessToken:w,userID:g,userRole:l}):"admin-panel"==Z?(0,s.jsx)(eB,{setTeams:m,searchParams:j,accessToken:w}):(0,s.jsx)(eH,{userID:g,userRole:l,token:y,accessToken:w})]})]})})}}},function(e){e.O(0,[253,971,69,744],function(){return e(e.s=79615)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.html b/litellm/proxy/_experimental/out/index.html index 89b7d52ac..c64e9ed8d 100644 --- a/litellm/proxy/_experimental/out/index.html +++ b/litellm/proxy/_experimental/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.txt b/litellm/proxy/_experimental/out/index.txt index 2d1739a51..9171ecf63 100644 --- a/litellm/proxy/_experimental/out/index.txt +++ b/litellm/proxy/_experimental/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[46502,["253","static/chunks/253-8ab6133ad5f92675.js","931","static/chunks/app/page-ce736ee5eac792c0.js"],""] +3:I[46502,["253","static/chunks/253-8ab6133ad5f92675.js","931","static/chunks/app/page-a485c9c659128852.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["9QubL0PO5JZ-hNit5iXPw",[[["",{"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/04eb0ce8764f86fe.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["KnyD0lgLk9_a0erHwSSu-",[[["",{"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/04eb0ce8764f86fe.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/404.html b/ui/litellm-dashboard/out/404.html index 33d640a28..8c80c9bc8 100644 --- a/ui/litellm-dashboard/out/404.html +++ b/ui/litellm-dashboard/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.html b/ui/litellm-dashboard/out/index.html index 89b7d52ac..c64e9ed8d 100644 --- a/ui/litellm-dashboard/out/index.html +++ b/ui/litellm-dashboard/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.txt b/ui/litellm-dashboard/out/index.txt index 2d1739a51..9171ecf63 100644 --- a/ui/litellm-dashboard/out/index.txt +++ b/ui/litellm-dashboard/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[46502,["253","static/chunks/253-8ab6133ad5f92675.js","931","static/chunks/app/page-ce736ee5eac792c0.js"],""] +3:I[46502,["253","static/chunks/253-8ab6133ad5f92675.js","931","static/chunks/app/page-a485c9c659128852.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["9QubL0PO5JZ-hNit5iXPw",[[["",{"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/04eb0ce8764f86fe.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["KnyD0lgLk9_a0erHwSSu-",[[["",{"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/04eb0ce8764f86fe.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 8f45d8a36..9ccf25496 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -240,7 +240,9 @@ export const userInfoCall = async ( accessToken: String, userID: String | null, userRole: String, - viewAll: Boolean = false + viewAll: Boolean = false, + page: number | null, + page_size: number | null ) => { try { let url = proxyBaseUrl ? `${proxyBaseUrl}/user/info` : `/user/info`; @@ -248,8 +250,8 @@ export const userInfoCall = async ( url = `${url}?user_id=${userID}`; } console.log("in userInfoCall viewAll=", viewAll); - if (viewAll) { - url = `${url}?view_all=true`; + if (viewAll && page && page_size) { + url = `${url}?view_all=true&page=${page}&page_size=${page_size}`; } //message.info("Requesting user data"); const response = await fetch(url, { diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsx index eb13faaae..72f86f749 100644 --- a/ui/litellm-dashboard/src/components/user_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx @@ -123,7 +123,7 @@ const UserDashboard: React.FC = ({ } else { const fetchData = async () => { try { - const response = await userInfoCall(accessToken, userID, userRole); + const response = await userInfoCall(accessToken, userID, userRole, false, null, null); console.log( `received teams in user dashboard: ${Object.keys( response diff --git a/ui/litellm-dashboard/src/components/view_users.tsx b/ui/litellm-dashboard/src/components/view_users.tsx index 6e785e290..19929a6be 100644 --- a/ui/litellm-dashboard/src/components/view_users.tsx +++ b/ui/litellm-dashboard/src/components/view_users.tsx @@ -59,7 +59,9 @@ const ViewUserDashboard: React.FC = ({ accessToken, null, userRole, - true + true, + currentPage, + defaultPageSize ); console.log("user data response:", userDataResponse); setUserData(userDataResponse); @@ -68,7 +70,7 @@ const ViewUserDashboard: React.FC = ({ } }; - if (accessToken && token && userRole && userID && !userData) { + if (accessToken && token && userRole && userID) { fetchData(); } @@ -88,7 +90,7 @@ const ViewUserDashboard: React.FC = ({ ) { fetchEndUserSpend(); } - }, [accessToken, token, userRole, userID]); + }, [accessToken, token, userRole, userID, currentPage]); if (!userData) { return
Loading...
; @@ -111,7 +113,7 @@ const ViewUserDashboard: React.FC = ({ function renderPagination() { if (!userData) return null; - const totalPages = Math.ceil(userData.length / defaultPageSize); + // const totalPages = Math.ceil(userData.length / defaultPageSize); const startItem = (currentPage - 1) * defaultPageSize + 1; const endItem = Math.min(currentPage * defaultPageSize, userData.length); @@ -130,8 +132,10 @@ const ViewUserDashboard: React.FC = ({