diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html index 3f4fbaaa4..4ecd3d58f 100644 --- a/litellm/proxy/_experimental/out/404.html +++ b/litellm/proxy/_experimental/out/404.html @@ -1 +1,5 @@ -404: This page could not be found.🚅 LiteLLM

404

This page could not be found.

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

404

This page could not be found.

+======= +404: This page could not be found.🚅 LiteLLM

404

This page could not be found.

+>>>>>>> e6a09427 ((new) ui build) diff --git a/litellm/proxy/_experimental/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_buildManifest.js new file mode 100644 index 000000000..f779caa02 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_buildManifest.js @@ -0,0 +1 @@ +self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/_error":["static/chunks/pages/_error-d6107f1aac0c574c.js"],sortedPages:["/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_ssgManifest.js new file mode 100644 index 000000000..5b3ff592f --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_ssgManifest.js @@ -0,0 +1 @@ +self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB() \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-37392d6753f8a3d0.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-37392d6753f8a3d0.js new file mode 100644 index 000000000..ff0808ac7 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-37392d6753f8a3d0.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,t,s){Promise.resolve().then(s.bind(s,90177))},90177:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eL}});var l=s(3827),r=s(64090),a=s(47907),n=s(8792),o=s(40491),i=s(65270),c=e=>{let{userID:t,userRole:s,userEmail:r,showSSOBanner:a}=e;console.log("User ID:",t),console.log("userEmail:",r);let c=[{key:"1",label:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{children:["Role: ",s]}),(0,l.jsxs)("p",{children:["ID: ",t]})]})}];return(0,l.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,l.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,l.jsx)("div",{className:"flex flex-col items-center",children:(0,l.jsx)(n.default,{href:"/",children:(0,l.jsx)("button",{className:"text-gray-800 text-2xl py-1 rounded text-center",children:(0,l.jsx)("img",{src:"/get_image",width:200,height:200,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,l.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[a?(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#setup-ssoauth-for-ui",target:"_blank",className:"mr-2"}):null,(0,l.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,l.jsx)(o.Z,{menu:{items:c},children:(0,l.jsx)(i.Z,{children:r})})})]})]})},d=s(80588);let m=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let s=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},x=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let s=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to delete team: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to delete key:",e),e}},p=async function(e,t,s){let l=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let r="/user/info";"App Owner"==s&&t&&(r="".concat(r,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",l),l&&(r="".concat(r,"?view_all=true"));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw d.ZP.error(e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},j=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}},g=async(e,t,s)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t,s)=>{try{let t=await fetch("/model/metrics",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,t,s)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,t)=>{try{let s="/global/spend/logs";console.log("in keySpendLogsCall:",s);let l=await fetch("".concat(s,"?api_key=").concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw d.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},Z=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let s=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t,s,l,r,a)=>{try{console.log("user role in spend logs call: ".concat(s));let t="/spend/logs";t="App Owner"==s?"".concat(t,"?user_id=").concat(l,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(t,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw d.ZP.error(e),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},k=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t)=>{try{t&&JSON.stringify({api_key:t});let s={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};t&&(s.body=JSON.stringify({api_key:t}));let l=await fetch("/global/spend/end_users",s);if(!l.ok){let e=await l.text();throw d.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},N=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t)=>{try{let s=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,t,s,l)=>{try{let r=await fetch("/user/request_model",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({models:[t],user_id:s,justification:l})});if(!r.ok){let e=await r.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},C=async e=>{try{let t="/user/get_requests";console.log("in userGetRequesedtModelsCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to get requested models:",e),e}},T=async(e,t)=>{try{let s="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",s);let l=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},I=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let s=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let s=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to update team: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("Update Team Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,t,s)=>{try{console.log("Form Values in teamMemberAddCall:",s);let l=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:s})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,t)=>{try{console.log("Form Values in userUpdateUserCall:",t);let s=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_role:"proxy_admin_viewer",...t})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,t)=>{try{let s=await fetch("/global/predict/spend/logs",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:t})});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}};var O=s(10384),R=s(46453),D=s(2179),U=s(71801),z=s(42440),B=s(55217),L=s(50670),K=s(12143),V=s(77171),q=s(42539),J=s(88707),G=s(1861);let{Option:W}=L.default;var $=e=>{let{userID:t,team:s,userRole:a,accessToken:n,data:o,setData:i}=e,[c]=K.Z.useForm(),[h,u]=(0,r.useState)(!1),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(null),[y,f]=(0,r.useState)([]),Z=()=>{u(!1),c.resetFields()},_=()=>{u(!1),p(null),c.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===t||null===a)return;if(null!==n){let e=(await w(n,t,a)).data.map(e=>e.id);console.log("available_model_names:",e),f(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,t,a]);let k=async e=>{try{d.ZP.info("Making API Call"),u(!0);let s=await m(n,t,e);console.log("key create Response:",s),i(e=>e?[...e,s]:[s]),p(s.key),g(s.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,l.jsxs)("div",{children:[(0,l.jsx)(D.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,l.jsx)(V.Z,{title:"Create Key",visible:h,width:800,footer:null,onOk:Z,onCancel:_,children:(0,l.jsxs)(K.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===a||"Admin"===a?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Team ID",name:"team_id",initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,l.jsx)(q.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:s&&s.models?s.models.map(e=>(0,l.jsx)(W,{value:e,children:e},e)):y.map(e=>(0,l.jsx)(W,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&s&&null!==s.max_budget&&t>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,l.jsxs)(L.default,{defaultValue:null,placeholder:"n/a",children:[(0,l.jsx)(L.default.Option,{value:"24h",children:"daily"}),(0,l.jsx)(L.default.Option,{value:"30d",children:"monthly"})]})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&s&&null!==s.tpm_limit&&t>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&s&&null!==s.rpm_limit&&t>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(q.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Key Name",name:"key_alias",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Team ID (Contact Group)",name:"team_id",children:(0,l.jsx)(q.Z,{placeholder:"default team (create a new team)"})}),(0,l.jsx)(K.Z.Item,{label:"Description",name:"description",children:(0,l.jsx)(q.Z.TextArea,{placeholder:"Enter description",rows:4})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Create Key"})})]})}),x&&(0,l.jsx)(V.Z,{visible:h,onOk:Z,onCancel:_,footer:null,children:(0,l.jsxs)(R.Z,{numItems:1,className:"gap-2 w-full",children:[(0,l.jsx)(z.Z,{children:"Save your Key"}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,l.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:null!=x?(0,l.jsxs)("div",{children:[(0,l.jsx)(U.Z,{className:"mt-3",children:"API Key:"}),(0,l.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,l.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:x})}),(0,l.jsx)(B.CopyToClipboard,{text:x,onCopy:()=>{d.ZP.success("API Key copied to clipboard")},children:(0,l.jsx)(D.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,l.jsx)(U.Z,{children:"Key being created, this might take 30s"})})]})})]})},Y=s(9454),H=s(33393),X=s(5),Q=s(9853),ee=s(13810),et=s(39290),es=s(66952),el=s(61244),er=s(10827),ea=s(3851),en=s(2044),eo=s(64167),ei=s(74480),ec=s(7178),ed=e=>{let{userID:t,accessToken:s,selectedTeam:a,data:n,setData:o}=e,[i,c]=(0,r.useState)(!1),[d,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(null),[p,j]=r.useState(null),[g,y]=(0,r.useState)(null),[w,Z]=(0,r.useState)(null),[_,k]=(0,r.useState)(""),b=async e=>{try{if(null==s||null==e)return;console.log("accessToken: ".concat(s,"; token: ").concat(e.token));let t=await f(s,e.token);console.log("Response:",t),Z(t);let l=await M(s,t);console.log("Response2:",l);let r=[...t,...l.response];Z(r),k(l.predicted_spend),console.log("Combined Data:",r)}catch(e){console.error("There was an error fetching the data",e)}};(0,r.useEffect)(()=>{b(g)},[g]);let v=async e=>{null!=n&&(x(e),localStorage.removeItem("userData"+t),m(!0))},N=async()=>{if(null!=h&&null!=n){try{await u(s,h);let e=n.filter(e=>e.token!==h);o(e)}catch(e){console.error("Error deleting the key:",e)}m(!1),x(null)}};if(null!=n)return console.log("RERENDER TRIGGERED"),(0,l.jsx)("div",{children:(0,l.jsxs)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,l.jsxs)(er.Z,{className:"mt-5",children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Key Alias"}),(0,l.jsx)(ei.Z,{children:"Secret Key"}),(0,l.jsx)(ei.Z,{children:"Spend (USD)"}),(0,l.jsx)(ei.Z,{children:"Budget (USD)"}),(0,l.jsx)(ei.Z,{children:"Models"}),(0,l.jsx)(ei.Z,{children:"TPM / RPM Limits"})]})}),(0,l.jsx)(ea.Z,{children:n.map(e=>(console.log(e),"litellm-dashboard"===e.team_id||a&&e.team_id!=a.team_id)?null:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,l.jsx)(U.Z,{children:e.key_alias}):(0,l.jsx)(U.Z,{children:"Not Set"})}),(0,l.jsx)(en.Z,{children:(0,l.jsx)(U.Z,{children:e.key_name})}),(0,l.jsx)(en.Z,{children:(0,l.jsx)(U.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(t){return e.spend}})()})}),(0,l.jsx)(en.Z,{children:null!=e.max_budget?(0,l.jsx)(U.Z,{children:e.max_budget}):(0,l.jsx)(U.Z,{children:"Unlimited"})}),(0,l.jsx)(en.Z,{children:Array.isArray(e.models)?(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,l.jsx)(l.Fragment,{children:a&&a.models&&a.models.length>0?a.models.map((e,t)=>(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,l.jsx)(U.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t)):(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"purple",children:(0,l.jsx)(U.Z,{children:"All Models"})})}):e.models.map((e,t)=>(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,l.jsx)(U.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,l.jsx)(en.Z,{children:(0,l.jsxs)(U.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsxs)(en.Z,{children:[(0,l.jsx)(el.Z,{onClick:()=>{y(e),j(e.id)},icon:Y.Z,size:"sm"}),(0,l.jsx)(et.Z,{open:null!==p,onClose:()=>{j(null),y(null)},children:(0,l.jsx)(es.Z,{children:g&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3",children:[(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,l.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,l.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(g.spend).toFixed(4)}catch(e){return g.spend}})()})})]}),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,l.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,l.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=g.max_budget?(0,l.jsx)(l.Fragment,{children:g.max_budget}):(0,l.jsx)(l.Fragment,{children:"Unlimited"})})})]},e.name),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,l.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,l.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=g.expires?(0,l.jsx)(l.Fragment,{children:new Date(g.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,l.jsx)(l.Fragment,{children:"Never"})})})]},e.name)]}),(0,l.jsx)(ee.Z,{className:"mt-6 mb-6",children:w&&(0,l.jsx)(Q.Z,{className:"mt-6",data:w,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})}),(0,l.jsx)(z.Z,{children:"Metadata"}),(0,l.jsx)(U.Z,{children:JSON.stringify(g.metadata)}),(0,l.jsx)(D.Z,{variant:"light",className:"mx-auto flex items-center",onClick:()=>{j(null),y(null)},children:"Close"})]})})}),(0,l.jsx)(el.Z,{onClick:()=>v(e.token),icon:H.Z,size:"sm"})]})]},e.token))})]}),d&&(0,l.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,l.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,l.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,l.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,l.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,l.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,l.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,l.jsx)("div",{className:"sm:flex sm:items-start",children:(0,l.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,l.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,l.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,l.jsx)(D.Z,{onClick:N,color:"red",className:"ml-2",children:"Delete"}),(0,l.jsx)(D.Z,{onClick:()=>{m(!1),x(null)},children:"Cancel"})]})]})]})})]})})},em=e=>{let{userID:t,userSpendData:s,userRole:a,accessToken:n}=e,[o,i]=(0,r.useState)(null==s?void 0:s.spend),[c,d]=(0,r.useState)((null==s?void 0:s.max_budget)||null);(0,r.useEffect)(()=>{(async()=>{if("Admin"===a)try{let e=await j(n);i(e.spend),d(e.max_budget||null)}catch(e){console.error("Error fetching global spend data:",e)}})()},[a,n]);let m=void 0!==o?o.toFixed(5):null;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,l.jsxs)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",m]})]})},eh=s(55901),eu=s(27166),ex=e=>{let{teams:t,setSelectedTeam:s}=e,[a,n]=(0,r.useState)("");return(0,l.jsxs)("div",{className:"mt-5 mb-5",children:[(0,l.jsx)(z.Z,{children:"Select Team"}),(0,l.jsx)(U.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),t&&t.length>0?(0,l.jsx)(eh.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(eu.Z,{value:String(t),onClick:()=>s(e),children:e.team_alias},t))}):(0,l.jsxs)(U.Z,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]})},ep=s(37963),ej=s(36083);console.log("isLocal:",!1);var eg=e=>{let{userID:t,userRole:s,teams:n,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,r.useState)(null),g=(0,a.useSearchParams)();g.get("viewSpend"),(0,a.useRouter)();let y=g.get("token"),[f,Z]=(0,r.useState)(null),[_,k]=(0,r.useState)([]),[b,v]=(0,r.useState)(n?n[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,ep.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),Z(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&&f&&s&&!o&&!u){let e=sessionStorage.getItem("userModels"+t);e?k(JSON.parse(e)):(async()=>{try{let e=await p(f,t,s);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await j(f);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 l=(await w(f,t,s)).data.map(e=>e.id);console.log("available_model_names:",l),k(l),console.log("userModels:",_),sessionStorage.setItem("userModels"+t,JSON.stringify(l))}catch(e){console.error("There was an error fetching the data",e)}})()}},[t,y,f,o,s]),null==t||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==f)return null;if(null==s&&i("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:t}=ej.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",b),(0,l.jsx)("div",{className:"w-full mx-4",children:(0,l.jsx)(R.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(em,{userID:t,userSpendData:u,userRole:s,accessToken:f}),(0,l.jsx)(ed,{userID:t,accessToken:f,selectedTeam:b||null,data:o,setData:h}),(0,l.jsx)($,{userID:t,team:b||null,userRole:s,accessToken:f,data:o,setData:h},b?b.team_id:null),(0,l.jsx)(ex,{teams:n,setSelectedTeam:v})]})})})};let{Option:ey}=L.default;var ew=e=>{let{userModels:t,accessToken:s,userID:a}=e,[n]=K.Z.useForm(),[o,i]=(0,r.useState)(!1),c=async e=>{try{d.ZP.info("Requesting access");let{selectedModel:t,accessReason:l}=e;await A(s,t,a,l),i(!0)}catch(e){console.error("Error requesting access:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(D.Z,{size:"xs",onClick:()=>i(!0),children:"Request Access"}),(0,l.jsx)(V.Z,{title:"Request Access",visible:o,width:800,footer:null,onOk:()=>{i(!1),n.resetFields()},onCancel:()=>{i(!1),n.resetFields()},children:(0,l.jsxs)(K.Z,{form:n,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(K.Z.Item,{label:"Select Model",name:"selectedModel",children:(0,l.jsx)(L.default,{placeholder:"Select model",style:{width:"100%"},children:t.map(e=>(0,l.jsx)(ey,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Reason for Access",name:"accessReason",children:(0,l.jsx)(q.Z.TextArea,{rows:4,placeholder:"Enter reason for access"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(D.Z,{children:"Request Access"})})]})})]})},ef=e=>{let{accessToken:t,token:s,userRole:a,userID:n}=e,[o,i]=(0,r.useState)({data:[]}),[c,d]=(0,r.useState)([]),[m,h]=(0,r.useState)([]);if((0,r.useEffect)(()=>{if(!t||!s||!a||!n)return;let e=async()=>{try{let e=await g(t,n,a);console.log("Model data response:",e.data),i(e);let s=await y(t,n,a);if(console.log("Model metrics response:",s),d(s),"Admin"===a&&t){let e=await C(t);console.log("Pending Requests:",m),h(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&a&&n&&e()},[t,s,a,n]),!o||!t||!s||!a||!n)return(0,l.jsx)("div",{children:"Loading..."});let u=[];for(let e=0;e(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:(0,l.jsx)(z.Z,{children:e.model_name})}),(0,l.jsx)(en.Z,{children:e.provider}),"Admin"===a&&(0,l.jsx)(en.Z,{children:e.api_base}),(0,l.jsx)(en.Z,{children:e.user_access?(0,l.jsx)(X.Z,{color:"green",children:"Yes"}):(0,l.jsx)(ew,{userModels:u,accessToken:t,userID:n})}),(0,l.jsx)(en.Z,{children:e.input_cost}),(0,l.jsx)(en.Z,{children:e.output_cost}),(0,l.jsx)(en.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Model Statistics (Number Requests)"}),(0,l.jsx)(Q.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Model Statistics (Latency)"}),(0,l.jsx)(Q.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})})},eZ=s(92836),e_=s(26734),ek=s(41608),eb=s(32126),ev=s(23682);let{Option:eN}=L.default;var eS=e=>{let{userID:t,accessToken:s}=e,[a]=K.Z.useForm(),[n,o]=(0,r.useState)(!1),[i,c]=(0,r.useState)(null),[m,u]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await w(s,t,"any"),l=[];for(let t=0;t{o(!1),a.resetFields()},p=()=>{o(!1),c(null),a.resetFields()},j=async e=>{try{d.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let l=await h(s,t,e);console.log("user create Response:",l),c(l.key),d.ZP.success("API user Created"),a.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the user:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(D.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Create New User"}),(0,l.jsx)(V.Z,{title:"Create User",visible:n,width:800,footer:null,onOk:x,onCancel:p,children:(0,l.jsxs)(K.Z,{form:a,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(K.Z.Item,{label:"User ID",name:"user_id",children:(0,l.jsx)(q.Z,{placeholder:"Enter User ID"})}),(0,l.jsx)(K.Z.Item,{label:"Team ID",name:"team_id",children:(0,l.jsx)(q.Z,{placeholder:"ai_team"})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:m.map(e=>(0,l.jsx)(eN,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(q.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Create User"})})]})}),i&&(0,l.jsxs)(V.Z,{title:"Save Your User",visible:n,onOk:x,onCancel:p,footer:null,children:[(0,l.jsxs)("p",{children:["Please save this secret user somewhere safe and accessible. For security reasons, ",(0,l.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret user, you will need to generate a new one."]}),(0,l.jsx)("p",{children:null!=i?"API user: ".concat(i):"User being created, this might take 30s"})]})]})},eA=e=>{let{accessToken:t,token:s,keys:a,userRole:n,userID:o,setKeys:i}=e,[c,d]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),[u,x]=(0,r.useState)(1);if((0,r.useEffect)(()=>{if(!t||!s||!n||!o)return;let e=async()=>{try{let e=await p(t,null,n,!0);console.log("user data response:",e),d(e)}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&n&&o&&!c&&e();let l=async()=>{try{let e=await v(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&&l()},[t,s,n,o]),!c||!t||!s||!n||!o)return(0,l.jsx)("div",{children:"Loading..."});let j=async e=>{try{let s=await v(t,e);console.log("user data response:",s),h(s)}catch(e){console.error("There was an error fetching the model data",e)}};return(0,l.jsx)("div",{style:{width:"100%"},children:(0,l.jsxs)(R.Z,{className:"gap-2 p-2 h-[75vh] w-full mt-8",children:[(0,l.jsx)(eS,{userID:o,accessToken:t}),(0,l.jsx)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{variant:"line",defaultValue:"1",children:[(0,l.jsx)(eZ.Z,{value:"1",children:"Key Owners"}),(0,l.jsx)(eZ.Z,{value:"2",children:"End-Users"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(er.Z,{className:"mt-5",children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"User ID"}),(0,l.jsx)(ei.Z,{children:"User Role"}),(0,l.jsx)(ei.Z,{children:"User Models"}),(0,l.jsx)(ei.Z,{children:"User Spend ($ USD)"}),(0,l.jsx)(ei.Z,{children:"User Max Budget ($ USD)"})]})}),(0,l.jsx)(ea.Z,{children:c.map(e=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.user_id}),(0,l.jsx)(en.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,l.jsx)(en.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,l.jsx)(en.Z,{children:e.spend?e.spend:0}),(0,l.jsx)(en.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,l.jsxs)(eb.Z,{children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("div",{className:"flex-1"}),(0,l.jsxs)("div",{className:"flex-1 flex justify-between items-center",children:[(0,l.jsx)(U.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,l.jsx)(eh.Z,{defaultValue:"1",className:"w-3/4",children:null==a?void 0:a.map((e,t)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,l.jsx)(eu.Z,{value:String(t),onClick:()=>j(e.token),children:e.key_name},t)})})]})]}),(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"End User"}),(0,l.jsx)(ei.Z,{children:"Spend"}),(0,l.jsx)(ei.Z,{children:"Total Events"})]})}),(0,l.jsx)(ea.Z,{children:null==m?void 0:m.map((e,t)=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.end_user}),(0,l.jsx)(en.Z,{children:e.total_spend}),(0,l.jsx)(en.Z,{children:e.total_events})]},t))})]})]})]})]})}),function(){if(!c)return null;let e=Math.ceil(c.length/25),t=Math.min(25*u,c.length);return(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsxs)("div",{children:["Showing ",(u-1)*25+1," – ",t," of ",c.length]}),(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===u,onClick:()=>x(u-1),children:"← Prev"}),(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:u===e,onClick:()=>x(u+1),children:"Next →"})]})]})}()]})})},eC=s(98941),eT=e=>{let{teams:t,searchParams:s,accessToken:a,setTeams:n,userID:o,userRole:i}=e,[c]=K.Z.useForm(),[m]=K.Z.useForm(),{Title:h,Paragraph:u}=ej.default,[p,j]=(0,r.useState)(""),[g,y]=(0,r.useState)(!1),[f,Z]=(0,r.useState)(t?t[0]:null),[_,k]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[N,S]=(0,r.useState)([]),[A,C]=(0,r.useState)(!1),[T,F]=(0,r.useState)(null),M=e=>{Z(e),y(!0)},z=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==a)return;let l=await P(a,e);t&&n(t.map(e=>e.team_id===s?l.data:e)),d.ZP.success("Team updated successfully"),y(!1),Z(null)},B=async e=>{F(e),C(!0)},W=async()=>{if(null!=T&&null!=t&&null!=a){try{await x(a,T);let e=t.filter(e=>e.team_id!==T);n(e)}catch(e){console.error("Error deleting the team:",e)}C(!1),F(null)}};(0,r.useEffect)(()=>{(async()=>{try{if(null===o||null===i)return;if(null!==a){let e=(await w(a,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),S(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,o,i]);let $=async e=>{try{if(null!=a){d.ZP.info("Creating Team");let s=await I(a,e);null!==t?n([...t,s]):n([s]),console.log("response for team create call: ".concat(s)),d.ZP.success("Team created"),k(!1)}}catch(e){console.error("Error creating the team:",e),d.ZP.error("Error creating the team: "+e)}},Y=async e=>{try{if(null!=a&&null!=t){d.ZP.info("Adding Member");let s={role:"user",user_email:e.user_email,user_id:e.user_id},l=await E(a,f.team_id,s);console.log("response for team create call: ".concat(l.data));let r=t.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(l.data.team_id)),e.team_id===l.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...t];e[r]=l.data,n(e),Z(l.data)}v(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(t)),(0,l.jsx)("div",{className:"w-full mx-4",children:(0,l.jsxs)(R.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(h,{level:4,children:"All Teams"}),(0,l.jsxs)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Team Name"}),(0,l.jsx)(ei.Z,{children:"Spend (USD)"}),(0,l.jsx)(ei.Z,{children:"Budget (USD)"}),(0,l.jsx)(ei.Z,{children:"Models"}),(0,l.jsx)(ei.Z,{children:"TPM / RPM Limits"})]})}),(0,l.jsx)(ea.Z,{children:t&&t.length>0?t.map(e=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,l.jsx)(en.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"purple",children:(0,l.jsx)(U.Z,{children:"All Models"})}):e.models.map((e,t)=>(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,l.jsx)(U.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsxs)(U.Z,{children:["TPM:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsxs)(en.Z,{children:[(0,l.jsx)(el.Z,{icon:eC.Z,size:"sm",onClick:()=>M(e)}),(0,l.jsx)(el.Z,{onClick:()=>B(e.team_id),icon:H.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,l.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,l.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,l.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,l.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,l.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,l.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,l.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,l.jsx)("div",{className:"sm:flex sm:items-start",children:(0,l.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,l.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,l.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,l.jsx)(D.Z,{onClick:W,color:"red",className:"ml-2",children:"Delete"}),(0,l.jsx)(D.Z,{onClick:()=>{C(!1),F(null)},children:"Cancel"})]})]})]})})]})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(D.Z,{className:"mx-auto",onClick:()=>k(!0),children:"+ Create New Team"}),(0,l.jsx)(V.Z,{title:"Create Team",visible:_,width:800,footer:null,onOk:()=>{k(!1),c.resetFields()},onCancel:()=>{k(!1),c.resetFields()},children:(0,l.jsxs)(K.Z,{form:c,onFinish:$,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:N.map(e=>(0,l.jsx)(L.default.Option,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(h,{level:4,children:"Team Members"}),(0,l.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),t&&t.length>0?(0,l.jsx)(eh.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(eu.Z,{value:String(t),onClick:()=>{Z(e)},children:e.team_alias},t))}):(0,l.jsxs)(u,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Member Name"}),(0,l.jsx)(ei.Z,{children:"Role"})]})}),(0,l.jsx)(ea.Z,{children:f?f.members_with_roles.map((e,t)=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(en.Z,{children:e.role})]},t)):null})]})}),f&&(0,l.jsx)(e=>{let{visible:t,onCancel:s,team:r,onSubmit:a}=e,[n]=K.Z.useForm();return(0,l.jsx)(V.Z,{title:"Edit Team",visible:t,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{a({...e,team_id:r.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,l.jsxs)(K.Z,{form:n,onFinish:z,initialValues:r,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:N&&N.map(e=>(0,l.jsx)(L.default.Option,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:g,onCancel:()=>{y(!1),Z(null)},team:f,onSubmit:z})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(D.Z,{className:"mx-auto mb-5",onClick:()=>v(!0),children:"+ Add member"}),(0,l.jsx)(V.Z,{title:"Add member",visible:b,width:800,footer:null,onOk:()=>{v(!1),m.resetFields()},onCancel:()=>{v(!1),m.resetFields()},children:(0,l.jsxs)(K.Z,{form:c,onFinish:Y,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(K.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eI=e=>{let{searchParams:t,accessToken:s}=e,[a]=K.Z.useForm(),[n]=K.Z.useForm(),{Title:o,Paragraph:i}=ej.default,[c,m]=(0,r.useState)(""),[h,u]=(0,r.useState)(null),[x,p]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{if(null!=s){let e=[],t=await T(s,"proxy_admin_viewer");t.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy viewers: ".concat(t));let l=await T(s,"proxy_admin");l.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy admins: ".concat(l)),console.log("combinedList: ".concat(e)),u(e)}})()},[s]);let j=async e=>{try{if(null!=s&&null!=h){d.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await F(s,e);console.log("response for team create call: ".concat(t));let l=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(l)),-1==l&&(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,l.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,l.jsx)(o,{level:4,children:"Restricted Access"}),(0,l.jsxs)(i,{children:["Add other people to just view spend. They cannot create keys, teams or grant users access to new models."," ",(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"})]}),(0,l.jsxs)(R.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsx)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Member Name"}),(0,l.jsx)(ei.Z,{children:"Role"})]})}),(0,l.jsx)(ea.Z,{children:h?h.map((e,t)=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(en.Z,{children:e.user_role})]},t)):null})]})})}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(D.Z,{className:"mx-auto mb-5",onClick:()=>p(!0),children:"+ Add viewer"}),(0,l.jsx)(V.Z,{title:"Add viewer",visible:x,width:800,footer:null,onOk:()=>{p(!1),n.resetFields()},onCancel:()=>{p(!1),n.resetFields()},children:(0,l.jsxs)(K.Z,{form:a,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(K.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})]})},eP=s(52273),eE=s(12968),eF=s(67951);async function eM(e,t,s,l){console.log("isLocal:",!1);let r=window.location.origin,a=new eE.ZP.OpenAI({apiKey:l,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let l of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(l),l.choices[0].delta.content&&t(l.choices[0].delta.content)}catch(e){d.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e))}}var eO=e=>{let{accessToken:t,token:s,userRole:a,userID:n}=e,[o,i]=(0,r.useState)(""),[c,d]=(0,r.useState)(""),[m,h]=(0,r.useState)([]),[u,x]=(0,r.useState)(void 0),[p,j]=(0,r.useState)([]);(0,r.useEffect)(()=>{t&&s&&a&&n&&(async()=>{try{let e=await w(t,n,a);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,a]);let g=(e,t)=>{h(s=>{let l=s[s.length-1];return l&&l.role===e?[...s.slice(0,s.length-1),{role:e,content:l.content+t}]:[...s,{role:e,content:t}]})},y=async()=>{if(""!==c.trim()&&o&&s&&a&&n){h(e=>[...e,{role:"user",content:c}]);try{u&&await eM(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(a&&"Admin Viewer"==a){let{Title:e,Paragraph:t}=ej.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to test models"})]})}return(0,l.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,l.jsx)(R.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,l.jsx)(ee.Z,{children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{children:[(0,l.jsx)(eZ.Z,{children:"Chat"}),(0,l.jsx)(eZ.Z,{children:"API Reference"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsxs)(eb.Z,{children:[(0,l.jsx)("div",{className:"sm:max-w-2xl",children:(0,l.jsxs)(R.Z,{numItems:2,children:[(0,l.jsxs)(O.Z,{children:[(0,l.jsx)(U.Z,{children:"API Key"}),(0,l.jsx)(eP.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,l.jsxs)(O.Z,{className:"mx-2",children:[(0,l.jsx)(U.Z,{children:"Select Model:"}),(0,l.jsx)(L.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,l.jsxs)(er.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,l.jsx)(eo.Z,{children:(0,l.jsx)(ec.Z,{children:(0,l.jsx)(en.Z,{})})}),(0,l.jsx)(ea.Z,{children:m.map((e,t)=>(0,l.jsx)(ec.Z,{children:(0,l.jsx)(en.Z,{children:"".concat(e.role,": ").concat(e.content)})},t))})]}),(0,l.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)(eP.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,l.jsx)(D.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]}),(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{children:[(0,l.jsx)(eZ.Z,{children:"OpenAI Python SDK"}),(0,l.jsx)(eZ.Z,{children:"LlamaIndex"}),(0,l.jsx)(eZ.Z,{children:"Langchain Py"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsx)(eb.Z,{children:(0,l.jsx)(eF.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # proxy base url\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to use from Models Tab\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ],\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-openai-client",\n "generation_id": "openai-client-gen-id22",\n "trace_id": "openai-client-trace-id22",\n "trace_user_id": "openai-client-user-id2"\n }\n }\n)\n\nprint(response)\n '})}),(0,l.jsx)(eb.Z,{children:(0,l.jsx)(eF.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,l.jsx)(eb.Z,{children:(0,l.jsx)(eF.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 '})})]})]})})]})]})})})})},eR=s(33509),eD=s(95781);let{Sider:eU}=eR.default;var ez=e=>{let{setPage:t,userRole:s,defaultSelectedKey:r}=e;return"Admin Viewer"==s?(0,l.jsx)(eR.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,l.jsx)(eU,{width:120,children:(0,l.jsxs)(eD.Z,{mode:"inline",defaultSelectedKeys:r||["4"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eD.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"4"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"1")]})})}):(0,l.jsx)(eR.default,{style:{minHeight:"100vh",maxWidth:"100px"},children:(0,l.jsx)(eU,{width:100,children:(0,l.jsxs)(eD.Z,{mode:"inline",defaultSelectedKeys:r||["1"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eD.Z.Item,{onClick:()=>t("api-keys"),children:(0,l.jsx)(U.Z,{children:"API Keys"})},"1"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("llm-playground"),children:(0,l.jsx)(U.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,l.jsx)(eD.Z.Item,{onClick:()=>t("teams"),children:(0,l.jsx)(U.Z,{children:"Teams"})},"6"):null,(0,l.jsx)(eD.Z.Item,{onClick:()=>t("usage"),children:(0,l.jsx)(U.Z,{children:"Usage"})},"4"),"Admin"==s?(0,l.jsx)(eD.Z.Item,{onClick:()=>t("users"),children:(0,l.jsx)(U.Z,{children:"Users"})},"5"):null,(0,l.jsx)(eD.Z.Item,{onClick:()=>t("models"),children:(0,l.jsx)(U.Z,{children:"Models"})},"2"),"Admin"==s?(0,l.jsx)(eD.Z.Item,{onClick:()=>t("admin-panel"),children:(0,l.jsx)(U.Z,{children:"Admin"})},"7"):null]})})})},eB=e=>{let{accessToken:t,token:s,userRole:a,userID:n}=e,o=new Date,[i,c]=(0,r.useState)([]),[d,m]=(0,r.useState)([]),[h,u]=(0,r.useState)([]),[x,p]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[y,w]=(0,r.useState)([]),[f,v]=(0,r.useState)([]),A=new Date(o.getFullYear(),o.getMonth(),1),C=new Date(o.getFullYear(),o.getMonth()+1,0),T=P(A),I=P(C);function P(e){let t=e.getFullYear(),s=e.getMonth()+1,l=e.getDate();return"".concat(t,"-").concat(s<10?"0"+s:s,"-").concat(l<10?"0"+l:l)}return console.log("Start date is ".concat(T)),console.log("End date is ".concat(I)),(0,r.useEffect)(()=>{t&&s&&a&&n&&(async()=>{try{if(console.log("user role: ".concat(a)),"Admin"==a||"Admin Viewer"==a){let e=await k(t);c(e);let s=(await b(t)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,7),spend:e.total_spend}));m(s);let l=(await N(t)).map(e=>({key:e.model,spend:e.total_spend}));u(l);let r=await Z(t);console.log("teamSpend",r),g(r.daily_spend),w(r.teams),v(r.total_spend_per_team)}else"App Owner"==a&&await _(t,s,a,n,T,I).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let t=e.daily_spend;console.log("daily spend",t),c(t);let s=e.top_api_keys;m(s)}else{let s=(await S(t,function(e){let t=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,l]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&t.push({key:s,spend:l})})}),t.sort((e,t)=>Number(t.spend)-Number(e.spend));let s=t.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias||e.token).substring(0,7),spend:e.spend}));m(s),p(function(e){let t={};e.forEach(e=>{Object.entries(e.users).forEach(e=>{let[s,l]=e;""!==s&&null!=s&&"None"!=s&&(t[s]||(t[s]=0),t[s]+=l)})});let s=Object.entries(t).map(e=>{let[t,s]=e;return{user_id:t,spend:s}});s.sort((e,t)=>t.spend-e.spend);let l=s.slice(0,5);return console.log("topKeys: ".concat(Object.values(l[0]))),l}(e)),c(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[t,s,a,n,T,I]),(0,l.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{className:"mt-2",children:[(0,l.jsx)(eZ.Z,{children:"All Up"}),(0,l.jsx)(eZ.Z,{children:"Team Based Usage"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(R.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,l.jsx)(O.Z,{numColSpan:2,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Monthly Spend"}),(0,l.jsx)(Q.Z,{data:i,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Top API Keys"}),(0,l.jsx)(Q.Z,{className:"mt-4 h-40",data:d,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Top Users"}),(0,l.jsx)(Q.Z,{className:"mt-4 h-40",data:x,index:"user_id",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Top Models"}),(0,l.jsx)(Q.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(R.Z,{numItems:2,className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(O.Z,{numColSpan:2,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Daily Spend Per Team"}),(0,l.jsx)(Q.Z,{className:"h-72",data:j,index:"date",categories:y,yAxisWidth:30,stack:!0})]})}),(0,l.jsx)(O.Z,{numColSpan:2,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Total Spend Per Team"}),(0,l.jsx)(Q.Z,{className:"h-72",data:f,index:"team_id",categories:["total_spend"],yAxisWidth:30})]})})]})})]})]})})},eL=()=>{let{Title:e,Paragraph:t}=ej.default,[s,n]=(0,r.useState)(""),[o,i]=(0,r.useState)(null),[d,m]=(0,r.useState)(null),[h,u]=(0,r.useState)(null),[x,p]=(0,r.useState)(!0),j=(0,a.useSearchParams)(),g=j.get("userID"),y=j.get("token"),[w,f]=(0,r.useState)("api-keys"),[Z,_]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(y){let e=(0,ep.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),_(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,l.jsx)(r.Suspense,{fallback:(0,l.jsx)("div",{children:"Loading..."}),children:(0,l.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,l.jsx)(c,{userID:g,userRole:s,userEmail:o,showSSOBanner:x}),(0,l.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,l.jsx)("div",{className:"mt-8",children:(0,l.jsx)(ez,{setPage:f,userRole:s,defaultSelectedKey:null})}),"api-keys"==w?(0,l.jsx)(eg,{userID:g,userRole:s,teams:d,keys:h,setUserRole:n,userEmail:o,setUserEmail:i,setTeams:m,setKeys:u}):"models"==w?(0,l.jsx)(ef,{userID:g,userRole:s,token:y,accessToken:Z}):"llm-playground"==w?(0,l.jsx)(eO,{userID:g,userRole:s,token:y,accessToken:Z}):"users"==w?(0,l.jsx)(eA,{userID:g,userRole:s,token:y,keys:h,accessToken:Z,setKeys:u}):"teams"==w?(0,l.jsx)(eT,{teams:d,setTeams:m,searchParams:j,accessToken:Z,userID:g,userRole:s}):"admin-panel"==w?(0,l.jsx)(eI,{setTeams:m,searchParams:j,accessToken:Z}):(0,l.jsx)(eB,{userID:g,userRole:s,token:y,accessToken:Z})]})]})})}}},function(e){e.O(0,[798,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.html b/litellm/proxy/_experimental/out/index.html index 219166a4d..1a2bd5a68 100644 --- a/litellm/proxy/_experimental/out/index.html +++ b/litellm/proxy/_experimental/out/index.html @@ -1 +1,5 @@ -🚅 LiteLLM \ No newline at end of file +<<<<<<< HEAD +🚅 LiteLLM +======= +🚅 LiteLLM +>>>>>>> e6a09427 ((new) ui build) diff --git a/litellm/proxy/_experimental/out/index.txt b/litellm/proxy/_experimental/out/index.txt index cfb598f35..2d4ea3f9e 100644 --- a/litellm/proxy/_experimental/out/index.txt +++ b/litellm/proxy/_experimental/out/index.txt @@ -1,7 +1,14 @@ 2:I[77831,[],""] +<<<<<<< HEAD 3:I[90177,["798","static/chunks/798-4baed68da0c5497d.js","931","static/chunks/app/page-a5a04da2a9356785.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] 0:["DptMjzo5xd96cx0b56k4u",[[["",{"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/f8da5a6a5b29d249.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +======= +3:I[90177,["798","static/chunks/798-4baed68da0c5497d.js","931","static/chunks/app/page-37392d6753f8a3d0.js"],""] +4:I[5613,[],""] +5:I[31778,[],""] +0:["L9N6TOWJaqSp22Vj96YE4",[[["",{"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/f8da5a6a5b29d249.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +>>>>>>> e6a09427 ((new) ui build) 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"🚅 LiteLLM"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/404.html b/ui/litellm-dashboard/out/404.html index 3f4fbaaa4..4ecd3d58f 100644 --- a/ui/litellm-dashboard/out/404.html +++ b/ui/litellm-dashboard/out/404.html @@ -1 +1,5 @@ -404: This page could not be found.🚅 LiteLLM

404

This page could not be found.

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

404

This page could not be found.

+======= +404: This page could not be found.🚅 LiteLLM

404

This page could not be found.

+>>>>>>> e6a09427 ((new) ui build) diff --git a/ui/litellm-dashboard/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_buildManifest.js new file mode 100644 index 000000000..f779caa02 --- /dev/null +++ b/ui/litellm-dashboard/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_buildManifest.js @@ -0,0 +1 @@ +self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/_error":["static/chunks/pages/_error-d6107f1aac0c574c.js"],sortedPages:["/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_ssgManifest.js new file mode 100644 index 000000000..5b3ff592f --- /dev/null +++ b/ui/litellm-dashboard/out/_next/static/L9N6TOWJaqSp22Vj96YE4/_ssgManifest.js @@ -0,0 +1 @@ +self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB() \ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-37392d6753f8a3d0.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-37392d6753f8a3d0.js new file mode 100644 index 000000000..ff0808ac7 --- /dev/null +++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-37392d6753f8a3d0.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,t,s){Promise.resolve().then(s.bind(s,90177))},90177:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eL}});var l=s(3827),r=s(64090),a=s(47907),n=s(8792),o=s(40491),i=s(65270),c=e=>{let{userID:t,userRole:s,userEmail:r,showSSOBanner:a}=e;console.log("User ID:",t),console.log("userEmail:",r);let c=[{key:"1",label:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{children:["Role: ",s]}),(0,l.jsxs)("p",{children:["ID: ",t]})]})}];return(0,l.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,l.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,l.jsx)("div",{className:"flex flex-col items-center",children:(0,l.jsx)(n.default,{href:"/",children:(0,l.jsx)("button",{className:"text-gray-800 text-2xl py-1 rounded text-center",children:(0,l.jsx)("img",{src:"/get_image",width:200,height:200,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,l.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[a?(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#setup-ssoauth-for-ui",target:"_blank",className:"mr-2"}):null,(0,l.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,l.jsx)(o.Z,{menu:{items:c},children:(0,l.jsx)(i.Z,{children:r})})})]})]})},d=s(80588);let m=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t,s)=>{try{if(console.log("Form Values in keyCreateCall:",s),s.description&&(s.metadata||(s.metadata={}),s.metadata.description=s.description,delete s.description,s.metadata=JSON.stringify(s.metadata)),s.metadata){console.log("formValues.metadata:",s.metadata);try{s.metadata=JSON.parse(s.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",s);let l=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...s})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let s=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},x=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let s=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to delete team: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to delete key:",e),e}},p=async function(e,t,s){let l=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let r="/user/info";"App Owner"==s&&t&&(r="".concat(r,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",l),l&&(r="".concat(r,"?view_all=true"));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw d.ZP.error(e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},j=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}},g=async(e,t,s)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t,s)=>{try{let t=await fetch("/model/metrics",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,t,s)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,t)=>{try{let s="/global/spend/logs";console.log("in keySpendLogsCall:",s);let l=await fetch("".concat(s,"?api_key=").concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw d.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},Z=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let s=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t,s,l,r,a)=>{try{console.log("user role in spend logs call: ".concat(s));let t="/spend/logs";t="App Owner"==s?"".concat(t,"?user_id=").concat(l,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(t,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw d.ZP.error(e),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},k=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t)=>{try{t&&JSON.stringify({api_key:t});let s={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};t&&(s.body=JSON.stringify({api_key:t}));let l=await fetch("/global/spend/end_users",s);if(!l.ok){let e=await l.text();throw d.ZP.error(e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},N=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t)=>{try{let s=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,t,s,l)=>{try{let r=await fetch("/user/request_model",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({models:[t],user_id:s,justification:l})});if(!r.ok){let e=await r.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},C=async e=>{try{let t="/user/get_requests";console.log("in userGetRequesedtModelsCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to get requested models:",e),e}},T=async(e,t)=>{try{let s="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",s);let l=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let r=await l.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},I=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let s=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let s=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to update team: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("Update Team Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,t,s)=>{try{console.log("Form Values in teamMemberAddCall:",s);let l=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:s})});if(!l.ok){let e=await l.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await l.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,t)=>{try{console.log("Form Values in userUpdateUserCall:",t);let s=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_role:"proxy_admin_viewer",...t})});if(!s.ok){let e=await s.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let l=await s.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,t)=>{try{let s=await fetch("/global/predict/spend/logs",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:t})});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let l=await s.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}};var O=s(10384),R=s(46453),D=s(2179),U=s(71801),z=s(42440),B=s(55217),L=s(50670),K=s(12143),V=s(77171),q=s(42539),J=s(88707),G=s(1861);let{Option:W}=L.default;var $=e=>{let{userID:t,team:s,userRole:a,accessToken:n,data:o,setData:i}=e,[c]=K.Z.useForm(),[h,u]=(0,r.useState)(!1),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(null),[y,f]=(0,r.useState)([]),Z=()=>{u(!1),c.resetFields()},_=()=>{u(!1),p(null),c.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===t||null===a)return;if(null!==n){let e=(await w(n,t,a)).data.map(e=>e.id);console.log("available_model_names:",e),f(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,t,a]);let k=async e=>{try{d.ZP.info("Making API Call"),u(!0);let s=await m(n,t,e);console.log("key create Response:",s),i(e=>e?[...e,s]:[s]),p(s.key),g(s.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,l.jsxs)("div",{children:[(0,l.jsx)(D.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,l.jsx)(V.Z,{title:"Create Key",visible:h,width:800,footer:null,onOk:Z,onCancel:_,children:(0,l.jsxs)(K.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===a||"Admin"===a?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Team ID",name:"team_id",initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,l.jsx)(q.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:s&&s.models?s.models.map(e=>(0,l.jsx)(W,{value:e,children:e},e)):y.map(e=>(0,l.jsx)(W,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&s&&null!==s.max_budget&&t>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,l.jsxs)(L.default,{defaultValue:null,placeholder:"n/a",children:[(0,l.jsx)(L.default.Option,{value:"24h",children:"daily"}),(0,l.jsx)(L.default.Option,{value:"30d",children:"monthly"})]})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&s&&null!==s.tpm_limit&&t>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,t)=>{if(t&&s&&null!==s.rpm_limit&&t>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(q.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Key Name",name:"key_alias",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Team ID (Contact Group)",name:"team_id",children:(0,l.jsx)(q.Z,{placeholder:"default team (create a new team)"})}),(0,l.jsx)(K.Z.Item,{label:"Description",name:"description",children:(0,l.jsx)(q.Z.TextArea,{placeholder:"Enter description",rows:4})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Create Key"})})]})}),x&&(0,l.jsx)(V.Z,{visible:h,onOk:Z,onCancel:_,footer:null,children:(0,l.jsxs)(R.Z,{numItems:1,className:"gap-2 w-full",children:[(0,l.jsx)(z.Z,{children:"Save your Key"}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,l.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:null!=x?(0,l.jsxs)("div",{children:[(0,l.jsx)(U.Z,{className:"mt-3",children:"API Key:"}),(0,l.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,l.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:x})}),(0,l.jsx)(B.CopyToClipboard,{text:x,onCopy:()=>{d.ZP.success("API Key copied to clipboard")},children:(0,l.jsx)(D.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,l.jsx)(U.Z,{children:"Key being created, this might take 30s"})})]})})]})},Y=s(9454),H=s(33393),X=s(5),Q=s(9853),ee=s(13810),et=s(39290),es=s(66952),el=s(61244),er=s(10827),ea=s(3851),en=s(2044),eo=s(64167),ei=s(74480),ec=s(7178),ed=e=>{let{userID:t,accessToken:s,selectedTeam:a,data:n,setData:o}=e,[i,c]=(0,r.useState)(!1),[d,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(null),[p,j]=r.useState(null),[g,y]=(0,r.useState)(null),[w,Z]=(0,r.useState)(null),[_,k]=(0,r.useState)(""),b=async e=>{try{if(null==s||null==e)return;console.log("accessToken: ".concat(s,"; token: ").concat(e.token));let t=await f(s,e.token);console.log("Response:",t),Z(t);let l=await M(s,t);console.log("Response2:",l);let r=[...t,...l.response];Z(r),k(l.predicted_spend),console.log("Combined Data:",r)}catch(e){console.error("There was an error fetching the data",e)}};(0,r.useEffect)(()=>{b(g)},[g]);let v=async e=>{null!=n&&(x(e),localStorage.removeItem("userData"+t),m(!0))},N=async()=>{if(null!=h&&null!=n){try{await u(s,h);let e=n.filter(e=>e.token!==h);o(e)}catch(e){console.error("Error deleting the key:",e)}m(!1),x(null)}};if(null!=n)return console.log("RERENDER TRIGGERED"),(0,l.jsx)("div",{children:(0,l.jsxs)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,l.jsxs)(er.Z,{className:"mt-5",children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Key Alias"}),(0,l.jsx)(ei.Z,{children:"Secret Key"}),(0,l.jsx)(ei.Z,{children:"Spend (USD)"}),(0,l.jsx)(ei.Z,{children:"Budget (USD)"}),(0,l.jsx)(ei.Z,{children:"Models"}),(0,l.jsx)(ei.Z,{children:"TPM / RPM Limits"})]})}),(0,l.jsx)(ea.Z,{children:n.map(e=>(console.log(e),"litellm-dashboard"===e.team_id||a&&e.team_id!=a.team_id)?null:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,l.jsx)(U.Z,{children:e.key_alias}):(0,l.jsx)(U.Z,{children:"Not Set"})}),(0,l.jsx)(en.Z,{children:(0,l.jsx)(U.Z,{children:e.key_name})}),(0,l.jsx)(en.Z,{children:(0,l.jsx)(U.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(t){return e.spend}})()})}),(0,l.jsx)(en.Z,{children:null!=e.max_budget?(0,l.jsx)(U.Z,{children:e.max_budget}):(0,l.jsx)(U.Z,{children:"Unlimited"})}),(0,l.jsx)(en.Z,{children:Array.isArray(e.models)?(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,l.jsx)(l.Fragment,{children:a&&a.models&&a.models.length>0?a.models.map((e,t)=>(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,l.jsx)(U.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t)):(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"purple",children:(0,l.jsx)(U.Z,{children:"All Models"})})}):e.models.map((e,t)=>(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,l.jsx)(U.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,l.jsx)(en.Z,{children:(0,l.jsxs)(U.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsxs)(en.Z,{children:[(0,l.jsx)(el.Z,{onClick:()=>{y(e),j(e.id)},icon:Y.Z,size:"sm"}),(0,l.jsx)(et.Z,{open:null!==p,onClose:()=>{j(null),y(null)},children:(0,l.jsx)(es.Z,{children:g&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3",children:[(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,l.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,l.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(g.spend).toFixed(4)}catch(e){return g.spend}})()})})]}),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,l.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,l.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=g.max_budget?(0,l.jsx)(l.Fragment,{children:g.max_budget}):(0,l.jsx)(l.Fragment,{children:"Unlimited"})})})]},e.name),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,l.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,l.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=g.expires?(0,l.jsx)(l.Fragment,{children:new Date(g.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,l.jsx)(l.Fragment,{children:"Never"})})})]},e.name)]}),(0,l.jsx)(ee.Z,{className:"mt-6 mb-6",children:w&&(0,l.jsx)(Q.Z,{className:"mt-6",data:w,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})}),(0,l.jsx)(z.Z,{children:"Metadata"}),(0,l.jsx)(U.Z,{children:JSON.stringify(g.metadata)}),(0,l.jsx)(D.Z,{variant:"light",className:"mx-auto flex items-center",onClick:()=>{j(null),y(null)},children:"Close"})]})})}),(0,l.jsx)(el.Z,{onClick:()=>v(e.token),icon:H.Z,size:"sm"})]})]},e.token))})]}),d&&(0,l.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,l.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,l.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,l.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,l.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,l.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,l.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,l.jsx)("div",{className:"sm:flex sm:items-start",children:(0,l.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,l.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,l.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,l.jsx)(D.Z,{onClick:N,color:"red",className:"ml-2",children:"Delete"}),(0,l.jsx)(D.Z,{onClick:()=>{m(!1),x(null)},children:"Cancel"})]})]})]})})]})})},em=e=>{let{userID:t,userSpendData:s,userRole:a,accessToken:n}=e,[o,i]=(0,r.useState)(null==s?void 0:s.spend),[c,d]=(0,r.useState)((null==s?void 0:s.max_budget)||null);(0,r.useEffect)(()=>{(async()=>{if("Admin"===a)try{let e=await j(n);i(e.spend),d(e.max_budget||null)}catch(e){console.error("Error fetching global spend data:",e)}})()},[a,n]);let m=void 0!==o?o.toFixed(5):null;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend"}),(0,l.jsxs)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",m]})]})},eh=s(55901),eu=s(27166),ex=e=>{let{teams:t,setSelectedTeam:s}=e,[a,n]=(0,r.useState)("");return(0,l.jsxs)("div",{className:"mt-5 mb-5",children:[(0,l.jsx)(z.Z,{children:"Select Team"}),(0,l.jsx)(U.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),t&&t.length>0?(0,l.jsx)(eh.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(eu.Z,{value:String(t),onClick:()=>s(e),children:e.team_alias},t))}):(0,l.jsxs)(U.Z,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]})},ep=s(37963),ej=s(36083);console.log("isLocal:",!1);var eg=e=>{let{userID:t,userRole:s,teams:n,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,r.useState)(null),g=(0,a.useSearchParams)();g.get("viewSpend"),(0,a.useRouter)();let y=g.get("token"),[f,Z]=(0,r.useState)(null),[_,k]=(0,r.useState)([]),[b,v]=(0,r.useState)(n?n[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,ep.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),Z(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&&f&&s&&!o&&!u){let e=sessionStorage.getItem("userModels"+t);e?k(JSON.parse(e)):(async()=>{try{let e=await p(f,t,s);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==s){let e=await j(f);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 l=(await w(f,t,s)).data.map(e=>e.id);console.log("available_model_names:",l),k(l),console.log("userModels:",_),sessionStorage.setItem("userModels"+t,JSON.stringify(l))}catch(e){console.error("There was an error fetching the data",e)}})()}},[t,y,f,o,s]),null==t||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==f)return null;if(null==s&&i("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:t}=ej.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",b),(0,l.jsx)("div",{className:"w-full mx-4",children:(0,l.jsx)(R.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(em,{userID:t,userSpendData:u,userRole:s,accessToken:f}),(0,l.jsx)(ed,{userID:t,accessToken:f,selectedTeam:b||null,data:o,setData:h}),(0,l.jsx)($,{userID:t,team:b||null,userRole:s,accessToken:f,data:o,setData:h},b?b.team_id:null),(0,l.jsx)(ex,{teams:n,setSelectedTeam:v})]})})})};let{Option:ey}=L.default;var ew=e=>{let{userModels:t,accessToken:s,userID:a}=e,[n]=K.Z.useForm(),[o,i]=(0,r.useState)(!1),c=async e=>{try{d.ZP.info("Requesting access");let{selectedModel:t,accessReason:l}=e;await A(s,t,a,l),i(!0)}catch(e){console.error("Error requesting access:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(D.Z,{size:"xs",onClick:()=>i(!0),children:"Request Access"}),(0,l.jsx)(V.Z,{title:"Request Access",visible:o,width:800,footer:null,onOk:()=>{i(!1),n.resetFields()},onCancel:()=>{i(!1),n.resetFields()},children:(0,l.jsxs)(K.Z,{form:n,onFinish:c,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(K.Z.Item,{label:"Select Model",name:"selectedModel",children:(0,l.jsx)(L.default,{placeholder:"Select model",style:{width:"100%"},children:t.map(e=>(0,l.jsx)(ey,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Reason for Access",name:"accessReason",children:(0,l.jsx)(q.Z.TextArea,{rows:4,placeholder:"Enter reason for access"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(D.Z,{children:"Request Access"})})]})})]})},ef=e=>{let{accessToken:t,token:s,userRole:a,userID:n}=e,[o,i]=(0,r.useState)({data:[]}),[c,d]=(0,r.useState)([]),[m,h]=(0,r.useState)([]);if((0,r.useEffect)(()=>{if(!t||!s||!a||!n)return;let e=async()=>{try{let e=await g(t,n,a);console.log("Model data response:",e.data),i(e);let s=await y(t,n,a);if(console.log("Model metrics response:",s),d(s),"Admin"===a&&t){let e=await C(t);console.log("Pending Requests:",m),h(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&a&&n&&e()},[t,s,a,n]),!o||!t||!s||!a||!n)return(0,l.jsx)("div",{children:"Loading..."});let u=[];for(let e=0;e(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:(0,l.jsx)(z.Z,{children:e.model_name})}),(0,l.jsx)(en.Z,{children:e.provider}),"Admin"===a&&(0,l.jsx)(en.Z,{children:e.api_base}),(0,l.jsx)(en.Z,{children:e.user_access?(0,l.jsx)(X.Z,{color:"green",children:"Yes"}):(0,l.jsx)(ew,{userModels:u,accessToken:t,userID:n})}),(0,l.jsx)(en.Z,{children:e.input_cost}),(0,l.jsx)(en.Z,{children:e.output_cost}),(0,l.jsx)(en.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Model Statistics (Number Requests)"}),(0,l.jsx)(Q.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Model Statistics (Latency)"}),(0,l.jsx)(Q.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})})},eZ=s(92836),e_=s(26734),ek=s(41608),eb=s(32126),ev=s(23682);let{Option:eN}=L.default;var eS=e=>{let{userID:t,accessToken:s}=e,[a]=K.Z.useForm(),[n,o]=(0,r.useState)(!1),[i,c]=(0,r.useState)(null),[m,u]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{let e=await w(s,t,"any"),l=[];for(let t=0;t{o(!1),a.resetFields()},p=()=>{o(!1),c(null),a.resetFields()},j=async e=>{try{d.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let l=await h(s,t,e);console.log("user create Response:",l),c(l.key),d.ZP.success("API user Created"),a.resetFields(),localStorage.removeItem("userData"+t)}catch(e){console.error("Error creating the user:",e)}};return(0,l.jsxs)("div",{children:[(0,l.jsx)(D.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Create New User"}),(0,l.jsx)(V.Z,{title:"Create User",visible:n,width:800,footer:null,onOk:x,onCancel:p,children:(0,l.jsxs)(K.Z,{form:a,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsx)(K.Z.Item,{label:"User ID",name:"user_id",children:(0,l.jsx)(q.Z,{placeholder:"Enter User ID"})}),(0,l.jsx)(K.Z.Item,{label:"Team ID",name:"team_id",children:(0,l.jsx)(q.Z,{placeholder:"ai_team"})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:m.map(e=>(0,l.jsx)(eN,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Metadata",name:"metadata",children:(0,l.jsx)(q.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Create User"})})]})}),i&&(0,l.jsxs)(V.Z,{title:"Save Your User",visible:n,onOk:x,onCancel:p,footer:null,children:[(0,l.jsxs)("p",{children:["Please save this secret user somewhere safe and accessible. For security reasons, ",(0,l.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret user, you will need to generate a new one."]}),(0,l.jsx)("p",{children:null!=i?"API user: ".concat(i):"User being created, this might take 30s"})]})]})},eA=e=>{let{accessToken:t,token:s,keys:a,userRole:n,userID:o,setKeys:i}=e,[c,d]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),[u,x]=(0,r.useState)(1);if((0,r.useEffect)(()=>{if(!t||!s||!n||!o)return;let e=async()=>{try{let e=await p(t,null,n,!0);console.log("user data response:",e),d(e)}catch(e){console.error("There was an error fetching the model data",e)}};t&&s&&n&&o&&!c&&e();let l=async()=>{try{let e=await v(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&&l()},[t,s,n,o]),!c||!t||!s||!n||!o)return(0,l.jsx)("div",{children:"Loading..."});let j=async e=>{try{let s=await v(t,e);console.log("user data response:",s),h(s)}catch(e){console.error("There was an error fetching the model data",e)}};return(0,l.jsx)("div",{style:{width:"100%"},children:(0,l.jsxs)(R.Z,{className:"gap-2 p-2 h-[75vh] w-full mt-8",children:[(0,l.jsx)(eS,{userID:o,accessToken:t}),(0,l.jsx)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{variant:"line",defaultValue:"1",children:[(0,l.jsx)(eZ.Z,{value:"1",children:"Key Owners"}),(0,l.jsx)(eZ.Z,{value:"2",children:"End-Users"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(er.Z,{className:"mt-5",children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"User ID"}),(0,l.jsx)(ei.Z,{children:"User Role"}),(0,l.jsx)(ei.Z,{children:"User Models"}),(0,l.jsx)(ei.Z,{children:"User Spend ($ USD)"}),(0,l.jsx)(ei.Z,{children:"User Max Budget ($ USD)"})]})}),(0,l.jsx)(ea.Z,{children:c.map(e=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.user_id}),(0,l.jsx)(en.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,l.jsx)(en.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,l.jsx)(en.Z,{children:e.spend?e.spend:0}),(0,l.jsx)(en.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,l.jsxs)(eb.Z,{children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("div",{className:"flex-1"}),(0,l.jsxs)("div",{className:"flex-1 flex justify-between items-center",children:[(0,l.jsx)(U.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,l.jsx)(eh.Z,{defaultValue:"1",className:"w-3/4",children:null==a?void 0:a.map((e,t)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,l.jsx)(eu.Z,{value:String(t),onClick:()=>j(e.token),children:e.key_name},t)})})]})]}),(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"End User"}),(0,l.jsx)(ei.Z,{children:"Spend"}),(0,l.jsx)(ei.Z,{children:"Total Events"})]})}),(0,l.jsx)(ea.Z,{children:null==m?void 0:m.map((e,t)=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.end_user}),(0,l.jsx)(en.Z,{children:e.total_spend}),(0,l.jsx)(en.Z,{children:e.total_events})]},t))})]})]})]})]})}),function(){if(!c)return null;let e=Math.ceil(c.length/25),t=Math.min(25*u,c.length);return(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsxs)("div",{children:["Showing ",(u-1)*25+1," – ",t," of ",c.length]}),(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===u,onClick:()=>x(u-1),children:"← Prev"}),(0,l.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",disabled:u===e,onClick:()=>x(u+1),children:"Next →"})]})]})}()]})})},eC=s(98941),eT=e=>{let{teams:t,searchParams:s,accessToken:a,setTeams:n,userID:o,userRole:i}=e,[c]=K.Z.useForm(),[m]=K.Z.useForm(),{Title:h,Paragraph:u}=ej.default,[p,j]=(0,r.useState)(""),[g,y]=(0,r.useState)(!1),[f,Z]=(0,r.useState)(t?t[0]:null),[_,k]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[N,S]=(0,r.useState)([]),[A,C]=(0,r.useState)(!1),[T,F]=(0,r.useState)(null),M=e=>{Z(e),y(!0)},z=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==a)return;let l=await P(a,e);t&&n(t.map(e=>e.team_id===s?l.data:e)),d.ZP.success("Team updated successfully"),y(!1),Z(null)},B=async e=>{F(e),C(!0)},W=async()=>{if(null!=T&&null!=t&&null!=a){try{await x(a,T);let e=t.filter(e=>e.team_id!==T);n(e)}catch(e){console.error("Error deleting the team:",e)}C(!1),F(null)}};(0,r.useEffect)(()=>{(async()=>{try{if(null===o||null===i)return;if(null!==a){let e=(await w(a,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),S(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[a,o,i]);let $=async e=>{try{if(null!=a){d.ZP.info("Creating Team");let s=await I(a,e);null!==t?n([...t,s]):n([s]),console.log("response for team create call: ".concat(s)),d.ZP.success("Team created"),k(!1)}}catch(e){console.error("Error creating the team:",e),d.ZP.error("Error creating the team: "+e)}},Y=async e=>{try{if(null!=a&&null!=t){d.ZP.info("Adding Member");let s={role:"user",user_email:e.user_email,user_id:e.user_id},l=await E(a,f.team_id,s);console.log("response for team create call: ".concat(l.data));let r=t.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(l.data.team_id)),e.team_id===l.data.team_id));if(console.log("foundIndex: ".concat(r)),-1!==r){let e=[...t];e[r]=l.data,n(e),Z(l.data)}v(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(t)),(0,l.jsx)("div",{className:"w-full mx-4",children:(0,l.jsxs)(R.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(h,{level:4,children:"All Teams"}),(0,l.jsxs)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Team Name"}),(0,l.jsx)(ei.Z,{children:"Spend (USD)"}),(0,l.jsx)(ei.Z,{children:"Budget (USD)"}),(0,l.jsx)(ei.Z,{children:"Models"}),(0,l.jsx)(ei.Z,{children:"TPM / RPM Limits"})]})}),(0,l.jsx)(ea.Z,{children:t&&t.length>0?t.map(e=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,l.jsx)(en.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"purple",children:(0,l.jsx)(U.Z,{children:"All Models"})}):e.models.map((e,t)=>(0,l.jsx)(X.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,l.jsx)(U.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},t))}):null}),(0,l.jsx)(en.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,l.jsxs)(U.Z,{children:["TPM:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,l.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,l.jsxs)(en.Z,{children:[(0,l.jsx)(el.Z,{icon:eC.Z,size:"sm",onClick:()=>M(e)}),(0,l.jsx)(el.Z,{onClick:()=>B(e.team_id),icon:H.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,l.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,l.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,l.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,l.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,l.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,l.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,l.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,l.jsx)("div",{className:"sm:flex sm:items-start",children:(0,l.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,l.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,l.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,l.jsx)(D.Z,{onClick:W,color:"red",className:"ml-2",children:"Delete"}),(0,l.jsx)(D.Z,{onClick:()=>{C(!1),F(null)},children:"Cancel"})]})]})]})})]})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(D.Z,{className:"mx-auto",onClick:()=>k(!0),children:"+ Create New Team"}),(0,l.jsx)(V.Z,{title:"Create Team",visible:_,width:800,footer:null,onOk:()=>{k(!1),c.resetFields()},onCancel:()=>{k(!1),c.resetFields()},children:(0,l.jsxs)(K.Z,{form:c,onFinish:$,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:N.map(e=>(0,l.jsx)(L.default.Option,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(h,{level:4,children:"Team Members"}),(0,l.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),t&&t.length>0?(0,l.jsx)(eh.Z,{defaultValue:"0",children:t.map((e,t)=>(0,l.jsx)(eu.Z,{value:String(t),onClick:()=>{Z(e)},children:e.team_alias},t))}):(0,l.jsxs)(u,{children:["No team created. ",(0,l.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Member Name"}),(0,l.jsx)(ei.Z,{children:"Role"})]})}),(0,l.jsx)(ea.Z,{children:f?f.members_with_roles.map((e,t)=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(en.Z,{children:e.role})]},t)):null})]})}),f&&(0,l.jsx)(e=>{let{visible:t,onCancel:s,team:r,onSubmit:a}=e,[n]=K.Z.useForm();return(0,l.jsx)(V.Z,{title:"Edit Team",visible:t,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{a({...e,team_id:r.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,l.jsxs)(K.Z,{form:n,onFinish:z,initialValues:r,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,l.jsx)(q.Z,{})}),(0,l.jsx)(K.Z.Item,{label:"Models",name:"models",children:(0,l.jsx)(L.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:N&&N.map(e=>(0,l.jsx)(L.default.Option,{value:e,children:e},e))})}),(0,l.jsx)(K.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,l.jsx)(J.Z,{step:.01,precision:2,width:200})}),(0,l.jsx)(K.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,l.jsx)(J.Z,{step:1,width:400})}),(0,l.jsx)(K.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:g,onCancel:()=>{y(!1),Z(null)},team:f,onSubmit:z})]}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(D.Z,{className:"mx-auto mb-5",onClick:()=>v(!0),children:"+ Add member"}),(0,l.jsx)(V.Z,{title:"Add member",visible:b,width:800,footer:null,onOk:()=>{v(!1),m.resetFields()},onCancel:()=>{v(!1),m.resetFields()},children:(0,l.jsxs)(K.Z,{form:c,onFinish:Y,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(K.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eI=e=>{let{searchParams:t,accessToken:s}=e,[a]=K.Z.useForm(),[n]=K.Z.useForm(),{Title:o,Paragraph:i}=ej.default,[c,m]=(0,r.useState)(""),[h,u]=(0,r.useState)(null),[x,p]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{if(null!=s){let e=[],t=await T(s,"proxy_admin_viewer");t.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy viewers: ".concat(t));let l=await T(s,"proxy_admin");l.forEach(t=>{e.push({user_role:t.user_role,user_id:t.user_id,user_email:t.user_email})}),console.log("proxy admins: ".concat(l)),console.log("combinedList: ".concat(e)),u(e)}})()},[s]);let j=async e=>{try{if(null!=s&&null!=h){d.ZP.info("Making API Call"),e.user_email,e.user_id;let t=await F(s,e);console.log("response for team create call: ".concat(t));let l=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(l)),-1==l&&(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,l.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,l.jsx)(o,{level:4,children:"Restricted Access"}),(0,l.jsxs)(i,{children:["Add other people to just view spend. They cannot create keys, teams or grant users access to new models."," ",(0,l.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"})]}),(0,l.jsxs)(R.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsx)(ee.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,l.jsxs)(er.Z,{children:[(0,l.jsx)(eo.Z,{children:(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(ei.Z,{children:"Member Name"}),(0,l.jsx)(ei.Z,{children:"Role"})]})}),(0,l.jsx)(ea.Z,{children:h?h.map((e,t)=>(0,l.jsxs)(ec.Z,{children:[(0,l.jsx)(en.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,l.jsx)(en.Z,{children:e.user_role})]},t)):null})]})})}),(0,l.jsxs)(O.Z,{numColSpan:1,children:[(0,l.jsx)(D.Z,{className:"mx-auto mb-5",onClick:()=>p(!0),children:"+ Add viewer"}),(0,l.jsx)(V.Z,{title:"Add viewer",visible:x,width:800,footer:null,onOk:()=>{p(!1),n.resetFields()},onCancel:()=>{p(!1),n.resetFields()},children:(0,l.jsxs)(K.Z,{form:a,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(K.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,l.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,l.jsx)(K.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,l.jsx)(q.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,l.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,l.jsx)(G.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})]})},eP=s(52273),eE=s(12968),eF=s(67951);async function eM(e,t,s,l){console.log("isLocal:",!1);let r=window.location.origin,a=new eE.ZP.OpenAI({apiKey:l,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let l of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(l),l.choices[0].delta.content&&t(l.choices[0].delta.content)}catch(e){d.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e))}}var eO=e=>{let{accessToken:t,token:s,userRole:a,userID:n}=e,[o,i]=(0,r.useState)(""),[c,d]=(0,r.useState)(""),[m,h]=(0,r.useState)([]),[u,x]=(0,r.useState)(void 0),[p,j]=(0,r.useState)([]);(0,r.useEffect)(()=>{t&&s&&a&&n&&(async()=>{try{let e=await w(t,n,a);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,a]);let g=(e,t)=>{h(s=>{let l=s[s.length-1];return l&&l.role===e?[...s.slice(0,s.length-1),{role:e,content:l.content+t}]:[...s,{role:e,content:t}]})},y=async()=>{if(""!==c.trim()&&o&&s&&a&&n){h(e=>[...e,{role:"user",content:c}]);try{u&&await eM(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(a&&"Admin Viewer"==a){let{Title:e,Paragraph:t}=ej.default;return(0,l.jsxs)("div",{children:[(0,l.jsx)(e,{level:1,children:"Access Denied"}),(0,l.jsx)(t,{children:"Ask your proxy admin for access to test models"})]})}return(0,l.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,l.jsx)(R.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,l.jsx)(ee.Z,{children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{children:[(0,l.jsx)(eZ.Z,{children:"Chat"}),(0,l.jsx)(eZ.Z,{children:"API Reference"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsxs)(eb.Z,{children:[(0,l.jsx)("div",{className:"sm:max-w-2xl",children:(0,l.jsxs)(R.Z,{numItems:2,children:[(0,l.jsxs)(O.Z,{children:[(0,l.jsx)(U.Z,{children:"API Key"}),(0,l.jsx)(eP.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,l.jsxs)(O.Z,{className:"mx-2",children:[(0,l.jsx)(U.Z,{children:"Select Model:"}),(0,l.jsx)(L.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,l.jsxs)(er.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,l.jsx)(eo.Z,{children:(0,l.jsx)(ec.Z,{children:(0,l.jsx)(en.Z,{})})}),(0,l.jsx)(ea.Z,{children:m.map((e,t)=>(0,l.jsx)(ec.Z,{children:(0,l.jsx)(en.Z,{children:"".concat(e.role,": ").concat(e.content)})},t))})]}),(0,l.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)(eP.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,l.jsx)(D.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]}),(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{children:[(0,l.jsx)(eZ.Z,{children:"OpenAI Python SDK"}),(0,l.jsx)(eZ.Z,{children:"LlamaIndex"}),(0,l.jsx)(eZ.Z,{children:"Langchain Py"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsx)(eb.Z,{children:(0,l.jsx)(eF.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # proxy base url\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to use from Models Tab\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ],\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-openai-client",\n "generation_id": "openai-client-gen-id22",\n "trace_id": "openai-client-trace-id22",\n "trace_user_id": "openai-client-user-id2"\n }\n }\n)\n\nprint(response)\n '})}),(0,l.jsx)(eb.Z,{children:(0,l.jsx)(eF.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,l.jsx)(eb.Z,{children:(0,l.jsx)(eF.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 '})})]})]})})]})]})})})})},eR=s(33509),eD=s(95781);let{Sider:eU}=eR.default;var ez=e=>{let{setPage:t,userRole:s,defaultSelectedKey:r}=e;return"Admin Viewer"==s?(0,l.jsx)(eR.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,l.jsx)(eU,{width:120,children:(0,l.jsxs)(eD.Z,{mode:"inline",defaultSelectedKeys:r||["4"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eD.Z.Item,{onClick:()=>t("api-keys"),children:"API Keys"},"4"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("models"),children:"Models"},"2"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("llm-playground"),children:"Chat UI"},"3"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("usage"),children:"Usage"},"1")]})})}):(0,l.jsx)(eR.default,{style:{minHeight:"100vh",maxWidth:"100px"},children:(0,l.jsx)(eU,{width:100,children:(0,l.jsxs)(eD.Z,{mode:"inline",defaultSelectedKeys:r||["1"],style:{height:"100%",borderRight:0},children:[(0,l.jsx)(eD.Z.Item,{onClick:()=>t("api-keys"),children:(0,l.jsx)(U.Z,{children:"API Keys"})},"1"),(0,l.jsx)(eD.Z.Item,{onClick:()=>t("llm-playground"),children:(0,l.jsx)(U.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,l.jsx)(eD.Z.Item,{onClick:()=>t("teams"),children:(0,l.jsx)(U.Z,{children:"Teams"})},"6"):null,(0,l.jsx)(eD.Z.Item,{onClick:()=>t("usage"),children:(0,l.jsx)(U.Z,{children:"Usage"})},"4"),"Admin"==s?(0,l.jsx)(eD.Z.Item,{onClick:()=>t("users"),children:(0,l.jsx)(U.Z,{children:"Users"})},"5"):null,(0,l.jsx)(eD.Z.Item,{onClick:()=>t("models"),children:(0,l.jsx)(U.Z,{children:"Models"})},"2"),"Admin"==s?(0,l.jsx)(eD.Z.Item,{onClick:()=>t("admin-panel"),children:(0,l.jsx)(U.Z,{children:"Admin"})},"7"):null]})})})},eB=e=>{let{accessToken:t,token:s,userRole:a,userID:n}=e,o=new Date,[i,c]=(0,r.useState)([]),[d,m]=(0,r.useState)([]),[h,u]=(0,r.useState)([]),[x,p]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[y,w]=(0,r.useState)([]),[f,v]=(0,r.useState)([]),A=new Date(o.getFullYear(),o.getMonth(),1),C=new Date(o.getFullYear(),o.getMonth()+1,0),T=P(A),I=P(C);function P(e){let t=e.getFullYear(),s=e.getMonth()+1,l=e.getDate();return"".concat(t,"-").concat(s<10?"0"+s:s,"-").concat(l<10?"0"+l:l)}return console.log("Start date is ".concat(T)),console.log("End date is ".concat(I)),(0,r.useEffect)(()=>{t&&s&&a&&n&&(async()=>{try{if(console.log("user role: ".concat(a)),"Admin"==a||"Admin Viewer"==a){let e=await k(t);c(e);let s=(await b(t)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,7),spend:e.total_spend}));m(s);let l=(await N(t)).map(e=>({key:e.model,spend:e.total_spend}));u(l);let r=await Z(t);console.log("teamSpend",r),g(r.daily_spend),w(r.teams),v(r.total_spend_per_team)}else"App Owner"==a&&await _(t,s,a,n,T,I).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let t=e.daily_spend;console.log("daily spend",t),c(t);let s=e.top_api_keys;m(s)}else{let s=(await S(t,function(e){let t=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,l]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&t.push({key:s,spend:l})})}),t.sort((e,t)=>Number(t.spend)-Number(e.spend));let s=t.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias||e.token).substring(0,7),spend:e.spend}));m(s),p(function(e){let t={};e.forEach(e=>{Object.entries(e.users).forEach(e=>{let[s,l]=e;""!==s&&null!=s&&"None"!=s&&(t[s]||(t[s]=0),t[s]+=l)})});let s=Object.entries(t).map(e=>{let[t,s]=e;return{user_id:t,spend:s}});s.sort((e,t)=>t.spend-e.spend);let l=s.slice(0,5);return console.log("topKeys: ".concat(Object.values(l[0]))),l}(e)),c(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[t,s,a,n,T,I]),(0,l.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,l.jsxs)(e_.Z,{children:[(0,l.jsxs)(ek.Z,{className:"mt-2",children:[(0,l.jsx)(eZ.Z,{children:"All Up"}),(0,l.jsx)(eZ.Z,{children:"Team Based Usage"})]}),(0,l.jsxs)(ev.Z,{children:[(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(R.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,l.jsx)(O.Z,{numColSpan:2,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Monthly Spend"}),(0,l.jsx)(Q.Z,{data:i,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Top API Keys"}),(0,l.jsx)(Q.Z,{className:"mt-4 h-40",data:d,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Top Users"}),(0,l.jsx)(Q.Z,{className:"mt-4 h-40",data:x,index:"user_id",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,l.jsx)(O.Z,{numColSpan:1,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Top Models"}),(0,l.jsx)(Q.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,l.jsx)(eb.Z,{children:(0,l.jsxs)(R.Z,{numItems:2,className:"gap-2 p-10 h-[75vh] w-full",children:[(0,l.jsx)(O.Z,{numColSpan:2,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Daily Spend Per Team"}),(0,l.jsx)(Q.Z,{className:"h-72",data:j,index:"date",categories:y,yAxisWidth:30,stack:!0})]})}),(0,l.jsx)(O.Z,{numColSpan:2,children:(0,l.jsxs)(ee.Z,{children:[(0,l.jsx)(z.Z,{children:"Total Spend Per Team"}),(0,l.jsx)(Q.Z,{className:"h-72",data:f,index:"team_id",categories:["total_spend"],yAxisWidth:30})]})})]})})]})]})})},eL=()=>{let{Title:e,Paragraph:t}=ej.default,[s,n]=(0,r.useState)(""),[o,i]=(0,r.useState)(null),[d,m]=(0,r.useState)(null),[h,u]=(0,r.useState)(null),[x,p]=(0,r.useState)(!0),j=(0,a.useSearchParams)(),g=j.get("userID"),y=j.get("token"),[w,f]=(0,r.useState)("api-keys"),[Z,_]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(y){let e=(0,ep.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),_(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,l.jsx)(r.Suspense,{fallback:(0,l.jsx)("div",{children:"Loading..."}),children:(0,l.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,l.jsx)(c,{userID:g,userRole:s,userEmail:o,showSSOBanner:x}),(0,l.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,l.jsx)("div",{className:"mt-8",children:(0,l.jsx)(ez,{setPage:f,userRole:s,defaultSelectedKey:null})}),"api-keys"==w?(0,l.jsx)(eg,{userID:g,userRole:s,teams:d,keys:h,setUserRole:n,userEmail:o,setUserEmail:i,setTeams:m,setKeys:u}):"models"==w?(0,l.jsx)(ef,{userID:g,userRole:s,token:y,accessToken:Z}):"llm-playground"==w?(0,l.jsx)(eO,{userID:g,userRole:s,token:y,accessToken:Z}):"users"==w?(0,l.jsx)(eA,{userID:g,userRole:s,token:y,keys:h,accessToken:Z,setKeys:u}):"teams"==w?(0,l.jsx)(eT,{teams:d,setTeams:m,searchParams:j,accessToken:Z,userID:g,userRole:s}):"admin-panel"==w?(0,l.jsx)(eI,{setTeams:m,searchParams:j,accessToken:Z}):(0,l.jsx)(eB,{userID:g,userRole:s,token:y,accessToken:Z})]})]})})}}},function(e){e.O(0,[798,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.html b/ui/litellm-dashboard/out/index.html index 219166a4d..1a2bd5a68 100644 --- a/ui/litellm-dashboard/out/index.html +++ b/ui/litellm-dashboard/out/index.html @@ -1 +1,5 @@ -🚅 LiteLLM \ No newline at end of file +<<<<<<< HEAD +🚅 LiteLLM +======= +🚅 LiteLLM +>>>>>>> e6a09427 ((new) ui build) diff --git a/ui/litellm-dashboard/out/index.txt b/ui/litellm-dashboard/out/index.txt index cfb598f35..2d4ea3f9e 100644 --- a/ui/litellm-dashboard/out/index.txt +++ b/ui/litellm-dashboard/out/index.txt @@ -1,7 +1,14 @@ 2:I[77831,[],""] +<<<<<<< HEAD 3:I[90177,["798","static/chunks/798-4baed68da0c5497d.js","931","static/chunks/app/page-a5a04da2a9356785.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] 0:["DptMjzo5xd96cx0b56k4u",[[["",{"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/f8da5a6a5b29d249.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +======= +3:I[90177,["798","static/chunks/798-4baed68da0c5497d.js","931","static/chunks/app/page-37392d6753f8a3d0.js"],""] +4:I[5613,[],""] +5:I[31778,[],""] +0:["L9N6TOWJaqSp22Vj96YE4",[[["",{"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/f8da5a6a5b29d249.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +>>>>>>> e6a09427 ((new) ui build) 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"🚅 LiteLLM"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/src/components/teams.tsx b/ui/litellm-dashboard/src/components/teams.tsx index 9ef093ff5..6a22aba11 100644 --- a/ui/litellm-dashboard/src/components/teams.tsx +++ b/ui/litellm-dashboard/src/components/teams.tsx @@ -37,6 +37,15 @@ interface TeamProps { userID: string | null; userRole: string | null; } + +interface EditTeamModalProps { + visible: boolean; + onCancel: () => void; + team: any; // Assuming TeamType is a type representing your team object + onSubmit: (data: FormData) => void; // Assuming FormData is the type of data to be submitted +} + + import { teamCreateCall, teamMemberAddCall, Member, modelAvailableCall } from "./networking"; const Team: React.FC = ({ @@ -64,7 +73,7 @@ const Team: React.FC = ({ const [teamToDelete, setTeamToDelete] = useState(null); -const EditTeamModal = ({ visible, onCancel, team, onSubmit }) => { + const EditTeamModal: React.FC = ({ visible, onCancel, team, onSubmit }) => { const [form] = Form.useForm(); const handleOk = () => {